bdk_chain/
chain_oracle.rs

1use crate::BlockId;
2
3/// Represents a service that tracks the blockchain.
4///
5/// The main method is [`is_block_in_chain`] which determines whether a given block of [`BlockId`]
6/// is an ancestor of the `chain_tip`.
7///
8/// [`is_block_in_chain`]: Self::is_block_in_chain
9pub trait ChainOracle {
10    /// Error type.
11    type Error: core::fmt::Debug;
12
13    /// Determines whether `block` of [`BlockId`] exists as an ancestor of `chain_tip`.
14    ///
15    /// If `None` is returned, it means the implementation cannot determine whether `block` exists
16    /// under `chain_tip`.
17    fn is_block_in_chain(
18        &self,
19        block: BlockId,
20        chain_tip: BlockId,
21    ) -> Result<Option<bool>, Self::Error>;
22
23    /// Get the best chain's chain tip.
24    fn get_chain_tip(&self) -> Result<BlockId, Self::Error>;
25}