From 9b8c8c954d9f8457564582a2b3d910aaaf4256c5 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 23 Aug 2018 20:11:21 +0800 Subject: [PATCH] miner: evict pending task with threshold --- miner/worker.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/miner/worker.go b/miner/worker.go index 96c19b650d..d32ffffe9a 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -72,6 +72,9 @@ const ( // intervalAdjustBias is applied during the new resubmit interval calculation in favor of // increasing upper limit or decreasing lower limit so that the limit can be reachable. intervalAdjustBias = 200 * 1000.0 * 1000.0 + + // staleThreshold is the maximum distance of the acceptable stale block. + staleThreshold = 7 ) // environment is the worker's current environment and holds all of the current state information. @@ -325,7 +328,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) { clearPending := func(number uint64) { w.pendingMu.Lock() for h, t := range w.pendingTasks { - if t.block.NumberU64() <= number { + if t.block.NumberU64() + staleThreshold <= number { delete(w.pendingTasks, h) } }