status-go/_assets/patches/geth/0031-fix-discovery-loop-when-no-seeds.patch
Adam Babik b5f05b1ab5
Fix flaky TestSingleTopicDiscoveryWithFailover and others (#992)
Other changes:
* needed to patch that loop implementation in Discover V5 implementation in go-ethereum,
* fixed TestStatusNodeReconnectStaticPeers,
* fixed TestBackendAccountsConcurrently.
2018-05-26 09:37:13 +02:00

25 lines
557 B
Diff

diff --git a/p2p/discv5/net.go b/p2p/discv5/net.go
index d0eae28f..25e75d50 100644
--- a/p2p/discv5/net.go
+++ b/p2p/discv5/net.go
@@ -641,7 +641,18 @@ loop:
}()
} else {
refreshDone = make(chan struct{})
- net.refresh(refreshDone)
+
+ done := make(chan struct{})
+ net.refresh(done)
+ <-done
+
+ // Refresh again only if there are no seeds.
+ // Also, sleep for some time to prevent from
+ // executing too often.
+ go func() {
+ time.Sleep(time.Millisecond * 100)
+ close(refreshDone)
+ }()
}
}
}