Skip to content

feat: pass initial providers to session #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025

Conversation

achingbrain
Copy link
Member

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

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

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

```js
const buf = await helia.blocks.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.
@SgtPooki
Copy link
Member

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.

@achingbrain achingbrain marked this pull request as ready for review April 23, 2025 11:42
@achingbrain achingbrain requested a review from a team as a code owner April 23, 2025 11:42
@achingbrain achingbrain merged commit 3d77369 into main May 13, 2025
18 checks passed
@achingbrain achingbrain deleted the feat/pass-initial-providers-to-session branch May 13, 2025 07:34
@achingbrain achingbrain mentioned this pull request May 9, 2025
2color added a commit that referenced this pull request Jun 18, 2025
* origin/main: (27 commits)
  fix: flaky test to publish an IPNS record  (#810)
  docs: fix API docs link (#809)
  fix: trustless gateway returned blocks can be limited (#791)
  deps: bump kubo from 0.34.1 to 0.35.0 in the kubo-deps group (#806)
  chore: fix linting
  chore: release main (#805)
  chore: bump execa from 8.0.1 to 9.5.3 (#797)
  chore: bump @helia/unixfs from 4.0.3 to 5.0.2 in /benchmarks/add-dir (#796)
  chore: bump codecov/codecov-action from 5.4.0 to 5.4.3 (#802)
  chore: bump tinybench from 3.1.1 to 4.0.1 (#798)
  deps: update aegir to 47.x.x (#804)
  chore: dep groups again
  chore: restore groups
  chore: remove groups
  chore: release main (#793)
  deps: update all deps (#792)
  chore: release main (#774)
  feat: pass initial providers to session (#777)
  ci: uci/copy-templates (#782)
  fix: propagate ipns failures (#789)
  ...
@SgtPooki SgtPooki mentioned this pull request Jul 24, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants