The current discovery mechanism I implemented is not pretty, and should be improved:
It's a complicated background process that we should test in smaller pieces.
The peer-count is polled and adjusts ticker speeds to adapt behavior. Instead we should use a notifier, and attach it to the p2p host, to track peer-count changes without polling.
The discovery package only provides an iterator, which doesn't block. If we want to pull random nodes from the DHT, and filter them, we have to carefully pace the iteration or risk a busy loop.
Update the scoring based on (re)discovery of the peer: peers that make themselves discoverable should get a small peer score reward. There's an open issue on Linear about peer scoring, which includes using the connection manager tag system: we need to configure a decay of the score to de-prioritize poor peer connections. Or maybe we adapt the global peerscore instead.
We can make more parameters configurable
See #439 for initial peer discovery implementation.
The current discovery mechanism I implemented is not pretty, and should be improved:
See #439 for initial peer discovery implementation.