From ca7b1f3dbf0a8082f924b248b9ab2a947ee26a22 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 22 Apr 2020 17:48:34 +0300 Subject: [PATCH] make initial delay for direct peer connections a variable --- gossipsub.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gossipsub.go b/gossipsub.go index 0140767..e2db462 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -64,6 +64,9 @@ var ( // currently connected GossipSubDirectConnectTicks uint64 = 300 + // Initial delay before opening connections to direct peers + GossipSubDirectConnectInitialDelay = time.Second + // Number of heartbeat ticks for attempting to improve the mesh with opportunistic // grafting GossipSubOpportunisticGraftTicks uint64 = 60 @@ -287,8 +290,9 @@ func (gs *GossipSubRouter) Attach(p *PubSub) { // connect to direct peers if len(gs.direct) > 0 { go func() { - // add a small delay to make this unit-testable - time.Sleep(time.Second) + if GossipSubDirectConnectInitialDelay > 0 { + time.Sleep(GossipSubDirectConnectInitialDelay) + } for p := range gs.direct { gs.connect <- connectInfo{p: p} }