Unverified Commit 0730acc5 authored by @edgararout's avatar @edgararout Committed by GitHub

consensus/ethash: less allocation during mining (#23199)

parent 2faf796d
...@@ -142,6 +142,7 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s ...@@ -142,6 +142,7 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s
var ( var (
attempts = int64(0) attempts = int64(0)
nonce = seed nonce = seed
powBuffer = new(big.Int)
) )
logger := ethash.config.Log.New("miner", id) logger := ethash.config.Log.New("miner", id)
logger.Trace("Started ethash search for new nonces", "seed", seed) logger.Trace("Started ethash search for new nonces", "seed", seed)
...@@ -163,7 +164,7 @@ search: ...@@ -163,7 +164,7 @@ search:
} }
// Compute the PoW value of this nonce // Compute the PoW value of this nonce
digest, result := hashimotoFull(dataset.dataset, hash, 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 // Correct nonce found, create a new header with it
header = types.CopyHeader(header) header = types.CopyHeader(header)
header.Nonce = types.EncodeNonce(nonce) header.Nonce = types.EncodeNonce(nonce)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment