Trait Storage

Source
pub trait Storage: StateStorage {
Show 16 methods // Required methods fn insert_contract( &self, predicate: SignedContract, ) -> impl Future<Output = Result<(), Error>> + Send; fn insert_solution_into_pool( &self, solution: Solution, ) -> impl Future<Output = Result<(), Error>> + Send; fn move_solutions_to_solved( &self, block_number: u64, block_timestamp: Duration, solutions: &[[u8; 32]], ) -> impl Future<Output = Result<(), Error>> + Send; fn move_solutions_to_failed( &self, solutions: &[([u8; 32], SolutionFailReason)], ) -> impl Future<Output = Result<(), Error>> + Send; fn get_predicate( &self, address: &PredicateAddress, ) -> impl Future<Output = Result<Option<Predicate>, Error>> + Send; fn get_contract( &self, address: &ContentAddress, ) -> impl Future<Output = Result<Option<SignedContract>, Error>> + Send; fn list_contracts( &self, time_range: Option<Range<Duration>>, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Contract>, Error>> + Send; fn subscribe_contracts( self, start_time: Option<Duration>, start_page: Option<usize>, ) -> impl Stream<Item = Result<Contract, Error>> + Send + 'static; fn list_solutions_pool( &self, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Solution>, Error>> + Send; fn list_failed_solutions_pool( &self, page: Option<usize>, ) -> impl Future<Output = Result<Vec<FailedSolution>, Error>> + Send; fn list_blocks( &self, time_range: Option<Range<Duration>>, block_number: Option<u64>, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Block>, Error>> + Send; fn subscribe_blocks( self, start_time: Option<Duration>, block_number: Option<u64>, start_page: Option<usize>, ) -> impl Stream<Item = Result<Block, Error>> + Send + 'static; fn get_solution( &self, solution_hash: [u8; 32], ) -> impl Future<Output = Result<Option<SolutionOutcomes>, Error>> + Send; fn get_latest_block( &self, ) -> impl Future<Output = Result<Option<Block>, Error>> + Send; fn prune_failed_solutions( &self, older_than: Duration, ) -> impl Future<Output = Result<(), Error>> + Send; fn commit_block( &self, data: CommitData<'_>, ) -> impl Future<Output = Result<(), Error>> + Send;
}
Expand description

Storage trait for the Essential platform. All inserts and updates are idempotent.

Required Methods§

Source

fn insert_contract( &self, predicate: SignedContract, ) -> impl Future<Output = Result<(), Error>> + Send

Insert a contract with their storage layout.

Source

fn insert_solution_into_pool( &self, solution: Solution, ) -> impl Future<Output = Result<(), Error>> + Send

Add a solution to the pool of unsolved solutions.

Source

fn move_solutions_to_solved( &self, block_number: u64, block_timestamp: Duration, solutions: &[[u8; 32]], ) -> impl Future<Output = Result<(), Error>> + Send

Move these solutions from the pool to the solved state.

Source

fn move_solutions_to_failed( &self, solutions: &[([u8; 32], SolutionFailReason)], ) -> impl Future<Output = Result<(), Error>> + Send

Move these solutions from the pool to the failed state.

Source

fn get_predicate( &self, address: &PredicateAddress, ) -> impl Future<Output = Result<Option<Predicate>, Error>> + Send

Get an individual predicate. Note that the same predicate might be in multiple contracts.

Source

fn get_contract( &self, address: &ContentAddress, ) -> impl Future<Output = Result<Option<SignedContract>, Error>> + Send

Get the entire contract.

Source

fn list_contracts( &self, time_range: Option<Range<Duration>>, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Contract>, Error>> + Send

List all contracts. This will paginate the results. The page is 0-indexed. A time range can optionally be provided to filter the results. The time is duration since the Unix epoch.

Source

fn subscribe_contracts( self, start_time: Option<Duration>, start_page: Option<usize>, ) -> impl Stream<Item = Result<Contract, Error>> + Send + 'static

Subscribe to new contracts from a given start page or start time. This will return all the contracts from that point then continue to stream as new contracts are added.

Source

fn list_solutions_pool( &self, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Solution>, Error>> + Send

List all solutions in the pool.

Source

fn list_failed_solutions_pool( &self, page: Option<usize>, ) -> impl Future<Output = Result<Vec<FailedSolution>, Error>> + Send

List all failed solutions in the pool.

Source

fn list_blocks( &self, time_range: Option<Range<Duration>>, block_number: Option<u64>, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Block>, Error>> + Send

List all blocks of solutions that have been solved.

Source

fn subscribe_blocks( self, start_time: Option<Duration>, block_number: Option<u64>, start_page: Option<usize>, ) -> impl Stream<Item = Result<Block, Error>> + Send + 'static

Subscribe to new blocks from a given block number or start page or start time. This will return all the blocks from that point then continue to stream as new blocks are added.

Source

fn get_solution( &self, solution_hash: [u8; 32], ) -> impl Future<Output = Result<Option<SolutionOutcomes>, Error>> + Send

Get failed solution and its failing reason.

Source

fn get_latest_block( &self, ) -> impl Future<Output = Result<Option<Block>, Error>> + Send

Get latest block.

Source

fn prune_failed_solutions( &self, older_than: Duration, ) -> impl Future<Output = Result<(), Error>> + Send

Prune failed solutions that failed before the provided duration.

Source

fn commit_block( &self, data: CommitData<'_>, ) -> impl Future<Output = Result<(), Error>> + Send

Commit block data atomically.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§