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

Function AddrHandle

p2pserver/message/utils/msg_handler.go:396–426  ·  view source on GitHub ↗

AddrHandle handles the neighbor address response message from peer

(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{})

Source from the content-addressed store, hash-verified

394
395// AddrHandle handles the neighbor address response message from peer
396func AddrHandle(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{}) {
397 log.Trace("[p2p]handle addr message", data.Addr, data.Id)
398
399 var msg = data.Payload.(*msgTypes.Addr)
400 for _, v := range msg.NodeAddrs {
401 var ip net.IP
402 ip = v.IpAddr[:]
403 address := ip.To16().String() + ":" + strconv.Itoa(int(v.Port))
404
405 if v.ID == p2p.GetID() {
406 continue
407 }
408
409 if p2p.NodeEstablished(v.ID) {
410 continue
411 }
412
413 if ret := p2p.GetPeerFromAddr(address); ret != nil {
414 continue
415 }
416
417 if v.Port == 0 {
418 continue
419 }
420 if p2p.IsAddrFromConnecting(address) {
421 continue
422 }
423 log.Debug("[p2p]connect ip address:", address)
424 go p2p.Connect(address)
425 }
426}
427
428// DataReqHandle handles the data req(block/Transaction) from peer
429func DataReqHandle(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{}) {

Callers 1

TestAddrHandleFunction · 0.85

Calls 8

TraceFunction · 0.92
DebugFunction · 0.92
GetIDMethod · 0.65
NodeEstablishedMethod · 0.65
GetPeerFromAddrMethod · 0.65
IsAddrFromConnectingMethod · 0.65
ConnectMethod · 0.65
StringMethod · 0.45

Tested by 1

TestAddrHandleFunction · 0.68