only broad crosslink if a new block is added to beacon chain (#3756)

pull/3760/head
Rongjian Lan 4 years ago committed by GitHub
parent d9489bdb6e
commit 6ef6580ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      node/node_syncing.go

@ -218,14 +218,18 @@ func (node *Node) doBeaconSyncing() {
// TODO ek – infinite loop; add shutdown/cleanup logic
for beaconBlock := range node.BeaconBlockChannel {
if node.beaconSync != nil {
err := node.beaconSync.UpdateBlockAndStatus(
beaconBlock, node.Beaconchain(), true,
)
if err != nil {
node.beaconSync.AddLastMileBlock(beaconBlock)
} else if node.Consensus.IsLeader() || rand.Intn(100) == 0 {
// Only leader or 1% of validators broadcast crosslink to avoid spamming p2p
node.BroadcastCrossLink()
if beaconBlock.NumberU64() >= node.Beaconchain().CurrentBlock().NumberU64()+1 {
err := node.beaconSync.UpdateBlockAndStatus(
beaconBlock, node.Beaconchain(), true,
)
if err != nil {
node.beaconSync.AddLastMileBlock(beaconBlock)
} else if node.Consensus.IsLeader() || rand.Intn(100) == 0 {
// Only leader or 1% of validators broadcast crosslink to avoid spamming p2p
if beaconBlock.NumberU64() == node.Beaconchain().CurrentBlock().NumberU64() {
node.BroadcastCrossLink()
}
}
}
}
}

Loading…
Cancel
Save