diff --git a/eth/handler.go b/eth/handler.go index 6f2bb7cdde..bb63d64bfa 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -833,7 +833,8 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) { // Step 1: Select target peers for initial broadcast. limit := totalPeers - if !h.directBroadcast { + if !h.directBroadcast && + !(h.networkID == 714 /*RialtoChainConfig.ChainID*/ && block.NumberU64() == 1) { // Populate TD from every receiver on startup to establish proper sync. limit = int(math.Sqrt(float64(totalPeers))) } diff --git a/eth/handler_eth.go b/eth/handler_eth.go index 0099fb0873..d96b3b849c 100644 --- a/eth/handler_eth.go +++ b/eth/handler_eth.go @@ -165,6 +165,10 @@ func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, packet *eth.NewBlockPa trueHead = block.ParentHash() trueTD = new(big.Int).Sub(td, block.Difficulty()) ) + if block.NumberU64() == 1 { // this enable sync with the right peer when starting up a new network + trueHead = block.Hash() + trueTD = td + } // Update the peer's total difficulty if better than the previous if _, td := peer.Head(); trueTD.Cmp(td) > 0 { peer.SetHead(trueHead, trueTD) diff --git a/eth/sync.go b/eth/sync.go index 9c608f374c..cf66a324d4 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -260,7 +260,11 @@ func (h *handler) doSync(op *chainSyncOp) error { // degenerate connectivity, but it should be healthy for the mainnet too to // more reliably update peers or the local TD state. if block := h.chain.GetBlock(head.Hash(), head.Number.Uint64()); block != nil { - h.BroadcastBlock(block, false) + if head.Number.Uint64() == 1 { // Update TD from all receivers during network initialization. + h.BroadcastBlock(block, true) + } else { + h.BroadcastBlock(block, false) + } } } return nil