Skip to content

pruneStaleUncles

Source (upstream pre-purge) Current
File miner/worker.go uncles_pow.go
Symbol worker.mainLoop (lines 607-618) powWorker.pruneStaleUncles
Ref dde2da0ef~1 etc/v1.17.3-full-node

Purges stale uncle candidates. From the cleanTicker case of the pre-purge mainLoop.

Diff — vs pre-nuke original (reimplemented)

--- a/miner/worker.go
+++ b/miner/uncles_pow.go
@@ -1,12 +1,15 @@
-       case <-cleanTicker.C:
+// pruneStaleUncles drops uncle candidates that have fallen too far behind the
+// chain head to still be includable.
+func (w *powWorker) pruneStaleUncles() {
            chainHead := w.chain.CurrentBlock()
            for hash, uncle := range w.localUncles {
-               if uncle.NumberU64()+staleThreshold <= chainHead.Number.Uint64() {
+       if uncle.Number.Uint64()+staleThreshold <= chainHead.Number.Uint64() {
                    delete(w.localUncles, hash)
                }
            }
            for hash, uncle := range w.remoteUncles {
-               if uncle.NumberU64()+staleThreshold <= chainHead.Number.Uint64() {
+       if uncle.Number.Uint64()+staleThreshold <= chainHead.Number.Uint64() {
                    delete(w.remoteUncles, hash)
                }
            }
+}

← Miner