Bitswap
Last updated
Last updated
Debt ratio r.
Probability of sending to a debtor.
Function drops off quickly as the nodes’ debt ratio surpasses twice the established credit.
BitSwap nodes keep ledgers accounting for the transfers with other nodes.
When activating a connection, BitSwap nodes exchange their ledger information. If it does not match exactly, the ledger is reinitialized from scratch, losing the accrued credit or debt.
Sketch of the lifetime of a peer connection:
Open: peers send ledgers until they agree.
Sending: peers exchange want_lists and blocks.
Close: peers deactivate a connection.
Ignored: (special) a peer is ignored (for the duration of a timeout) if a node’s strategy avoids sending.
In IFPS, every file or directory has a CID.
A unique SHA256 hash is used to identify the file.
Whenever the content changes, the CID also changes.
To keep track of files after being altered, IPFS uses the InterPlanetary Name System (IPNS) where the name is the hash of a public key, stored in the DHT, pointing to the CID of the latest version.
When a peer wants a block, it broadcasts a Want to all connected peers.
If there is no response, it asks the DHT who has the root CID. Peers who respond are added to the session and subsequent requests are sent only to peers in the session.