8000 feat: use libp2p in @helia/http and move libp2p to the base helia class by 2color · Pull Request #822 · ipfs/helia · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: use libp2p in @helia/http and move libp2p to the base helia class #822

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 8 commits into from
Jun 23, 2025

Conversation

2color
Copy link
Member
@2color 2color commented Jun 20, 2025

What

  • This introduces a libp2p instance to @helia/http which is configured such that it only makes HTTP requests.
  • This removes the HeliaP2P class and moves the libp2p instance to the base Helia class which both Helia and @helia/http instantiate

Notes & open questions

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

so that both helia and @helia/http can share the same base class
with libp2p configured in a different fashion
@2color 2color requested a review from a team as a code owner June 20, 2025 13:33
@2color 2color requested a review from achingbrain June 20, 2025 13:33
@2color 2color merged commit 3349164 into add-republishing Jun 23, 2025
3 of 4 checks passed
@2color 2color deleted the helia-http-with-libp2p branch June 23, 2025 15:17
@achingbrain
Copy link
Member

Any reason not to target main with this PR? It would make #764 less noisy.

/**
* Options used to create a Helia node.
*/
export interface HeliaInit<T extends Libp2p = Libp2p> extends HeliaClassInit {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, it should re-export the HeliaInit type from @helia/utils to make it non-breaking.

keychain?: KeychainInit
}

export interface HeliaLibp2p<T extends Libp2p = Libp2p<DefaultLibp2pServices>> extends Helia {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, the type should be marked deprecated with a message saying it'll be removed in a future release instead.

@2color
Copy link
Member Author
2color commented Jun 26, 2025

Any reason not to target main with this PR? It would make #764 less noisy.Any reason not to target main with this PR? It would make #764 less noisy.

Yeah let's do that. I'll open another PR.

@@ -242,6 +271,7 @@ export class Helia implements HeliaInterface {
this.datastore,
this.routing
)
await this.libp2p.start()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.libp2p can be passed to start same as the blockstore/datastore/routing implementations.

@@ -250,6 +280,7 @@ export class Helia implements HeliaInterface {
this.datastore,
this.routing
)
await this.libp2p.stop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.libp2p can be passed to stop same as the blockstore/datastore/routing implementations.

*/
put(routingKey: Uint8Array, marshaledRecord: Uint8Array, metadata: IPNSMetadata, options?: PutOptions): Promise<void>
put(routingKey: Uint8Array, marshaledRecord: Uint8Array, metadata?: IPNSPublishMetadata, options?: PutOptions): Promise<void>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is optional, move it into the options object for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
< 42DE /div> None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0