Skip to main content

co_api/types/
guard.rs

1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 1io BRANDGUARDIAN GmbH
3
4use crate::CoreBlockStorage;
5use cid::Cid;
6use std::collections::BTreeSet;
7
8#[allow(async_fn_in_trait)]
9pub trait Guard {
10	/// Verify `next_head` is allowed to integrate into `state`@`heads`.
11	/// Return `true` if is allowed to integrate, `false` if is not allowed to integrate.
12	/// Errors will be treated as not allowed to integrate (`false`) but provide additional context.
13	async fn verify(
14		storage: &CoreBlockStorage,
15		guard: String,
16		state: Cid,
17		heads: BTreeSet<Cid>,
18		next_head: Cid,
19	) -> Result<bool, anyhow::Error>;
20}