VerAckHandle handles the version ack from peer
(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{})
| 362 | |
| 363 | // VerAckHandle handles the version ack from peer |
| 364 | func 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 |
| 396 | func AddrHandle(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{}) { |