helia icon indicating copy to clipboard operation
helia copied to clipboard

feat: pass initial providers to session

Open achingbrain opened this issue 8 months ago • 1 comments

For when you know that certain peers have some or all of the blocks you want, allow passing providers to session implementations to start from instead of always querying the routing/connected peers.

const buf = await helia.blockstore.get(cid, {
  providers: [
    peerId1,
    peerId2
  ]
})

Session implementations accept an array of PeerId | Multiaddr | Multiaddr[] and use them if they can or discard them if they can't.

Change checklist

  • [x] I have performed a self-review of my own code
  • [x] I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • [x] I have added tests that prove my fix is effective or that my feature works

achingbrain avatar Apr 17 '25 12:04 achingbrain

note that this is related to https://discuss.ipfs.tech/t/helia-not-using-bitswap-even-though-dialed-to-nodes/19234/10 even though it may no longer be needed, it should prove useful for some situations.

SgtPooki avatar Apr 17 '25 13:04 SgtPooki