MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / missing_blocks

Function missing_blocks

ipld/resolver/src/missing_blocks.rs:15–33  ·  view source on GitHub ↗

Recursively find all [`Cid`] fields in the [`Block`] structures stored in the [`Blockstore`] and return all CIDs which could *not* be retrieved from the store. This function is available as a convenience, to be used by any [`BitswapStore`] implementation as they see fit.

(
    bs: &mut BS,
    cid: &Cid,
)

Source from the content-addressed store, hash-verified

13/// This function is available as a convenience, to be used by any [`BitswapStore`]
14/// implementation as they see fit.
15pub fn missing_blocks<BS: Blockstore, P: StoreParams>(
16 bs: &mut BS,
17 cid: &Cid,
18) -> anyhow::Result<Vec<Cid>>
19where
20 Ipld: References<<P as StoreParams>::Codecs>,
21{
22 let mut stack = vec![*cid];
23 let mut missing = vec![];
24 while let Some(cid) = stack.pop() {
25 if let Some(data) = bs.get(&cid)? {
26 let block = libipld::Block::<P>::new_unchecked(cid, data);
27 block.references(&mut stack)?;
28 } else {
29 missing.push(cid);
30 }
31 }
32 Ok(missing)
33}

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected