AddrHandle handles the neighbor address response message from peer
(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{})
| 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{}) { |
| 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 |
| 429 | func DataReqHandle(data *msgTypes.MsgPayload, p2p p2p.P2P, pid *evtActor.PID, args ...interface{}) { |