Used to acquire and send blocks to peers in IPFS. It’s slow.

Nodes running bitswap send out their wantlists. Peer nodes keep track of the wants their peers have and sends it if they have it.

Discovery

User asks for the root node of the DAG of blocks they want.

sequenceDiagram
    PeerA ->> PeerB : want-have CID1?
    PeerA ->> PeerC : want-have CID1?
    PeerA ->> PeerD : want-have CID1?
    PeerB ->> PeerA : HAVE CID1
    PeerA ->> PeerB : want-block CID1
    PeerC ->> PeerA : HAVE CID1
    PeerD ->> PeerA : HAVE CID1
    PeerB ->> PeerA : Block (CID1)

Transfer

If none of the peers have the root block, bitswap queries the DHT.