From 8e969ba29edf8ffed7a97b9d47e9dc5bafdf2121 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 10 Apr 2020 13:54:14 +0300 Subject: [PATCH] use a configurable variable for direct peer reconnect ticks --- gossipsub.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gossipsub.go b/gossipsub.go index f686249..3e079e9 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -59,6 +59,10 @@ var ( // timeout for connection attempts GossipSubConnectionTimeout = 30 * time.Second + + // Number of heartbeat ticks for attempting to reconnect direct peers that are not + // currently connected + GossipSubDirectConnectTicks uint64 = 300 ) // NewGossipSub returns a new PubSub object using GossipSubRouter as the router. @@ -983,9 +987,9 @@ func (gs *GossipSubRouter) clearBackoff() { } func (gs *GossipSubRouter) directConnect() { - // we donly do this every 150 ticks to allow pending connections to complete and account + // we donly do this every some ticks to allow pending connections to complete and account // for restarts/downtime - if gs.heartbeatTicks%150 != 0 { + if gs.heartbeatTicks%GossipSubDirectConnectTicks != 0 { return }