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

Method reachMinConnection

p2pserver/p2pserver.go:354–373  ·  view source on GitHub ↗

reachMinConnection return whether net layer have enough link under different config

()

Source from the content-addressed store, hash-verified

352
353//reachMinConnection return whether net layer have enough link under different config
354func (this *P2PServer) reachMinConnection() bool {
355 if !config.DefConfig.Consensus.EnableConsensus {
356 //just sync
357 return true
358 }
359 consensusType := strings.ToLower(config.DefConfig.Genesis.ConsensusType)
360 if consensusType == "" {
361 consensusType = "dbft"
362 }
363 minCount := config.DBFT_MIN_NODE_NUM
364 switch consensusType {
365 case "dbft":
366 case "solo":
367 minCount = config.SOLO_MIN_NODE_NUM
368 case "vbft":
369 minCount = config.VBFT_MIN_NODE_NUM
370
371 }
372 return int(this.GetConnectionCnt())+1 >= minCount
373}
374
375//getNode returns the peer with the id
376func (this *P2PServer) getNode(id uint64) *peer.Peer {

Callers 3

WaitForPeersStartMethod · 0.95
connectSeedServiceMethod · 0.95
syncHeaderMethod · 0.80

Calls 1

GetConnectionCntMethod · 0.95

Tested by

no test coverage detected