From 148a4526804f280aecae98b57d852bfa78366a9e Mon Sep 17 00:00:00 2001 From: Piotr Heilman Date: Tue, 12 Nov 2024 11:52:15 +0100 Subject: [PATCH] Fix restoring tree from cache with mined status back. --- src/identity_tree/initializer.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/identity_tree/initializer.rs b/src/identity_tree/initializer.rs index 9835e386..b33dfd09 100644 --- a/src/identity_tree/initializer.rs +++ b/src/identity_tree/initializer.rs @@ -165,11 +165,11 @@ impl TreeInitializer { return Ok(None); }; - let (mined, processed_builder) = mined_builder.seal(); + let (mined, mut processed_builder) = mined_builder.seal(); match self .database - .get_latest_root_by_status(ProcessedStatus::Processed) + .get_latest_root_by_status(ProcessedStatus::Mined) .await? { Some(root) => { @@ -184,6 +184,15 @@ impl TreeInitializer { } } + let processed_items = self + .database + .get_commitments_by_status(ProcessedStatus::Processed) + .await?; + + for processed_item in processed_items { + processed_builder.update(&processed_item); + } + let (processed, batching_builder) = processed_builder.seal_and_continue(); let (batching, mut latest_builder) = batching_builder.seal_and_continue();