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

Method IsNbrPeerAddr

p2pserver/net/netserver/netserver.go:478–492  ·  view source on GitHub ↗

IsNbrPeerAddr return result whether the address is under connecting

(addr string)

Source from the content-addressed store, hash-verified

476
477//IsNbrPeerAddr return result whether the address is under connecting
478func (this *NetServer) IsNbrPeerAddr(addr string) bool {
479 var addrNew string
480 this.Np.RLock()
481 defer this.Np.RUnlock()
482 for _, p := range this.Np.List {
483 if p.GetState() == common.HAND || p.GetState() == common.HAND_SHAKE ||
484 p.GetState() == common.ESTABLISH {
485 addrNew = p.Link.GetAddr()
486 if strings.Compare(addrNew, addr) == 0 {
487 return true
488 }
489 }
490 }
491 return false
492}
493
494//AddPeerAddress add sync addr to peer-addr map
495func (this *NetServer) AddPeerAddress(addr string, p *peer.Peer) {

Callers 1

ConnectMethod · 0.95

Calls 2

GetStateMethod · 0.45
GetAddrMethod · 0.45

Tested by

no test coverage detected