Skip to content

Commit

Permalink
debugging storage.rs for jmt
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd committed Sep 11, 2024
1 parent 54316b8 commit 9ef3ea5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/common/src/hashchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Hashchain {
}

pub fn push(&mut self, operation: Operation) -> Result<Digest> {
if let Operation::CreateAccount { .. } = operation {
if !self.is_empty() {
bail!("Cannot CreateAccount on an already existing hashchain");
}
if operation.id() != self.id {
Expand Down
8 changes: 3 additions & 5 deletions crates/prism/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl TreeReader for RedisConnection {
fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>> {
let mut con = self.lock_connection()?;
let serialized_key = hex::encode(borsh::to_vec(node_key).unwrap());
let node_data: Option<Vec<u8>> = con.get(format!("node:{}", serialized_key))?;
let node_data: Option<Vec<u8>> = con.get(dbg!(format!("node:{}", serialized_key)))?;
match node_data {
None => Ok(None),
Some(data) => {
Expand Down Expand Up @@ -146,12 +146,11 @@ impl TreeWriter for RedisConnection {
fn write_node_batch(&self, node_batch: &NodeBatch) -> Result<()> {
let mut con = self.lock_connection()?;
let mut pipe = redis::pipe();

for (node_key, node) in node_batch.nodes() {
let serialized_key = hex::encode(borsh::to_vec(node_key).unwrap());
let node_data = borsh::to_vec(node)?;
pipe.set(format!("node:{:?}", node_key), node_data);
pipe.set(format!("node:{}", serialized_key), node_data);
}

for ((version, key_hash), value) in node_batch.values() {
if let Some(v) = value {
pipe.zadd(format!("value_history:{:?}", key_hash), v, *version as f64);
Expand All @@ -163,7 +162,6 @@ impl TreeWriter for RedisConnection {
);
}
}

pipe.execute(&mut con);
Ok(())
}
Expand Down

0 comments on commit 9ef3ea5

Please sign in to comment.