control parameter for gossipsub initial heartbeat delay

This commit is contained in:
vyzo 2018-08-29 11:15:41 +03:00
parent 35c945373f
commit 0cd357b295
1 changed files with 9 additions and 1 deletions

View File

@ -27,7 +27,8 @@ var (
GossipSubHistoryGossip = 3
// heartbeat interval
GossipSubHeartbeatInterval = 1 * time.Second
GossipSubHeartbeatInitialDelay = 100 * time.Millisecond
GossipSubHeartbeatInterval = 1 * time.Second
// fanout ttl
GossipSubFanoutTTL = 60 * time.Second
@ -349,6 +350,13 @@ func (gs *GossipSubRouter) sendRPC(p peer.ID, out *RPC) {
}
func (gs *GossipSubRouter) heartbeatTimer() {
time.Sleep(GossipSubHeartbeatInitialDelay)
select {
case gs.p.eval <- gs.heartbeat:
case <-gs.p.ctx.Done():
return
}
ticker := time.NewTicker(GossipSubHeartbeatInterval)
defer ticker.Stop()