Skip to content

LW-12164 Feat/cache data from blockfrost locally #1569

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

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

AngelCastilloB
Copy link
Member

Context

We want to reduce the amount of request we make to blockfrost. Now ChainHistoryProvider and UtxoProvider use a local volatile cache to reuse when requesting the same data several times.

@@ -34,6 +34,7 @@ type BlockfrostTx = Pick<Responses['address_transactions_content'][0], 'block_he
const compareTx = (a: BlockfrostTx, b: BlockfrostTx) => a.block_height - b.block_height || a.tx_index - b.tx_index;

export class BlockfrostChainHistoryProvider extends BlockfrostProvider implements ChainHistoryProvider {
private readonly cache: Map<string, Cardano.HydratedTx> = new Map();
Copy link
Member

@mkazlauskas mkazlauskas Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if cache objects were injected (e.g. type Cache<K, V> = { get: (key: K) => Promise<T>, set: (key: K, value: V) => Promise<void> }), then it would be easier to update/swap it with a more sophisticated cache (lru, persistent etc.) and control it with FFs. Anyway happy to merge as-is to mitigate the current issue quickly.

@AngelCastilloB AngelCastilloB force-pushed the feat/cache-data-from-blockfrost-locally branch from 4dce93b to 8cb0dac Compare January 27, 2025 10:29
@rhyslbw rhyslbw removed the request for review from ginnun January 27, 2025 11:02
@AngelCastilloB AngelCastilloB merged commit fbc7429 into master Jan 27, 2025
5 of 6 checks passed
@AngelCastilloB AngelCastilloB deleted the feat/cache-data-from-blockfrost-locally branch January 27, 2025 11:12
@rhyslbw rhyslbw changed the title Feat/cache data from blockfrost locally LW-12164 Feat/cache data from blockfrost locally Jan 27, 2025
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