Skip to content

Conversation

@pablomendezroyo
Copy link
Contributor

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

  1. Set multiple IPFS gateway URLs using the ipfsGatewayUrlsSet function.
  2. Retrieve the configured URLs with the ipfsGatewayUrlsGet function.
  3. Verify that the content fetching mechanism utilizes the configured gateway URLs.
  4. Check the metrics to ensure the count of configured gateways is accurate.

@pablomendezroyo pablomendezroyo requested a review from a team as a code owner January 2, 2026 09:33
@github-actions github-actions bot temporarily deployed to commit January 2, 2026 09:34 Inactive
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

@github-actions github-actions bot temporarily deployed to commit January 2, 2026 09:44 Inactive
@pablomendezroyo pablomendezroyo marked this pull request as draft January 2, 2026 09:53
Copy link
Contributor

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.

Copy link
Contributor

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

Comment on lines +9 to +41
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}`);
}
}
Copy link
Contributor

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

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

Successfully merging this pull request may close these issues.

3 participants