Skip to content
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

Fix really large clone #752

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/identity_tree/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ impl TreeInitializer {

mined_items.sort_by_key(|item| item.leaf_index);

let mined_items = dedup_tree_updates(mined_items);

if !self.config.force_cache_purge {
info!("Attempting to restore tree from cache");
if let Some(tree_state) = self
.get_cached_tree_state(mined_items.clone(), initial_root_hash)
.get_cached_tree_state(&mined_items, initial_root_hash)
.await?
{
info!("tree restored from cache");
Expand Down Expand Up @@ -150,16 +152,14 @@ impl TreeInitializer {

async fn get_cached_tree_state(
&self,
mined_items: Vec<TreeUpdate>,
mined_items: &[TreeUpdate],
initial_root_hash: Hash,
) -> anyhow::Result<Option<TreeState>> {
let mined_items = dedup_tree_updates(mined_items);

let mut last_mined_index_in_dense: Option<usize> = None;
let leftover_items = Self::get_leftover_leaves_and_update_index(
&mut last_mined_index_in_dense,
self.config.dense_tree_prefix_depth,
&mined_items,
mined_items,
);

let Some(mined_builder) = CanonicalTreeBuilder::restore(
Expand Down Expand Up @@ -227,10 +227,6 @@ impl TreeInitializer {

#[instrument(skip_all)]
async fn initialize_tree(&self, mined_items: Vec<TreeUpdate>) -> anyhow::Result<TreeState> {
// Flatten the updates for initial leaves
info!("Deduplicating mined items");

let mined_items = dedup_tree_updates(mined_items);
let initial_leaf_value = self.identity_manager.initial_leaf_value();

let initial_leaves = if mined_items.is_empty() {
Expand Down
Loading