feature: add span and debugs to fetch_leaf (#683)

buddies-main-deployment
James Prestwich 3 years ago committed by GitHub
parent 84062f354d
commit 0f0cf57edb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      rust/agents/processor/src/prover_sync.rs

@ -14,7 +14,7 @@ use tokio::{
}, },
time::sleep, time::sleep,
}; };
use tracing::info; use tracing::{debug, info, instrument};
/// Struct to sync prover. /// Struct to sync prover.
#[derive(Debug)] #[derive(Debug)]
@ -108,17 +108,24 @@ impl ProverSync {
} }
// simple caching // simple caching
async fn fetch_leaf(&mut self, index: usize) -> Result<Option<H256>, ProverSyncError> { #[instrument(err)]
let leaf = self.retrieve_leaf(index); async fn fetch_leaf(&mut self, leaf_index: usize) -> Result<Option<H256>, ProverSyncError> {
let leaf = self.retrieve_leaf(leaf_index);
if leaf.is_some() { if leaf.is_some() {
debug!("Retrieved leaf from db.");
Ok(leaf) Ok(leaf)
} else { } else {
match self.home.leaf_by_tree_index(index).await? { debug!("Retrieving leaf from chain.");
match self.home.leaf_by_tree_index(leaf_index).await? {
Some(leaf) => { Some(leaf) => {
self.store_leaf(index, leaf); debug!("Retrieved leaf from chain.");
self.store_leaf(leaf_index, leaf);
Ok(Some(leaf)) Ok(Some(leaf))
} }
None => Ok(None), None => {
debug!("Chain does not contain leaf.");
Ok(None)
}
} }
} }
} }
@ -215,7 +222,7 @@ impl ProverSync {
info!("Local root is {}, goingt to root {}", local_root, new_root); info!("Local root is {}, goingt to root {}", local_root, new_root);
while local_root != new_root { while local_root != new_root {
info!("Polling Chain for leaf at index {}", tree_size); info!("Retrieving leaf at index {}", tree_size);
// As we fill the incremental merkle, its tree_size will always be // As we fill the incremental merkle, its tree_size will always be
// equal to the index of the next leaf we want (e.g. if tree_size // equal to the index of the next leaf we want (e.g. if tree_size

Loading…
Cancel
Save