-
Notifications
You must be signed in to change notification settings - Fork 44
Implement resilient IPFS fetcher #2336
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
base: develop
Are you sure you want to change the base?
Conversation
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.
this file should be deleted right? content is the same as in new ipfsGatewayUrlsGet/ts.
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.
same, should be deleted if ipfsGatewayUrlsSet.ts is enough
| export async function ipfsGatewayUrlsSet({ ipfsGatewayUrls }: { ipfsGatewayUrls: string[] }): Promise<void> { | ||
| if (!ipfsGatewayUrls || ipfsGatewayUrls.length === 0) { | ||
| throw Error(`At least one gateway URL must be provided`); | ||
| } | ||
|
|
||
| await changeIpfsGatewayUrls(ipfsGatewayUrls); | ||
|
|
||
| // Emit event to trigger notifier healthcheck notification | ||
| eventBus.ipfsRepositoryChanged.emit(); | ||
| } | ||
|
|
||
| /** | ||
| * Changes IPFS gateway URLs used for package fetching | ||
| * @param nextGatewayUrls Gateway endpoints to be used | ||
| */ | ||
| async function changeIpfsGatewayUrls(nextGatewayUrls: string[]): Promise<void> { | ||
| try { | ||
| // Return if gateway URLs are equal | ||
| const currentGatewayUrls = db.ipfsGatewayUrls.get(); | ||
| if (JSON.stringify(currentGatewayUrls) === JSON.stringify(nextGatewayUrls)) { | ||
| return; | ||
| } | ||
|
|
||
| // Set new values in db | ||
| const gatewayUrls = nextGatewayUrls.length > 0 ? nextGatewayUrls : params.IPFS_REMOTE_URLS; | ||
| db.ipfsGatewayUrls.set(gatewayUrls); | ||
|
|
||
| // Change IPFS gateway URLs in the installer | ||
| dappnodeInstaller.changeIpfsGatewayUrls(db.ipfsGatewayUrls.get()); | ||
| } catch (e) { | ||
| throw Error(`Error changing IPFS gateway URLs, ${e}`); | ||
| } | ||
| } |
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.
seems like changeIpfsGatewayUrls() and ipfsGatewayUrlsSet() are overlapping, they do the same or have too similar names
Context
This pull request introduces a new mechanism for fetching content from IPFS using multiple gateway URLs, enhancing resilience and reliability in content retrieval.
Approach
The solution involves modifying the IPFS repository structure to support an array of gateway URLs, implementing functions to set and get these URLs, and updating the metrics to reflect the number of configured gateways.
Test instructions
ipfsGatewayUrlsSetfunction.ipfsGatewayUrlsGetfunction.