Fast and robust atproto CAR file processing in rust
15
fork

Configure Feed

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

little faster?

authored by

phil and committed by tangled.org b190325c 51b55775

+10 -4
+10 -4
src/drive.rs
··· 10 10 use iroh_car::CarReader; 11 11 use std::convert::Infallible; 12 12 use tokio::{io::AsyncRead, sync::mpsc}; 13 + use sha2::{Digest, Sha256}; 13 14 14 15 use crate::mst::Commit; 15 16 use crate::walk::{WalkError, Walker}; ··· 304 305 } 305 306 306 307 fn verify_block(given: Cid, block: &[u8]) -> bool { 307 - use multihash_codetable::{Code, MultihashDigest}; 308 - const RAW: u64 = 0x71; 309 - let calculated = cid::Cid::new_v1(RAW, Code::Sha2_256.digest(block)); 310 - calculated == given 308 + // we know we're in atproto, so we can make a few assumptions 309 + if given.version() != cid::Version::V1 { 310 + return false; 311 + } 312 + let (codec, given_digest, _) = given.hash().into_inner(); 313 + if codec != 0x12 { 314 + return false; 315 + } 316 + given_digest[..32] == *Sha256::digest(block) 311 317 } 312 318 313 319 impl<R: AsyncRead + Unpin> NeedDisk<R> {