tangled
alpha
login
or
join now
microcosm.blue
/
repo-stream
14
fork
atom
Fast and robust atproto CAR file processing in rust
14
fork
atom
overview
issues
pulls
1
pipelines
little faster?
bad-example.com
1 month ago
d2e96dfb
40f93b80
+10
-4
1 changed file
expand all
collapse all
unified
split
src
drive.rs
+10
-4
src/drive.rs
reviewed
···
10
10
use iroh_car::CarReader;
11
11
use std::convert::Infallible;
12
12
use tokio::{io::AsyncRead, sync::mpsc};
13
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
307
-
use multihash_codetable::{Code, MultihashDigest};
308
308
-
const RAW: u64 = 0x71;
309
309
-
let calculated = cid::Cid::new_v1(RAW, Code::Sha2_256.digest(block));
310
310
-
calculated == given
308
308
+
// we know we're in atproto, so we can make a few assumptions
309
309
+
if given.version() != cid::Version::V1 {
310
310
+
return false;
311
311
+
}
312
312
+
let (codec, given_digest, _) = given.hash().into_inner();
313
313
+
if codec != 0x12 {
314
314
+
return false;
315
315
+
}
316
316
+
given_digest[..32] == *Sha256::digest(block)
311
317
}
312
318
313
319
impl<R: AsyncRead + Unpin> NeedDisk<R> {