Skip to content

Commit

Permalink
Implement persisted indexed merkle trees (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmantica11 authored Jun 3, 2024
1 parent 38391a3 commit 9897362
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 208 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ test-ledger/
# Added by cargo

/target
/.cargo
11 changes: 3 additions & 8 deletions src/api/method/get_multiple_compressed_account_proofs.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

use crate::{
ingester::persist::persisted_state_tree::{
get_multiple_compressed_leaf_proofs, MerkleProofWithContext,
},
use crate::ingester::persist::persisted_state_tree::{
get_multiple_compressed_leaf_proofs, MerkleProofWithContext,
};

use sea_orm::{
DatabaseConnection,
};
use sea_orm::DatabaseConnection;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

Expand Down
7 changes: 4 additions & 3 deletions src/dao/generated/indexed_trees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use sea_orm::entity::prelude::*;
#[sea_orm(table_name = "indexed_trees")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub index: i64,
pub value: i64,
pub tree: Vec<u8>,
pub leaf_index: i64,
pub value: Vec<u8>,
pub next_index: i64,
pub next_value: i64,
pub next_value: Vec<u8>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
3 changes: 2 additions & 1 deletion src/ingester/persist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ pub async fn persist_state_update(
}
let StateUpdate {
in_accounts,
out_accounts,
mut out_accounts,
account_transactions,
transactions,
} = state_update;

out_accounts.sort_by(|a, b| a.seq.cmp(&b.seq));
debug!(
"Persisting state update with {} input accounts, {} output accounts",
in_accounts.len(),
Expand Down
Loading

0 comments on commit 9897362

Please sign in to comment.