Skip to main content

TreeSyncApi

Trait TreeSyncApi 

Source
pub trait TreeSyncApi {
    type Error: Debug;

    // Required methods
    fn get_block_commitments(
        &self,
        from_height: u32,
        to_height: u32,
    ) -> Result<Vec<BlockCommitments>, Self::Error>;
    fn get_root_at_height(&self, height: u32) -> Result<Option<Fp>, Self::Error>;
    fn get_tree_state(&self) -> Result<TreeState, Self::Error>;
}
Expand description

The contract between server and client.

In the POC: in-process (server implements this directly). In production: maps to Cosmos SDK gRPC/REST endpoints:

  • get_block_commitments → custom compact-block endpoint or Tendermint block queries
  • get_root_at_heightGET /zally/v1/commitment-tree/{height}
  • get_tree_stateGET /zally/v1/commitment-tree/latest

Required Associated Types§

Required Methods§

Source

fn get_block_commitments( &self, from_height: u32, to_height: u32, ) -> Result<Vec<BlockCommitments>, Self::Error>

Fetch commitments per block in a height range (primary sync method).

Returns blocks in ascending height order. Empty blocks (no appends) may be omitted from the result.

Source

fn get_root_at_height(&self, height: u32) -> Result<Option<Fp>, Self::Error>

Fetch tree root at a checkpoint height (anchor verification).

Maps to: GET /zally/v1/commitment-tree/{height}

Source

fn get_tree_state(&self) -> Result<TreeState, Self::Error>

Fetch current tree state (next_index, root, latest height).

Maps to: GET /zally/v1/commitment-tree/latest

Implementors§

Source§

impl<S> TreeSyncApi for SyncableServer<S>
where S: ShardStore<H = MerkleHashVote, CheckpointId = u32>, S::Error: Debug,