Skip to main content

TreeServer

Type Alias TreeServer 

Source
pub type TreeServer = GenericTreeServer<KvShardStore>;
Expand description

Production vote commitment tree backed by the Cosmos KV store.

Aliased Type§

pub struct TreeServer { /* private fields */ }

Implementations§

Source§

impl TreeServer

Source

pub fn new(cb: KvCallbacks, next_position: u64) -> Self

Create a new KV-backed tree server.

next_position is CommitmentTreeState.NextIndex from KV (0 on first boot). On a cold start, latest_checkpoint is initialised from the maximum checkpoint ID persisted in the KV store, so that root() returns the correct value even before the first checkpoint after restart.

Source§

impl TreeServer

Source

pub fn append_from_kv( &mut self, cursor: u64, count: u64, ) -> Result<(), AppendFromKvError>

Append count leaves starting at cursor by reading them directly from the application KV store via KV callbacks, skipping the Go-side leaf fetch and CGO serialization round-trip.

Each leaf is stored at 0x02 || u64 BE index in the Cosmos KV store (the CommitmentLeafKey format from types/keys.go). On success, the tree’s internal leaf count advances by count.

This is the production delta-append path: a single CGO call to this function replaces the newLeaves allocation + per-leaf KV read loop that was previously done in ensureTreeLoaded.