-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: filter origins & delegates #13
Conversation
only merge origins if mergeOrigins option is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with nits.
constructor (private readonly heliaInstance: Helia, private readonly remotePinningClient: RemotePinningServiceClient, config?: HeliaRemotePinnerConfig) { | ||
this.config = { | ||
mergeOrigins: config?.mergeOrigins ?? false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't these set as Required? does nullish check still apply?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah.. yes, I should remove from the Pick<Required
. good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, no, the this.config
is the only place it's required. the passed in options are all optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which means, in the constructor, we have to set the required options on this.config, but user doesn't need to pass anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed an issue though: f0bf463
src/heliaRemotePinner.ts
Outdated
const nodeOrigins = multiaddrs.map(multiaddr => multiaddr.toString()) | ||
const filteredOrigins = this.config.filterOrigins?.(nodeOrigins) ?? nodeOrigins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we call const nodeOrigins
something else? in fact since this assignment is only used in case this.config.filterOrigins?.(nodeOrigins) ??
why spend time converting all multiaddrs.toString()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because filterOrigins takes an array of strings.. though it should probably take an array of Multiaddrs
src/heliaRemotePinner.ts
Outdated
* | ||
* @default (origins) => origins | ||
*/ | ||
filterOrigins?: (origins: string[]) => string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering if there is a need support regexp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filtering multiaddrs with regex can be done in user provided function if they desire. full customization owned by fn caller
FYI: I have some additional updates here that i added while working on ipfs-examples/helia-examples#147 that I want to be sure are looked at, will update when i unblock ipfs-desktop and ipfs-webui issues |
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR adds more configuration options and no longer merges origins by default.
New configuration options:
boolean
(origins: string[]) => string[]
(delegates: string[]) => string[]
New functionality:
helia.libp2p.getMultiaddrs()
origins.