Skip to main content

validate_chain

Function validate_chain 

Source
pub fn validate_chain<F>(start: u64, next: F) -> Result<usize, ProvenanceError>
where F: FnMut(u64) -> Option<u64>,
Expand description

Walk a derivation / informing chain to validate bounded depth and the absence of cycles.

The caller supplies a closure that resolves each node ID to its (optional) predecessor in the chain. The walk bails out with ProvenanceError::CycleDetected if a node is revisited and with ProvenanceError::ChainTooDeep after MAX_CHAIN_DEPTH hops.