Skip to content

ethHandler.handleBlockBroadcast

Source (upstream pre-purge) Current
File eth/handler_eth.go handler_pow.go
Symbol ethHandler.handleBlockBroadcast ethHandler.handleBlockBroadcast
Ref f4d53133f~1 etc/v1.17.3-full-node

Removed PoS merger check (not applicable to ETC). — see ethHandler.handleBlockAnnounces

3-way merge — purge → getc ← upstream

pre-purge
// handleBlockBroadcast is invoked from a peer's message handler when it transmits a
// block broadcast for the local node to process.
func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, block *types.Block, td *big.Int) error {
// Schedule the block for import
h.blockFetcher.Enqueue(peer.ID(), block)
// Assuming the block is importable by the peer, but possibly not yet done so,
// calculate the head hash and TD that the peer truly must have.
var (
trueHead = block.ParentHash()
trueTD = new(big.Int).Sub(td, block.Difficulty())
)
// Update the peer's total difficulty if better than the previous
if _, td := peer.Head(); trueTD.Cmp(td) > 0 {
peer.SetHead(trueHead, trueTD)
h.chainSync.handlePeerEvent()
}
return nil
}
core-geth validation — +2 -8 | | | |---|---| | File | [`handler_eth.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/handler_eth.go) | | Symbol | `ethHandler.handleBlockBroadcast` | | Ref | `v1.12.20` |
--- a/core-geth/eth/handler_eth.go
+++ b/etc/eth/handler_pow.go
@@ -1,12 +1,6 @@
 // handleBlockBroadcast is invoked from a peer's message handler when it transmits a
 // block broadcast for the local node to process.
 func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, block *types.Block, td *big.Int) error {
-   // Drop all incoming block announces from the p2p network if
-   // the chain already entered the pos stage and disconnect the
-   // remote peer.
-   if h.merger.PoSFinalized() {
-       return errors.New("disallowed block broadcast")
-   }
    // Schedule the block for import
    h.blockFetcher.Enqueue(peer.ID(), block)

@@ -17,8 +11,8 @@
        trueTD   = new(big.Int).Sub(td, block.Difficulty())
    )
    // Update the peer's total difficulty if better than the previous
-   if _, td, _ := peer.Head(); trueTD.Cmp(td) > 0 {
-       peer.SetHead(trueHead, trueTD, block.Difficulty())
+   if _, td := peer.Head(); trueTD.Cmp(td) > 0 {
+       peer.SetHead(trueHead, trueTD)
        h.chainSync.handlePeerEvent()
    }
    return nil

← Eth Service