File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* DEV DOCS
2
+ Every hypercore has one Replicator object managing its connections to other peers.
3
+ There is one Peer object per peer connected to the Hypercore.
4
+ Hypercores do not know about other hypercores, so when a peer is connected to multiple cores, there exists one Peer object per core.
5
+
6
+ Hypercore indicates block should be downloaded through methods like Replicator.addRange or Replicator.addBlock
7
+ Hypercore calls Replicator.updateActivity every time a hypercore session opens/closes
8
+ Replicator.updateActivity ensures the Hypercore is downloading blocks as expected
9
+ Replicator keeps track of:
10
+ - Which blocks need to be downloaded (Replicator._blocks)
11
+ - Which blocks currently have inflight requests (Replicator._inflight)
12
+
13
+ Blocks are requested from remote peers by Peer objects. The flow is:
14
+ - The replicator's updatePeer method gets called
15
+ - The replicator detects whether the Peer can accept more requests (for example by checking if it's maxed out on inflight blocks)
16
+ - The replicator then tells the Peer what to request (e.g. Peer_requestRange or Peer._requestBlock methods)
17
+
18
+ The Peer object is responsible for tracking
19
+ - Which blocks does the Peer have available (tracked in remoteBitfield)
20
+ - Which blocks are you actively looking for from this peer (tracked in missingBlocks)
21
+ - How many blocks are currently inflight (tracked in inflight)
22
+ The Peer uses this information to decide which blocks to request form the peer in response to _requestRange requests and the like.
23
+ */
24
+
1
25
const b4a = require ( 'b4a' )
2
26
const safetyCatch = require ( 'safety-catch' )
3
27
const RandomIterator = require ( 'random-array-iterator' )
You can’t perform that action at this time.
0 commit comments