diff --git a/consensus/ethash/sealer.go b/consensus/ethash/sealer.go index 8dc2111a50..b5e742d8bb 100644 --- a/consensus/ethash/sealer.go +++ b/consensus/ethash/sealer.go @@ -97,10 +97,9 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan struct{}, found chan *types.Block) { // Extract some data from the header var ( - header = block.Header() - hash = header.HashNoNonce().Bytes() - target = new(big.Int).Div(maxUint256, header.Difficulty) - + header = block.Header() + hash = header.HashNoNonce().Bytes() + target = new(big.Int).Div(maxUint256, header.Difficulty) number = header.Number.Uint64() dataset = ethash.dataset(number) ) @@ -111,13 +110,14 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s ) logger := log.New("miner", id) logger.Trace("Started ethash search for new nonces", "seed", seed) +search: for { select { case <-abort: // Mining terminated, update stats and abort logger.Trace("Ethash nonce search aborted", "attempts", nonce-seed) ethash.hashrate.Mark(attempts) - return + break search default: // We don't have to update hash rate on every nonce, so update after after 2^X nonces @@ -141,7 +141,7 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s case <-abort: logger.Trace("Ethash nonce found but discarded", "attempts", nonce-seed, "nonce", nonce) } - return + break search } nonce++ }