pub trait StatementStore: Send + Sync {
Show 15 methods
// Required methods
fn statements(&self) -> Result<Vec<(Hash, Statement)>>;
fn take_recent_statements(&self) -> Result<Vec<(Hash, Statement)>>;
fn statement(&self, hash: &Hash) -> Result<Option<Statement>>;
fn has_statement(&self, hash: &Hash) -> bool;
fn statement_hashes(&self) -> Vec<Hash> ⓘ;
fn statements_by_hashes(
&self,
hashes: &[Hash],
filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision,
) -> Result<(Vec<(Hash, Statement)>, usize)>;
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<()>;
}Expand description
Statement store API.
Required Methods§
Sourcefn take_recent_statements(&self) -> Result<Vec<(Hash, Statement)>>
fn take_recent_statements(&self) -> Result<Vec<(Hash, Statement)>>
Return recent statements and clear the internal index.
This consumes and clears the recently received statements, allowing new statements to be collected from this point forward.
Sourcefn has_statement(&self, hash: &Hash) -> bool
fn has_statement(&self, hash: &Hash) -> bool
Check if statement exists in the store
Fast index check without accessing the DB.
Sourcefn statement_hashes(&self) -> Vec<Hash> ⓘ
fn statement_hashes(&self) -> Vec<Hash> ⓘ
Return all statement hashes.
Sourcefn statements_by_hashes(
&self,
hashes: &[Hash],
filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision,
) -> Result<(Vec<(Hash, Statement)>, usize)>
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 nextTake: include this statement in the result, continue to nextAbort: stop iteration, return collected statements so far
Returns (statements, number_of_hashes_processed).
Sourcefn broadcasts(&self, match_all_topics: &[Topic]) -> Result<Vec<Vec<u8>>>
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.
Sourcefn posted(
&self,
match_all_topics: &[Topic],
dest: [u8; 32],
) -> Result<Vec<Vec<u8>>>
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).
Sourcefn posted_clear(
&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>>>
Return the decrypted data of all known statements whose decryption key is identified as
dest. The key must be available to the client.
Sourcefn broadcasts_stmt(&self, match_all_topics: &[Topic]) -> Result<Vec<Vec<u8>>>
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.
Sourcefn posted_stmt(
&self,
match_all_topics: &[Topic],
dest: [u8; 32],
) -> Result<Vec<Vec<u8>>>
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).
Sourcefn posted_clear_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>>>
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.
Sourcefn submit(&self, statement: Statement, source: StatementSource) -> SubmitResult
fn submit(&self, statement: Statement, source: StatementSource) -> SubmitResult
Submit a statement.