waku-org / js-waku

JavaScript implementation of Waku v2

Home Page:https://js.waku.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: peer management for protocols (with disconnection management)

danisharora099 opened this issue · comments

This is a feature request

Problem

For Filter and LightPush, every time a new LP request/new subscription is created, getPeers() is called -- this is called every time which gives us a new set of peers to use for each request/subscription.

Further, we wish to discard a peer if it fails, and renew it with another peer. This is not trivial to do if we rely on getting a new set of peers each time.

Proposed Solutions

  • Maintain a list of peers for Filter and LightPush that are updated, instead of relying on getPeers for each request: #2003

LightPush:

  • Renew a peer if fails to send a message: #2003

Filter:

  • Use peer management: #2047
  • Renew peer if filter ping fails on a node: #2052
  • Check if messages are missing from one node but not another, replace a peer that is missing to deliver messages;

Notes

Renew peer if filter ping fails on a node
Not sure if we can depend on this as expected filter ping duration is 1 minute.
Maybe better to listen on disconnection signal from a peer and then act on it, which can be based on periodic ping that is run more often. In go-waku/status-go all connected peers are pinged every 10 seconds.