heartBeat send ping to nbr peers and check the timeout
()
| 491 | |
| 492 | //heartBeat send ping to nbr peers and check the timeout |
| 493 | func (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 |
| 511 | func (this *P2PServer) ping() { |