Fast and robust atproto CAR file processing in rust
14
fork

Configure Feed

Select the types of activity you want to include in your feed.

fmt

authored by

phil and committed by tangled.org cac412cb a369e23a

+11 -6
+10 -4
benches/cid-check.rs
··· 1 + use cid::Cid; 1 2 use criterion::{Criterion, criterion_group, criterion_main}; 2 3 use multihash_codetable::{Code, MultihashDigest}; 3 - use cid::Cid; 4 4 use sha2::{Digest, Sha256}; 5 5 6 6 fn multihash_verify(given: Cid, block: &[u8]) -> bool { ··· 30 30 let cid = Cid::new_v1(0x71, Code::Sha2_256.digest(&some_bytes)); 31 31 32 32 let mut g = c.benchmark_group("CID check"); 33 - g.bench_function("multihash", |b| b.iter(|| multihash_verify(cid, &some_bytes))); 34 - g.bench_function("effortful", |b| b.iter(|| effortful_verify(cid, &some_bytes))); 35 - g.bench_function("fastloose", |b| b.iter(|| fastloose_verify(cid, &some_bytes))); 33 + g.bench_function("multihash", |b| { 34 + b.iter(|| multihash_verify(cid, &some_bytes)) 35 + }); 36 + g.bench_function("effortful", |b| { 37 + b.iter(|| effortful_verify(cid, &some_bytes)) 38 + }); 39 + g.bench_function("fastloose", |b| { 40 + b.iter(|| fastloose_verify(cid, &some_bytes)) 41 + }); 36 42 } 37 43 38 44 criterion_group!(benches, criterion_benchmark);
+1 -2
src/drive.rs
··· 1 1 //! Consume a CAR from an AsyncRead, producing an ordered stream of records 2 2 3 - use multihash_codetable::{MultihashDigest, Code}; 4 3 use crate::{ 5 4 Bytes, HashMap, 6 5 disk::{DiskError, DiskStore}, ··· 9 8 }; 10 9 use cid::Cid; 11 10 use iroh_car::CarReader; 11 + use multihash_codetable::{Code, MultihashDigest}; 12 12 use std::convert::Infallible; 13 13 use tokio::{io::AsyncRead, sync::mpsc}; 14 14 ··· 205 205 // try to load all the blocks into memory 206 206 let mut mem_size = 0; 207 207 while let Some((cid, data)) = car.next_block().await? { 208 - 209 208 // lkasdjflkajdsflkajsfdlkjasdf 210 209 if !verify_block(cid, &data) { 211 210 return Err(DriveError::BadCID);