-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: createExtendedProviderAd helper to guide extended provider usage (
#8) the expected way to use extended providers is with a special advert that doesn't include a context or entries, so a helper is provider to help guide usage. The Advertisement constructor lets you do anything that's legal but requires you to pass null for the special case of a ad with no context id, entries or previous cid. While the helper lets you skip those nulls as you've clearly opt'd in to the extendedProvider world. ```js /** * Advertise that **all** past and future entries in this chain are now * available from a new, additional provider by specifying the root provider * and the additional providers along with no context id and no entries cid. * * To advertise that subset of entries are available from additional providers * specify the relevant context id to identify that group. * * Note: it is not yet possible to unannounce an extended provider once announced. * see: ipni/storetheindex#1745 * * @param {object} config * @param {Provider[]} config.providers * @param {Link | null} config.previous * @param {Bytes | null} [config.context] */ export function createExtendedProviderAd ({ previous, providers, context = null }) { if (!providers || !Array.isArray(providers) || providers.length < 2) { throw new Error('at least 2 providers are required, the root provider and the new extended provider') } return new Advertisement({ previous, providers, entries: null, context }) } ``` Adds and reworks some missing validation checks and typos. License: MIT --------- Signed-off-by: Oli Evans <[email protected]>
- Loading branch information
Showing
6 changed files
with
180 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { Provider } from './provider.js' | ||
export { Advertisement } from './advertisement.js' | ||
export { Advertisement, createExtendedProviderAd } from './advertisement.js' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.