Skip to content

Cache Improvements#267

Merged
thewhaleking merged 7 commits intostagingfrom
feat/thewhaleking/runtime-cache-improvements-nog
Feb 12, 2026
Merged

Cache Improvements#267
thewhaleking merged 7 commits intostagingfrom
feat/thewhaleking/runtime-cache-improvements-nog

Conversation

@thewhaleking
Copy link
Collaborator

Adds a reverse dict of the RuntimeCache.blocks ({block_number: block_hash} mapping) to RuntimeCache.blocks_reverse which is a {block_hash: block_number} mapping, to make it simpler to interact with the new add_known_versions method.

Also optimises the caching of block hashes and numbers in both the sync and async versions for get_block_hash and get_block_number, where None is no longer cached (None implies get the chain tip, which is constantly changing), there's first a lookup to see if the reverse has happened (e.g. you got the block hash for block 5_000_002 and now you want to get the block number for that block's hash), and then finally passes it to the cached retrieval method, which then adds the mapping to the RuntimeCache for future updates.

Adds caching in general to the get_block_number async version, which was for some reason not cached.

…} reverse of RuntimeCache.blocks (which is {block: block_hash}
…sure that we do not cache when `None` is passed, and to attempt to retrieve the block hash or block from the cache if its previously been requested.
@thewhaleking thewhaleking marked this pull request as ready for review February 12, 2026 11:03
@thewhaleking thewhaleking added run-bittensor-sdk-tests Runs Bittensor SDK tests. run-bittensor-cli-tests Runs BTCLI tests. enhancement New feature or request labels Feb 12, 2026
@thewhaleking thewhaleking requested a review from a team February 12, 2026 11:06
@thewhaleking thewhaleking merged commit 9eab469 into staging Feb 12, 2026
100 of 102 checks passed
@thewhaleking thewhaleking deleted the feat/thewhaleking/runtime-cache-improvements-nog branch February 12, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request run-bittensor-cli-tests Runs BTCLI tests. run-bittensor-sdk-tests Runs Bittensor SDK tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants