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

Method timeout

p2pserver/p2pserver.go:528–542  ·  view source on GitHub ↗

timeout trace whether some peer be long time no response

()

Source from the content-addressed store, hash-verified

526
527//timeout trace whether some peer be long time no response
528func (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
545func (this *P2PServer) addToRetryList(addr string) {

Callers 1

heartBeatServiceMethod · 0.95

Calls 9

WarnfFunction · 0.92
GetContactTimeMethod · 0.80
AddMethod · 0.80
GetNeighborsMethod · 0.65
GetIDMethod · 0.65
CloseMethod · 0.65
GetStateMethod · 0.45
GetAddrMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected