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

Function VerAckHandle

p2pserver/message/utils/msg_handler.go:364–393  ·  view source on GitHub ↗

VerAckHandle handles the version ack from peer

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

Source from the content-addressed store, hash-verified

362
363// VerAckHandle handles the version ack from peer
364func VerAckHandle(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{}) {
365 log.Trace("[p2p]receive verAck message from ", data.Addr, data.Id)
366
367 //verAck := data.Payload.(*msgTypes.VerACK)
368 remotePeer := p2p.GetPeer(data.Id)
369
370 if remotePeer == nil {
371 log.Warn("[p2p]nbr node is not exist", data.Id, data.Addr)
372 return
373 }
374
375 s := remotePeer.GetState()
376 if s != msgCommon.HAND_SHAKE && s != msgCommon.HAND_SHAKED {
377 log.Warnf("[p2p]unknown status to received verAck,state:%d,%s\n", s, data.Addr)
378 return
379 }
380
381 remotePeer.SetState(msgCommon.ESTABLISH)
382 p2p.RemoveFromConnectingList(data.Addr)
383 remotePeer.DumpInfo()
384
385 if s == msgCommon.HAND_SHAKE {
386 msg := msgpack.NewVerAck()
387 p2p.Send(remotePeer, msg)
388 }
389
390 msg := msgpack.NewAddrReq()
391 go p2p.Send(remotePeer, msg)
392
393}
394
395// AddrHandle handles the neighbor address response message from peer
396func AddrHandle(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{}) {

Callers 1

TestVerAckHandleFunction · 0.85

Calls 9

TraceFunction · 0.92
WarnFunction · 0.92
WarnfFunction · 0.92
SetStateMethod · 0.80
DumpInfoMethod · 0.80
GetPeerMethod · 0.65
SendMethod · 0.65
GetStateMethod · 0.45

Tested by 1

TestVerAckHandleFunction · 0.68