Skip to content
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

Add support for removing Extended Provider #1745

Open
ischasny opened this issue May 16, 2023 · 0 comments
Open

Add support for removing Extended Provider #1745

ischasny opened this issue May 16, 2023 · 0 comments

Comments

@ischasny
Copy link
Collaborator

At the moment there is no way to remove extended providers, only add. We need to add such capability in the case if one would like to stop advertising an endpoint.

olizilla added a commit to storacha/ipni that referenced this issue May 17, 2023
#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]>
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

No branches or pull requests

1 participant