fix: iterate through Network peers during ping process (#182)

This commit is contained in:
Vitaliy Vlasov 2022-06-01 23:11:35 +03:00 committed by GitHub
parent 80385bf78e
commit ca595277e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 7 deletions

View File

@ -26,13 +26,9 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
for {
select {
case <-ticker.C:
// Compared to Network's peers collection,
// Peerstore contains all peers ever connected to,
// thus if a host goes down and back again,
// pinging a peer will trigger identification process,
// which is not possible when iterating
// through Network's peer collection, as it will be empty
for _, p := range w.host.Peerstore().Peers() {
// Network's peers collection,
// contains only currently active peers
for _, p := range w.host.Network().Peers() {
if p != w.host.ID() {
w.wg.Add(1)
go w.pingPeer(p)