referrerpolicy=no-referrer-when-downgrade

StatementStore

Trait StatementStore 

Source
pub trait StatementStore: Send + Sync {
Show 17 methods // Required methods fn statements(&self) -> Result<Vec<(Hash, Statement)>>; fn take_recent_statements(&self) -> Result<Vec<(u64, Hash, Statement)>>; fn statement(&self, hash: &Hash) -> Result<Option<Statement>>; fn has_statement(&self, hash: &Hash) -> bool; fn statements_by_hashes( &self, hashes: &[Hash], filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision, ) -> Result<(Vec<(Hash, Statement)>, usize)>; fn admission_watermark(&self) -> Result<u64>; fn admitted_statements( &self, cursor: u64, watermark: u64, scan_limit: usize, filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision, ) -> Result<AdmittedBatch>; fn broadcasts(&self, match_all_topics: &[Topic]) -> Result<Vec<Vec<u8>>>; fn posted( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>; fn posted_clear( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>; fn broadcasts_stmt( &self, match_all_topics: &[Topic], ) -> Result<Vec<Vec<u8>>>; fn posted_stmt( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>; fn posted_clear_stmt( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>; fn submit( &self, statement: Statement, source: StatementSource, ) -> SubmitResult; fn remove(&self, hash: &Hash) -> Result<()>; fn remove_by(&self, who: [u8; 32]) -> Result<()>; // Provided method fn subscription_topics(&self) -> HashSet<Topic> { ... }
}
Expand description

Statement store API.

Required Methods§

Source

fn statements(&self) -> Result<Vec<(Hash, Statement)>>

Return all statements.

Source

fn take_recent_statements(&self) -> Result<Vec<(u64, Hash, Statement)>>

Return recent statements with their admission sequence numbers, oldest admission first, and clear the internal index.

This consumes and clears the recently received statements, allowing new statements to be collected from this point forward.

Source

fn statement(&self, hash: &Hash) -> Result<Option<Statement>>

Get statement by hash.

Source

fn has_statement(&self, hash: &Hash) -> bool

Check if statement exists in the store

Fast index check without accessing the DB.

Source

fn statements_by_hashes( &self, hashes: &[Hash], filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision, ) -> Result<(Vec<(Hash, Statement)>, usize)>

Fetch statements by their hashes with a filter callback.

The callback receives (hash, encoded_bytes, decoded_statement) and returns:

  • Skip: ignore this statement, continue to next
  • Take: include this statement in the result, continue to next
  • Abort: stop iteration, return collected statements so far

Returns (statements, number_of_hashes_processed).

Source

fn admission_watermark(&self) -> Result<u64>

One past the newest assigned admission sequence number.

Every statement currently in the store was admitted below this boundary, so it serves as the watermark for a subsequent Self::admitted_statements walk.

Source

fn admitted_statements( &self, cursor: u64, watermark: u64, scan_limit: usize, filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision, ) -> Result<AdmittedBatch>

Walk the admission journal from cursor (inclusive) towards watermark (exclusive), collecting statements through a filter callback.

The callback receives (hash, encoded_bytes, decoded_statement) and returns:

  • Skip: leave this statement out of the batch, continue to next
  • Take: include this statement in the batch, continue to next
  • Abort: stop the walk before this statement

Sequence numbers whose statement has left the store are passed over. The returned cursor sits after every visited statement except an Aborted one, which the next walk revisits first.

A call visits at most scan_limit journal entries, passed-over ones included, so its cost stays bounded even when the filter takes nothing. scan_limit must be positive: a walk that visits no entries cannot advance the cursor. A walk stopped by the limit returns a partial cursor to resume from, exactly like an Abort.

Source

fn broadcasts(&self, match_all_topics: &[Topic]) -> Result<Vec<Vec<u8>>>

Return the data of all known statements which include all topics and have no DecryptionKey field.

Source

fn posted( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>

Return the data of all known statements whose decryption key is identified as dest (this will generally be the public key or a hash thereof for symmetric ciphers, or a hash of the private key for symmetric ciphers).

Source

fn posted_clear( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>

Return the decrypted data of all known statements whose decryption key is identified as dest. The key must be available to the client.

Source

fn broadcasts_stmt(&self, match_all_topics: &[Topic]) -> Result<Vec<Vec<u8>>>

Return all known statements which include all topics and have no DecryptionKey field.

Source

fn posted_stmt( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>

Return all known statements whose decryption key is identified as dest (this will generally be the public key or a hash thereof for symmetric ciphers, or a hash of the private key for symmetric ciphers).

Source

fn posted_clear_stmt( &self, match_all_topics: &[Topic], dest: [u8; 32], ) -> Result<Vec<Vec<u8>>>

Return the statement and the decrypted data of all known statements whose decryption key is identified as dest. The key must be available to the client.

The result is for each statement: the SCALE-encoded statement concatenated to the decrypted data.

Source

fn submit(&self, statement: Statement, source: StatementSource) -> SubmitResult

Submit a statement.

Source

fn remove(&self, hash: &Hash) -> Result<()>

Remove a statement from the store.

Source

fn remove_by(&self, who: [u8; 32]) -> Result<()>

Remove all statements authored by who.

Provided Methods§

Source

fn subscription_topics(&self) -> HashSet<Topic>

Topics across all live statement subscriptions, for advertising topic affinity.

Defaults to empty for stores without a subscription manager.

Implementors§