Skip to main content

Queue

Trait Queue 

Source
pub trait Queue<V>: Send{
    // Required methods
    fn iterator(
        &self,
        partition: QueuePartitionIdx,
        ranges: &[QueueShardRange],
        for_shard_id: ShardIdent,
    ) -> Result<Box<dyn StateIterator<V>>>;
    fn prepare_diff(
        &self,
        diff: QueueDiffWithMessages<V>,
        block_id_short: BlockIdShort,
        hash: &HashBytes,
        statistics: DiffStatistics,
        check_sequence: Option<DiffZone>,
    ) -> Result<Option<PendingQueueDiff>>;
    fn apply_diff(
        &self,
        diff: QueueDiffWithMessages<V>,
        block_id_short: BlockIdShort,
        hash: &HashBytes,
        statistics: DiffStatistics,
        check_sequence: Option<DiffZone>,
    ) -> Result<()>;
    fn commit_diff(
        &self,
        mc_top_blocks: &[TopBlockIdUpdated],
        partitions: &FastHashSet<QueuePartitionIdx>,
    ) -> Result<()>;
    fn clear_uncommitted_state(
        &self,
        partitions: &FastHashSet<QueuePartitionIdx>,
        top_shards: &[ShardIdent],
    ) -> Result<()>;
    fn get_diffs_tail_len(
        &self,
        shard_ident: &ShardIdent,
        from: &QueueKey,
    ) -> u32;
    fn load_diff_statistics(
        &self,
        partition: QueuePartitionIdx,
        range: &QueueShardRange,
        result: &mut AccountStatistics,
    ) -> Result<()>;
    fn get_diff_info(
        &self,
        shard_ident: &ShardIdent,
        seqno: u32,
        zone: DiffZone,
    ) -> Result<Option<DiffInfo>>;
    fn is_diff_exists(&self, block_id_short: &BlockIdShort) -> Result<bool>;
    fn get_last_committed_mc_block_id(&self) -> Result<Option<BlockId>>;
    fn load_separated_diff_statistics(
        &self,
        partitions: &FastHashSet<QueuePartitionIdx>,
        range: &QueueShardRange,
    ) -> Result<SeparatedStatisticsByPartitions>;
}

Required Methods§

Source

fn iterator( &self, partition: QueuePartitionIdx, ranges: &[QueueShardRange], for_shard_id: ShardIdent, ) -> Result<Box<dyn StateIterator<V>>>

Create iterator for specified shard and return it

Source

fn prepare_diff( &self, diff: QueueDiffWithMessages<V>, block_id_short: BlockIdShort, hash: &HashBytes, statistics: DiffStatistics, check_sequence: Option<DiffZone>, ) -> Result<Option<PendingQueueDiff>>

Prepare diff for applying to state. Returns transaction that should be committed later. Returns None if diff is already applied (duplicate).

Source

fn apply_diff( &self, diff: QueueDiffWithMessages<V>, block_id_short: BlockIdShort, hash: &HashBytes, statistics: DiffStatistics, check_sequence: Option<DiffZone>, ) -> Result<()>

Add messages to state from diff.messages and store diff info (writes immediately)

Source

fn commit_diff( &self, mc_top_blocks: &[TopBlockIdUpdated], partitions: &FastHashSet<QueuePartitionIdx>, ) -> Result<()>

Commit diffs to the state and update GC

Source

fn clear_uncommitted_state( &self, partitions: &FastHashSet<QueuePartitionIdx>, top_shards: &[ShardIdent], ) -> Result<()>

Remove all data in uncommitted zone

Source

fn get_diffs_tail_len(&self, shard_ident: &ShardIdent, from: &QueueKey) -> u32

Get diffs tail len

Source

fn load_diff_statistics( &self, partition: QueuePartitionIdx, range: &QueueShardRange, result: &mut AccountStatistics, ) -> Result<()>

Load statistics for the given range by accounts

Source

fn get_diff_info( &self, shard_ident: &ShardIdent, seqno: u32, zone: DiffZone, ) -> Result<Option<DiffInfo>>

Get diff info for the given block from committed and/or uncommitted zones

Source

fn is_diff_exists(&self, block_id_short: &BlockIdShort) -> Result<bool>

Check if diff exists in state

Source

fn get_last_committed_mc_block_id(&self) -> Result<Option<BlockId>>

Get mc block id on which the queue was committed. Returns None if queue was not committed

Source

fn load_separated_diff_statistics( &self, partitions: &FastHashSet<QueuePartitionIdx>, range: &QueueShardRange, ) -> Result<SeparatedStatisticsByPartitions>

Load separated diff statistics for the specified partitions and range

Implementors§

Source§

impl<P, V> Queue<V> for QueueImpl<P, V>
where P: QueueState<V> + Send + Sync + 'static, V: InternalMessageValue + Send + Sync,