Skip to content

Commit a335d4b

Browse files
committed
RuntimeCache improvements
1 parent a953c01 commit a335d4b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

async_substrate_interface/types.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,28 @@ def retrieve(
7474
if block is not None:
7575
runtime = self.blocks.get(block)
7676
if runtime is not None:
77+
if block_hash is not None:
78+
# if lookup occurs for block_hash and block, but only block matches, also map to block_hash
79+
self.add_item(runtime, block_hash=block_hash)
7780
self.last_used = runtime
78-
# runtime.load_runtime()
79-
# if runtime.registry:
80-
# runtime.load_registry_type_map()
8181
return runtime
8282
if block_hash is not None:
8383
runtime = self.block_hashes.get(block_hash)
8484
if runtime is not None:
85+
if block is not None:
86+
# if lookup occurs for block_hash and block, but only block_hash matches, also map to block
87+
self.add_item(runtime, block=block)
8588
self.last_used = runtime
86-
# runtime.load_runtime()
87-
# if runtime.registry:
88-
# runtime.load_registry_type_map()
8989
return runtime
9090
if runtime_version is not None:
9191
runtime = self.versions.get(runtime_version)
9292
if runtime is not None:
93+
# if runtime_version matches, also map to block and block_hash (if supplied)
94+
if block is not None:
95+
self.add_item(runtime, block=block)
96+
if block_hash is not None:
97+
self.add_item(runtime, block_hash=block_hash)
9398
self.last_used = runtime
94-
# runtime.load_runtime()
95-
# if runtime.registry:
96-
# runtime.load_registry_type_map()
9799
return runtime
98100
return None
99101

0 commit comments

Comments
 (0)