Skip to content

Peer.InitPoWExtension

Source (upstream pre-purge) Current
File eth/protocols/eth/peer.go peer_pow.go
Symbol NewPeer (lines 105-107) Peer.InitPoWExtension
Ref f4d53133f~1 etc/v1.17.3-full-node

Extracted from NewPeer — initializes the PoW-specific fields (head, td, knownBlocks, queuedBlocks, queuedBlockAnns) that were previously set inline in the Peer constructor. Transaction fields (txBroadcast, txAnnounce, knownTxs) remain in upstream NewPeer since they are not PoW-specific.

Diff — vs pre-nuke original (reimplemented)

--- a/eth/protocols/eth/peer.go
+++ b/eth/protocols/eth/peer_pow.go
@@ -1,3 +1,12 @@
+// InitPoWExtension initializes PoW-specific fields for the peer.
+// This should be called after a successful PoW handshake.
+func (p *Peer) InitPoWExtension(head common.Hash, td *big.Int) {
+   p.powExt = &PoWPeerExtension{
+       head:            head,
+       td:              new(big.Int).Set(td),
+       knownBlocks:     newKnownCache(maxKnownBlocks),
        queuedBlocks:    make(chan *blockPropagation, maxQueuedBlocks),
        queuedBlockAnns: make(chan *types.Block, maxQueuedBlockAnns),
-       txBroadcast:     make(chan []common.Hash),
+   }
+   go p.broadcastBlocksPoW()
+}
core-geth validation — +9 -0 | | | |---|---| | File | [`peer.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/protocols/eth/peer.go) | | Symbol | `Peer.NewPeer` | | Ref | `v1.12.20` |
--- a/core-geth/eth/protocols/eth/peer.go
+++ b/etc/eth/protocols/eth/peer_pow.go
@@ -1,3 +1,12 @@
+// InitPoWExtension initializes PoW-specific fields for the peer.
+// This should be called after a successful PoW handshake.
+func (p *Peer) InitPoWExtension(head common.Hash, td *big.Int) {
+   p.powExt = &PoWPeerExtension{
+       head:            head,
+       td:              new(big.Int).Set(td),
        knownBlocks:     newKnownCache(maxKnownBlocks),
        queuedBlocks:    make(chan *blockPropagation, maxQueuedBlocks),
        queuedBlockAnns: make(chan *types.Block, maxQueuedBlockAnns),
+   }
+   go p.broadcastBlocksPoW()
+}

← eth Protocol