From 8ca64e305d43c5bfa54bfdd3d2483c83856487a7 Mon Sep 17 00:00:00 2001 From: "@edgararout" Date: Wed, 28 Jul 2021 08:24:41 -0400 Subject: [PATCH] consensus/ethash: less allocation during mining (#23199) --- consensus/ethash/sealer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/sealer.go b/consensus/ethash/sealer.go index 1830e672b1ff3..6fa60ef6a8bbd 100644 --- a/consensus/ethash/sealer.go +++ b/consensus/ethash/sealer.go @@ -140,8 +140,9 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s ) // Start generating random nonces until we abort or find a good one var ( - attempts = int64(0) - nonce = seed + attempts = int64(0) + nonce = seed + powBuffer = new(big.Int) ) logger := ethash.config.Log.New("miner", id) logger.Trace("Started ethash search for new nonces", "seed", seed) @@ -163,7 +164,7 @@ search: } // Compute the PoW value of this nonce digest, result := hashimotoFull(dataset.dataset, hash, nonce) - if new(big.Int).SetBytes(result).Cmp(target) <= 0 { + if powBuffer.SetBytes(result).Cmp(target) <= 0 { // Correct nonce found, create a new header with it header = types.CopyHeader(header) header.Nonce = types.EncodeNonce(nonce)