Skip to content

Commit

Permalink
chore: Add tracing to update_have_cids
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Jan 1, 2024
1 parent 190e6a9 commit 7310ed2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion car-mirror/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ impl Default for Config {
}
}

#[cfg(fuckoff)]
#[cfg(test)]
mod tests {
use super::*;
Expand Down
9 changes: 8 additions & 1 deletion car-mirror/src/incremental_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl IncrementalDagVerification {
Ok(this)
}

#[instrument(level = "trace", skip_all, fields(num_want = self.want_cids.len(), num_have = self.have_cids.len()))]
#[instrument(level = "trace", skip_all)]
async fn update_have_cids(
&mut self,
store: &impl BlockStore,
Expand All @@ -68,6 +68,7 @@ impl IncrementalDagVerification {
if let Some(BlockStoreError::CIDNotFound(not_found)) =
e.downcast_ref::<BlockStoreError>()
{
tracing::trace!(%not_found, "Missing block, adding to want list");
self.want_cids.insert(*not_found);
} else {
return Err(Error::BlockStoreError(e));
Expand All @@ -84,6 +85,12 @@ impl IncrementalDagVerification {
}
}

tracing::debug!(
num_want = self.want_cids.len(),
num_have = self.have_cids.len(),
"Finished dag verification"
);

Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions car-mirror/src/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ mod tests {
use futures::TryStreamExt;
use libipld::Cid;
use std::collections::HashSet;
use wnfs_common::MemoryBlockStore;
use wnfs_common::{BlockStore, MemoryBlockStore};

pub(crate) async fn simulate_protocol(
root: Cid,
config: &Config,
client_store: &MemoryBlockStore,
server_store: &MemoryBlockStore,
client_store: &impl BlockStore,
server_store: &impl BlockStore,
) -> Result<Vec<Metrics>> {
let mut metrics = Vec::new();
let mut request = crate::pull::request(root, None, config, client_store, &NoCache).await?;
Expand Down
6 changes: 3 additions & 3 deletions car-mirror/src/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ mod tests {
use libipld::Cid;
use proptest::collection::vec;
use std::collections::HashSet;
use wnfs_common::MemoryBlockStore;
use wnfs_common::{BlockStore, MemoryBlockStore};

pub(crate) async fn simulate_protocol(
root: Cid,
config: &Config,
client_store: &MemoryBlockStore,
server_store: &MemoryBlockStore,
client_store: &impl BlockStore,
server_store: &impl BlockStore,
) -> Result<Vec<Metrics>> {
let mut metrics = Vec::new();
let mut request = crate::push::request(root, None, config, client_store, &NoCache).await?;
Expand Down
4 changes: 2 additions & 2 deletions car-mirror/src/test_utils/local_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Result;
use futures::TryStreamExt;
use libipld::{Cid, Ipld};
use proptest::strategy::Strategy;
use wnfs_common::{BlockStore, MemoryBlockStore};
use wnfs_common::{utils::CondSync, BlockStore, MemoryBlockStore};

#[derive(Clone, Debug)]
pub(crate) struct Metrics {
Expand Down Expand Up @@ -92,4 +92,4 @@ pub(crate) async fn total_dag_blocks(root: Cid, store: &impl BlockStore) -> Resu
.len())
}

pub(crate) fn assert_send_sync<T: Send + Sync>(fut: fn() -> T) {}
pub(crate) fn assert_cond_send_sync<T: CondSync>(fut: fn() -> T) {}

0 comments on commit 7310ed2

Please sign in to comment.