pub fn verify_consistency(&self, version: u64) -> Result<(), ConsistencyError> {
        let manifest = self.db.try_manifest()?;
        let manifest = manifest.ok_or(ConsistencyError::MissingVersion(version))?;
        if version >= manifest.version_count {
            return Err(ConsistencyError::MissingVersion(version));
        }

        let root = self
            .db
            .try_root(version)?
            .ok_or(ConsistencyError::MissingRoot(version))?;

        if root.leaf_count < 2 {
            return Err(ConsistencyError::NoGuards);
        }
        let leaf_data = LeafConsistencyData::new(root.leaf_count);

        // We want to perform a depth-first walk of the tree in order to not keep
        // much in memory.
        let root_key = NodeKey::root(version);
        self.validate_internal_node(&root.root_node, root_key, &leaf_data)?;

        Ok(())
    }
Verifies the internal tree consistency as stored in the database.

If `validate_indices` flag is set, it will be checked that indices for all tree leaves are unique
and are sequentially assigned starting from 1.

# Errors

Returns an error (the first encountered one if there are multiple).
core/lib/zk_os_merkle_tree/src/consistency.rs