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§
Sourcefn take_recent_statements(&self) -> Result<Vec<(u64, Hash, Statement)>>
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.
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 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 admission_watermark(&self) -> Result<u64>
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.
Sourcefn admitted_statements(
&self,
cursor: u64,
watermark: u64,
scan_limit: usize,
filter: &mut dyn FnMut(&Hash, &[u8], &Statement) -> FilterDecision,
) -> Result<AdmittedBatch>
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 nextTake: include this statement in the batch, continue to nextAbort: 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.
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.
Provided Methods§
Sourcefn subscription_topics(&self) -> HashSet<Topic>
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.