From b490d117f2bf19456451913d7ff6e48ddc174635 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 10 Mar 2018 10:23:55 +0200 Subject: [PATCH] make heartbeat interval a parameter, turn all gossipsub parameters into variables --- gossipsub.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gossipsub.go b/gossipsub.go index 5ff4386..66d1734 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -14,7 +14,9 @@ import ( const ( GossipSubID = protocol.ID("/meshsub/1.0.0") +) +var ( // overlay parameters GossipSubD = 6 GossipSubDlo = 4 @@ -23,6 +25,9 @@ const ( // gossip parameters GossipSubHistoryLength = 5 GossipSubHistoryGossip = 3 + + // heartbeat interval + GossipSubHeartbeatInterval = 1 * time.Second ) func NewGossipSub(ctx context.Context, h host.Host, opts ...Option) (*PubSub, error) { @@ -306,7 +311,7 @@ func (gs *GossipSubRouter) sendRPC(p peer.ID, out *RPC) { } func (gs *GossipSubRouter) heartbeatTimer() { - ticker := time.NewTicker(1 * time.Second) + ticker := time.NewTicker(GossipSubHeartbeatInterval) defer ticker.Stop() for {