dariusc93 / rust-ipfs

The InterPlanetary File System (IPFS), implemented in Rust.
Apache License 2.0
36 stars 7 forks source link

bitswap: Bundle multiple requests/blocks into a single message #210

Open dariusc93 opened 1 month ago

dariusc93 commented 1 month ago

In the internal implementation of bitswap, wants and haves were split into their own respective sessions on purpose to allow handling each request on its own, putting peers into those sessions based on any requests made for said blocks, however this would result in multiple messages being sent when multiple blocks are requested. We could optimize this by bundling the multiple requests into a single message, assuming we can stay below the max message size (which is 2MB). If a message does begin to reach that limit, we could split it up into multiple messages if needed.