Skip to content

Commit 0730acc

Browse files
authored
consensus/ethash: less allocation during mining (ethereum#23199)
1 parent 2faf796 commit 0730acc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

consensus/ethash/sealer.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s
140140
)
141141
// Start generating random nonces until we abort or find a good one
142142
var (
143-
attempts = int64(0)
144-
nonce = seed
143+
attempts = int64(0)
144+
nonce = seed
145+
powBuffer = new(big.Int)
145146
)
146147
logger := ethash.config.Log.New("miner", id)
147148
logger.Trace("Started ethash search for new nonces", "seed", seed)
@@ -163,7 +164,7 @@ search:
163164
}
164165
// Compute the PoW value of this nonce
165166
digest, result := hashimotoFull(dataset.dataset, hash, nonce)
166-
if new(big.Int).SetBytes(result).Cmp(target) <= 0 {
167+
if powBuffer.SetBytes(result).Cmp(target) <= 0 {
167168
// Correct nonce found, create a new header with it
168169
header = types.CopyHeader(header)
169170
header.Nonce = types.EncodeNonce(nonce)

0 commit comments

Comments
 (0)