Browse Source

doc: p2p-net.md clarify protocol and specify it more

x 3 years ago
parent
commit
c445c0f8eb
1 changed files with 13 additions and 7 deletions
  1. 13 7
      doc/src/architecture/p2p-network.md

+ 13 - 7
doc/src/architecture/p2p-network.md

@@ -26,17 +26,23 @@ The outbound session is responsible to ensure the hosts pool is populated, eithe
 through currently connected nodes or using the seed session.
 through currently connected nodes or using the seed session.
 It performs this algorithm:
 It performs this algorithm:
 
 
-1. Start $N$ slots, each set with `status = ACTIVE`
-2. If no addresses matching our filters are in the hosts pool then:
+1. Start $N$ slots, and set each slot with `status = ACTIVE`
+
+Then each slot performs this algorithm:
+
+1. If no addresses matching our filters are in the hosts pool then:
     1. Check the other slots are all `ACTIVE`, otherwise let `status = SLEEP` and
     1. Check the other slots are all `ACTIVE`, otherwise let `status = SLEEP` and
        wait for a wakeup signal.
        wait for a wakeup signal.
-    2. If we have connections available in `p2p` then let `status = DISCOVERY`
+    2. If we there are channels opened in `p2p` then let `status = DISCOVERY`
        otherwise let `status = SEED`.
        otherwise let `status = SEED`.
-    3. If `status ≟ DISCOVERY` and the hosts pool is still empty then
-       let `status = SEED`.
-    4. If the hosts pool is still empty, then let `status = SLEEP` and set a wakeup timer.
-    4. Once finished, send the wakeup signal to the other slots and repeat the process.
+    3. If `status ≟ DISCOVERY` and no hosts are found then let `status = SEED`.
+    5. 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
 The slots are able to communicate to each other through pipes to signal status changes
 such as wakeup requests.
 such as wakeup requests.
 
 
+Sleeping slots are woken up periodically by the session. They can be forcefully woken up
+by calling `session.wakeup()`.
+