doc/book: update outdated peer discovery algo desc

This commit is contained in:
x
2023-10-19 11:23:15 +02:00
parent 5e14347fe7
commit 1d22ee44a0

View File

@@ -26,25 +26,15 @@ The outbound session is responsible to ensure the hosts pool is populated, eithe
through currently connected nodes or using the seed session.
It performs this algorithm:
1. Start $N$ slots, and set each slot with `status = ACTIVE`
1. Start $N$ slots, and a sleeping peer discovery process
Then each slot performs this algorithm:
1. If no addresses matching our filters are in the hosts pool then:
1. If there is another slot where `status ≟ DISCOVERY` or `status ≟ SEED` then
let `status = SLEEP` and wait for a wakeup signal.
2. If there are channels opened in `p2p` then let `status = DISCOVERY`
else skip this step, and let `status = SEED`.
1. If `status ≟ DISCOVERY` and no hosts are found then let `status = SEED`.
3. In either case when `status ≟ DISCOVERY` or `status = SEED` and we manage to find
new hosts, then wakeup the other sleeping slots.
4. If there are still no hosts found, then let `status = SLEEP`.
The slots are able to communicate to each other through pipes to signal status changes
such as wakeup requests.
Sleeping slots are woken up periodically by the session. They can be forcefully woken up
by calling `session.wakeup()`.
1. Wakeup the peer discovery process. This does nothing if peer discovery is already active.
2. Peer discovery tries first 2 times to poll the current network if there are connected nodes,
otherwise it will do a seed server sync.
3. Peer discovery then wakes any sleeping slots and goes back to sleep.
## Security