Bitswap strategy implementation

Hi there!

I’ve been digging a bit in Bitswap lately and here is my understanding of the current implementation (https://github.com/ipfs/go-bitswap), focusing on the wantList messages:

  • Nodes exchange bitswap messages containing a list of wanted blocks
  • When bitswap receives a message, the engine:
  • updates the peer’s ledger with the wanted blocks (if any)
  • removes cancelled blocks from the PeerRequestQueue (PRQ)
  • pushes wanted blocks that are in the blockStore to the PRQ
  • if the message contains blocks, updates the peer’s ledger (data received)
  • The push method of the PRQ (PeerRequestQueue ordered with partnerCompare)
  • finds or creates partner (and pushes him to the priority queue)
  • updates priority of the task (and the order of the PRQ) and exits if a task already exists for this block
  • else creates a task and pushes it to the partner’s taskQueue (and updates the order of the PRQ)
  • The engine’s taskWorker
  • pulls tasks from the PRQ, puts them in envelope to be consumed and processed

My question is:
If one were to implement a strategy (like the sigmoid from the IPFS paper) he would have to do it with partnerCompare right?

But in the specs they talk about a RoundRobinQueue, and research-bitswap gives an implementation with this Round Robin Queue and the strategies. Can someone explain why it’s not used in the current implementation? Is it just a matter of testing to do, or is there something else?

I’ve also found reference of a Bitswap contest in the meeting-notes, any idea how far we are from that? Could this test-suit be used? And this tool: iptest?

Thanks for any insight!

1 Like