Skip to content

handler.BroadcastBlock

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

3-way merge — purge → getc ← upstream

pre-purge
// BroadcastBlock will either propagate a block to a subset of its peers, or
// will only announce its availability (depending what's requested).
func (h *handler) BroadcastBlock(block *types.Block, propagate bool) {
hash := block.Hash()
peers := h.peers.peersWithoutBlock(hash)
// If propagation is requested, send to a subset of the peer
if propagate {
// Calculate the TD of the block (it's not imported yet, so block.Td is not valid)
var td *big.Int
if parent := h.chain.GetBlock(block.ParentHash(), block.NumberU64()-1); parent != nil {
td = new(big.Int).Add(block.Difficulty(), h.chain.GetTd(block.ParentHash(), block.NumberU64()-1))
} else {
log.Error("Propagating dangling block", "number", block.Number(), "hash", hash)
return
}
// Send the block to a subset of our peers
transfer := peers[:int(math.Sqrt(float64(len(peers))))]
for _, peer := range transfer {
peer.AsyncSendNewBlock(block, td)
}
log.Trace("Propagated block", "hash", hash, "recipients", len(transfer), "duration", common.PrettyDuration(time.Since(block.ReceivedAt)))
return
}
// Otherwise if the block is indeed in out own chain, announce it
if h.chain.HasBlock(hash, block.NumberU64()) {
for _, peer := range peers {
peer.AsyncSendNewBlockHash(block)
}
log.Trace("Announced block", "hash", hash, "recipients", len(peers), "duration", common.PrettyDuration(time.Since(block.ReceivedAt)))
}
}
core-geth validation — +0 -11 | | | |---|---| | File | [`handler.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/handler.go) | | Symbol | `handler.BroadcastBlock` | | Ref | `v1.12.20` |
--- a/core-geth/eth/handler.go
+++ b/etc/eth/handler_pow.go
@@ -1,17 +1,6 @@
 // BroadcastBlock will either propagate a block to a subset of its peers, or
 // will only announce its availability (depending what's requested).
 func (h *handler) BroadcastBlock(block *types.Block, propagate bool) {
-   // Disable the block propagation if the chain has already entered the PoS
-   // stage. The block propagation is delegated to the consensus layer.
-   if h.merger.PoSFinalized() {
-       return
-   }
-   // Disable the block propagation if it's the post-merge block.
-   if beacon, ok := h.chain.Engine().(*beacon.Beacon); ok {
-       if beacon.IsPoSHeader(block.Header()) {
-           return
-       }
-   }
    hash := block.Hash()
    peers := h.peers.peersWithoutBlock(hash)

← Eth Service