pub use super::impls::state::State;
use cfx_types::AddressWithSpace;
pub type WithProof = primitives::static_bool::Yes;
pub type NoProof = primitives::static_bool::No;
pub trait StateTrait: Sync + Send {
fn get(&self, access_key: StorageKeyWithSpace)
-> Result<Option<Box<[u8]>>>;
fn set(
&mut self, access_key: StorageKeyWithSpace, value: Box<[u8]>,
) -> Result<()>;
fn delete(&mut self, access_key: StorageKeyWithSpace) -> Result<()>;
fn delete_test_only(
&mut self, access_key: StorageKeyWithSpace,
) -> Result<Option<Box<[u8]>>>;
fn delete_all(
&mut self, access_key_prefix: StorageKeyWithSpace,
) -> Result<Option<Vec<MptKeyValue>>>;
fn read_all(
&mut self, access_key_prefix: StorageKeyWithSpace,
) -> Result<Option<Vec<MptKeyValue>>>;
fn compute_state_root(&mut self) -> Result<StateRootWithAuxInfo>;
fn get_state_root(&self) -> Result<StateRootWithAuxInfo>;
fn commit(&mut self, epoch: EpochId) -> Result<StateRootWithAuxInfo>;
}
pub trait StateTraitExt {
fn get_with_proof(
&self, access_key: StorageKeyWithSpace,
) -> Result<(Option<Box<[u8]>>, StateProof)>;
fn get_node_merkle_all_versions<WithProof: StaticBool>(
&self, access_key: StorageKeyWithSpace,
) -> Result<(NodeMerkleTriplet, NodeMerkleProof)>;
}
pub trait StateDbGetOriginalMethods {
fn get_original_raw_with_proof(
&self, key: StorageKeyWithSpace,
) -> Result<(Option<Box<[u8]>>, StateProof)>;
fn get_original_storage_root(
&self, address: &AddressWithSpace,
) -> Result<StorageRoot>;
fn get_original_storage_root_with_proof(
&self, address: &AddressWithSpace,
) -> Result<(StorageRoot, StorageRootProof)>;
}
use super::{
impls::{
errors::*, node_merkle_proof::NodeMerkleProof, state_proof::StateProof,
},
MptKeyValue, StateRootWithAuxInfo,
};
use crate::StorageRootProof;
use primitives::{
EpochId, NodeMerkleTriplet, StaticBool, StorageKeyWithSpace, StorageRoot,
};