use pasta_curves::Fp;
use crate::hash::MerkleHashVote;
#[derive(Clone, Debug)]
pub struct BlockCommitments {
pub height: u32,
pub start_index: u64,
pub leaves: Vec<MerkleHashVote>,
pub root: Fp,
}
#[derive(Clone, Debug)]
pub struct BlockCommitmentsPage {
pub blocks: Vec<BlockCommitments>,
pub next_from_height: u32,
}
#[derive(Clone, Debug)]
pub struct TreeState {
pub next_index: u64,
pub root: Fp,
pub height: u32,
}
pub trait TreeSyncApi {
type Error: std::fmt::Debug;
fn get_block_commitments(
&self,
from_height: u32,
to_height: u32,
) -> Result<BlockCommitmentsPage, Self::Error>;
fn get_root_at_height(&self, height: u32) -> Result<Option<Fp>, Self::Error>;
fn get_tree_state(&self) -> Result<TreeState, Self::Error>;
}