Trait ListIndex

Source
pub trait ListIndex {
    type List: Readable + Writeable;
    type Entry: ListIndexEntry;

    // Required methods
    fn list_key(&self, commit: Commitment) -> Vec<u8> ;
    fn entry_key(&self, commit: Commitment, pos: u64) -> Vec<u8> ;
    fn peek_pos(
        &self,
        batch: &Batch<'_>,
        commit: Commitment,
    ) -> Result<Option<<Self::Entry as ListIndexEntry>::Pos>, Error>;
    fn push_pos(
        &self,
        batch: &Batch<'_>,
        commit: Commitment,
        new_pos: <Self::Entry as ListIndexEntry>::Pos,
    ) -> Result<(), Error>;
    fn pop_pos(
        &self,
        batch: &Batch<'_>,
        commit: Commitment,
    ) -> Result<Option<<Self::Entry as ListIndexEntry>::Pos>, Error>;

    // Provided methods
    fn get_list(
        &self,
        batch: &Batch<'_>,
        commit: Commitment,
    ) -> Result<Option<Self::List>, Error> { ... }
    fn get_entry(
        &self,
        batch: &Batch<'_>,
        commit: Commitment,
        pos: u64,
    ) -> Result<Option<Self::Entry>, Error> { ... }
}
Expand description

Index supporting a list of (duplicate) entries per commitment. Each entry will be at a unique MMR pos.

Required Associated Types§

Source

type List: Readable + Writeable

List type

Source

type Entry: ListIndexEntry

List entry type

Required Methods§

Source

fn list_key(&self, commit: Commitment) -> Vec<u8>

Construct a key for the list.

Source

fn entry_key(&self, commit: Commitment, pos: u64) -> Vec<u8>

Construct a key for an individual entry in the list.

Source

fn peek_pos( &self, batch: &Batch<'_>, commit: Commitment, ) -> Result<Option<<Self::Entry as ListIndexEntry>::Pos>, Error>

Peek the head of the list for the specified commitment.

Source

fn push_pos( &self, batch: &Batch<'_>, commit: Commitment, new_pos: <Self::Entry as ListIndexEntry>::Pos, ) -> Result<(), Error>

Push a pos onto the list for the specified commitment.

Source

fn pop_pos( &self, batch: &Batch<'_>, commit: Commitment, ) -> Result<Option<<Self::Entry as ListIndexEntry>::Pos>, Error>

Pop a pos off the list for the specified commitment.

Provided Methods§

Source

fn get_list( &self, batch: &Batch<'_>, commit: Commitment, ) -> Result<Option<Self::List>, Error>

Returns either a “Single” with embedded “pos” or a “list” with “head” and “tail”. Key is “prefix|commit”. Note the key for an individual entry in the list is “prefix|commit|pos”.

Source

fn get_entry( &self, batch: &Batch<'_>, commit: Commitment, pos: u64, ) -> Result<Option<Self::Entry>, Error>

Returns one of “head”, “tail” or “middle” entry variants. Key is “prefix|commit|pos”.

Implementors§