mirror of https://github.com/status-im/go-waku.git
Iterate through Peerstore in startKeepAlive() (#102)
This commit is contained in:
parent
b63efd6561
commit
268767262b
|
@ -118,6 +118,7 @@ func New(ctx context.Context, opts ...WakuNodeOption) (*WakuNode, error) {
|
|||
|
||||
w.connectionNotif = NewConnectionNotifier(ctx, host)
|
||||
w.host.Network().Notify(w.connectionNotif)
|
||||
|
||||
go w.connectednessListener()
|
||||
|
||||
if w.opts.keepAliveInterval > time.Duration(0) {
|
||||
|
@ -540,7 +541,13 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
|
|||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
for _, p := range w.host.Network().Peers() {
|
||||
// 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() {
|
||||
go pingPeer(w.ctx, w.ping, p)
|
||||
}
|
||||
case <-w.quit:
|
||||
|
|
Loading…
Reference in New Issue