make initial delay for direct peer connections a variable

This commit is contained in:
vyzo 2020-04-22 17:48:34 +03:00
parent 2eaa566371
commit ca7b1f3dbf

View File

@ -64,6 +64,9 @@ var (
// currently connected // currently connected
GossipSubDirectConnectTicks uint64 = 300 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 // Number of heartbeat ticks for attempting to improve the mesh with opportunistic
// grafting // grafting
GossipSubOpportunisticGraftTicks uint64 = 60 GossipSubOpportunisticGraftTicks uint64 = 60
@ -287,8 +290,9 @@ func (gs *GossipSubRouter) Attach(p *PubSub) {
// connect to direct peers // connect to direct peers
if len(gs.direct) > 0 { if len(gs.direct) > 0 {
go func() { go func() {
// add a small delay to make this unit-testable if GossipSubDirectConnectInitialDelay > 0 {
time.Sleep(time.Second) time.Sleep(GossipSubDirectConnectInitialDelay)
}
for p := range gs.direct { for p := range gs.direct {
gs.connect <- connectInfo{p: p} gs.connect <- connectInfo{p: p}
} }