Skip to content

collectUncle

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

Records a side-block header as an uncle candidate. From the chainSideCh case of the pre-purge mainLoop; classifies local/remote by etherbase (instead of isLocalBlock).

Diff — vs pre-nuke original (reimplemented)

--- a/miner/worker.go
+++ b/miner/uncles_pow.go
@@ -1,14 +1,21 @@
-       case ev := <-w.chainSideCh:
-           // Short circuit for duplicate side blocks
-           if _, exist := w.localUncles[ev.Block.Hash()]; exist {
-               continue
+// collectUncle records a side-block header as a possible uncle, classifying it
+// as locally or remotely mined by comparing against the configured etherbase.
+// It returns true if the header was newly added (not a duplicate).
+func (w *powWorker) collectUncle(header *types.Header) bool {
+   if header == nil {
+       return false
            }
-           if _, exist := w.remoteUncles[ev.Block.Hash()]; exist {
-               continue
+   hash := header.Hash()
+   if _, exist := w.localUncles[hash]; exist {
+       return false
            }
-           // Add side block to possible uncle block set depending on the author.
-           if w.isLocalBlock != nil && w.isLocalBlock(ev.Block.Header()) {
-               w.localUncles[ev.Block.Hash()] = ev.Block
+   if _, exist := w.remoteUncles[hash]; exist {
+       return false
+   }
+   if header.Coinbase == w.etherbase() {
+       w.localUncles[hash] = header
            } else {
-               w.remoteUncles[ev.Block.Hash()] = ev.Block
+       w.remoteUncles[hash] = header
            }
+   return true
+}

← Miner