From b12ae08e3b14f9b943d729713b034ae503491430 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 11 Jul 2023 15:14:25 -0400 Subject: [PATCH] shift optimization to `DataStore.get_keys_values_dict()` --- chia/data_layer/data_store.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/chia/data_layer/data_store.py b/chia/data_layer/data_store.py index 71d22c91d24c..0107c910c2a8 100644 --- a/chia/data_layer/data_store.py +++ b/chia/data_layer/data_store.py @@ -762,6 +762,9 @@ class DataStore: ) async def get_keys_values_dict(self, tree_id: bytes32, root_hash: Optional[bytes32] = None) -> Dict[bytes, bytes]: + if root_hash is None: + return {} + pairs = await self.get_keys_values(tree_id=tree_id, root_hash=root_hash) return {node.key: node.value for node in pairs} @@ -1015,11 +1018,7 @@ class DataStore: ) -> Optional[bytes32]: async with self.db_wrapper.writer(): old_root = await self.get_tree_root(tree_id) - root_hash = old_root.node_hash - if old_root.node_hash is None: - hint_keys_values = {} - else: - hint_keys_values = await self.get_keys_values_dict(tree_id, root_hash=root_hash) + hint_keys_values = await self.get_keys_values_dict(tree_id, root_hash=old_root.node_hash) iter_root: Optional[Root] = old_root for change in changelist: