timeout trace whether some peer be long time no response
()
| 526 | |
| 527 | //timeout trace whether some peer be long time no response |
| 528 | func (this *P2PServer) timeout() { |
| 529 | peers := this.network.GetNeighbors() |
| 530 | var periodTime uint |
| 531 | periodTime = config.DEFAULT_GEN_BLOCK_TIME / common.UPDATE_RATE_PER_BLOCK |
| 532 | for _, p := range peers { |
| 533 | if p.GetState() == common.ESTABLISH { |
| 534 | t := p.GetContactTime() |
| 535 | if t.Before(time.Now().Add(-1 * time.Second * |
| 536 | time.Duration(periodTime) * common.KEEPALIVE_TIMEOUT)) { |
| 537 | log.Warnf("[p2p]keep alive timeout!!!lost remote peer %d - %s from %s", p.GetID(), p.Link.GetAddr(), t.String()) |
| 538 | p.Close() |
| 539 | } |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | //addToRetryList add retry address to ReconnectAddrs |
| 545 | func (this *P2PServer) addToRetryList(addr string) { |
no test coverage detected