Trait essential_storage::Storage
source · pub trait Storage: StateStorage {
Show 15 methods
// Required methods
fn insert_contract(
&self,
predicate: SignedContract,
) -> impl Future<Output = Result<()>> + Send;
fn insert_solution_into_pool(
&self,
solution: Solution,
) -> impl Future<Output = Result<()>> + Send;
fn move_solutions_to_solved(
&self,
solutions: &[Hash],
) -> impl Future<Output = Result<()>> + Send;
fn move_solutions_to_failed(
&self,
solutions: &[(Hash, SolutionFailReason)],
) -> impl Future<Output = Result<()>> + Send;
fn get_predicate(
&self,
address: &PredicateAddress,
) -> impl Future<Output = Result<Option<Predicate>>> + Send;
fn get_contract(
&self,
address: &ContentAddress,
) -> impl Future<Output = Result<Option<SignedContract>>> + Send;
fn list_contracts(
&self,
time_range: Option<Range<Duration>>,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<Contract>>> + Send;
fn subscribe_contracts(
self,
start_time: Option<Duration>,
start_page: Option<usize>,
) -> impl Stream<Item = Result<Contract>> + Send + 'static;
fn list_solutions_pool(
&self,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<Solution>>> + Send;
fn list_failed_solutions_pool(
&self,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<FailedSolution>>> + Send;
fn list_blocks(
&self,
time_range: Option<Range<Duration>>,
block_number: Option<u64>,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<Block>>> + Send;
fn subscribe_blocks(
self,
start_time: Option<Duration>,
block_number: Option<u64>,
start_page: Option<usize>,
) -> impl Stream<Item = Result<Block>> + Send + 'static;
fn get_solution(
&self,
solution_hash: Hash,
) -> impl Future<Output = Result<Option<SolutionOutcomes>>> + Send;
fn prune_failed_solutions(
&self,
older_than: Duration,
) -> impl Future<Output = Result<()>> + Send;
fn commit_block(
&self,
data: CommitData<'_>,
) -> impl Future<Output = Result<()>> + Send;
}Expand description
Storage trait for the Essential platform. All inserts and updates are idempotent.
Required Methods§
sourcefn insert_contract(
&self,
predicate: SignedContract,
) -> impl Future<Output = Result<()>> + Send
fn insert_contract( &self, predicate: SignedContract, ) -> impl Future<Output = Result<()>> + Send
Insert a contract with their storage layout.
sourcefn insert_solution_into_pool(
&self,
solution: Solution,
) -> impl Future<Output = Result<()>> + Send
fn insert_solution_into_pool( &self, solution: Solution, ) -> impl Future<Output = Result<()>> + Send
Add a solution to the pool of unsolved solutions.
sourcefn move_solutions_to_solved(
&self,
solutions: &[Hash],
) -> impl Future<Output = Result<()>> + Send
fn move_solutions_to_solved( &self, solutions: &[Hash], ) -> impl Future<Output = Result<()>> + Send
Move these solutions from the pool to the solved state.
sourcefn move_solutions_to_failed(
&self,
solutions: &[(Hash, SolutionFailReason)],
) -> impl Future<Output = Result<()>> + Send
fn move_solutions_to_failed( &self, solutions: &[(Hash, SolutionFailReason)], ) -> impl Future<Output = Result<()>> + Send
Move these solutions from the pool to the failed state.
sourcefn get_predicate(
&self,
address: &PredicateAddress,
) -> impl Future<Output = Result<Option<Predicate>>> + Send
fn get_predicate( &self, address: &PredicateAddress, ) -> impl Future<Output = Result<Option<Predicate>>> + Send
Get an individual predicate. Note that the same predicate might be in multiple contracts.
sourcefn get_contract(
&self,
address: &ContentAddress,
) -> impl Future<Output = Result<Option<SignedContract>>> + Send
fn get_contract( &self, address: &ContentAddress, ) -> impl Future<Output = Result<Option<SignedContract>>> + Send
Get the entire contract.
sourcefn list_contracts(
&self,
time_range: Option<Range<Duration>>,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<Contract>>> + Send
fn list_contracts( &self, time_range: Option<Range<Duration>>, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Contract>>> + 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.
sourcefn subscribe_contracts(
self,
start_time: Option<Duration>,
start_page: Option<usize>,
) -> impl Stream<Item = Result<Contract>> + Send + 'static
fn subscribe_contracts( self, start_time: Option<Duration>, start_page: Option<usize>, ) -> impl Stream<Item = Result<Contract>> + 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.
sourcefn list_solutions_pool(
&self,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<Solution>>> + Send
fn list_solutions_pool( &self, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Solution>>> + Send
List all solutions in the pool.
sourcefn list_failed_solutions_pool(
&self,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<FailedSolution>>> + Send
fn list_failed_solutions_pool( &self, page: Option<usize>, ) -> impl Future<Output = Result<Vec<FailedSolution>>> + Send
List all failed solutions in the pool.
sourcefn list_blocks(
&self,
time_range: Option<Range<Duration>>,
block_number: Option<u64>,
page: Option<usize>,
) -> impl Future<Output = Result<Vec<Block>>> + Send
fn list_blocks( &self, time_range: Option<Range<Duration>>, block_number: Option<u64>, page: Option<usize>, ) -> impl Future<Output = Result<Vec<Block>>> + Send
List all blocks of solutions that have been solved.
sourcefn subscribe_blocks(
self,
start_time: Option<Duration>,
block_number: Option<u64>,
start_page: Option<usize>,
) -> impl Stream<Item = Result<Block>> + Send + 'static
fn subscribe_blocks( self, start_time: Option<Duration>, block_number: Option<u64>, start_page: Option<usize>, ) -> impl Stream<Item = Result<Block>> + 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.
sourcefn get_solution(
&self,
solution_hash: Hash,
) -> impl Future<Output = Result<Option<SolutionOutcomes>>> + Send
fn get_solution( &self, solution_hash: Hash, ) -> impl Future<Output = Result<Option<SolutionOutcomes>>> + Send
Get failed solution and its failing reason.
sourcefn prune_failed_solutions(
&self,
older_than: Duration,
) -> impl Future<Output = Result<()>> + Send
fn prune_failed_solutions( &self, older_than: Duration, ) -> impl Future<Output = Result<()>> + Send
Prune failed solutions that failed before the provided duration.
sourcefn commit_block(
&self,
data: CommitData<'_>,
) -> impl Future<Output = Result<()>> + Send
fn commit_block( &self, data: CommitData<'_>, ) -> impl Future<Output = Result<()>> + Send
Commit block data atomically.