MCPcopy Create free account
hub / github.com/DNAProject/DNA / pingOutsyncNodes

Method pingOutsyncNodes

p2pserver/block_sync.go:971–992  ·  view source on GitHub ↗

pingOutsyncNodes send ping msg to lower height nodes for syncing

(curHeight uint32)

Source from the content-addressed store, hash-verified

969
970//pingOutsyncNodes send ping msg to lower height nodes for syncing
971func (this *BlockSyncMgr) pingOutsyncNodes(curHeight uint32) {
972 peers := make([]*peer.Peer, 0)
973 this.lock.RLock()
974 maxHeight := curHeight
975 for id := range this.nodeWeights {
976 peer := this.server.getNode(id)
977 if peer == nil {
978 continue
979 }
980 peerHeight := uint32(peer.GetHeight())
981 if peerHeight >= maxHeight {
982 maxHeight = peerHeight
983 }
984 if peerHeight < curHeight {
985 peers = append(peers, peer)
986 }
987 }
988 this.lock.RUnlock()
989 if curHeight > maxHeight-SYNC_MAX_HEIGHT_OFFSET && len(peers) > 0 {
990 this.server.pingTo(peers)
991 }
992}
993
994//Using polling for load balance
995func getNextNodeId(nextNodeIndex int, nodeList []uint64) (int, uint64) {

Callers 1

saveBlockMethod · 0.95

Calls 3

getNodeMethod · 0.80
pingToMethod · 0.80
GetHeightMethod · 0.65

Tested by

no test coverage detected