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

Method heartBeatService

p2pserver/p2pserver.go:493–508  ·  view source on GitHub ↗

heartBeat send ping to nbr peers and check the timeout

()

Source from the content-addressed store, hash-verified

491
492//heartBeat send ping to nbr peers and check the timeout
493func (this *P2PServer) heartBeatService() {
494 var periodTime uint
495 periodTime = config.DEFAULT_GEN_BLOCK_TIME / common.UPDATE_RATE_PER_BLOCK
496 t := time.NewTicker(time.Second * (time.Duration(periodTime)))
497
498 for {
499 select {
500 case <-t.C:
501 this.ping()
502 this.timeout()
503 case <-this.quitHeartBeat:
504 t.Stop()
505 return
506 }
507 }
508}
509
510//ping send pkg to get pong msg from others
511func (this *P2PServer) ping() {

Callers 1

StartMethod · 0.95

Calls 3

pingMethod · 0.95
timeoutMethod · 0.95
StopMethod · 0.65

Tested by

no test coverage detected