Merge pull request #102 from libp2p/fix/issue-101

Add control parameter for gossipsub initial heartbeat delay
This commit is contained in:
Steven Allen 2018-08-29 23:37:29 +00:00 committed by GitHub
commit 30dee56ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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()