1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use quartz_contract_core::state::{Config, Nonce};
pub mod default;
/// A trait representing a key-value store for managing core enclave state.
///
/// The [`Store`] trait defines an asynchronous interface for reading and writing
/// various pieces of state that are essential to the handshake protocol.
#[async_trait::async_trait]
pub trait Store: Send + Sync + 'static {
/// The type representing the contract that the store manages.
type Contract: Send + Sync;
/// The type representing the chain height that the store manages.
type Height: Send + Sync;
/// The type representing the chain hash that the store manages.
type Hash: Send + Sync;
/// The error type returned by store operations.
type Error: ToString + Send + Sync;
/// Retrieves the current enclave configuration.
async fn get_config(&self) -> Result<Option<Config>, Self::Error>;
/// Sets a new configuration for the enclave.
async fn set_config(&self, config: Config) -> Result<Option<Config>, Self::Error>;
/// Retrieves the contract associated with the enclave.
async fn get_contract(&self) -> Result<Option<Self::Contract>, Self::Error>;
/// Sets the contract associated with the enclave.
async fn set_contract(
&self,
contract: Self::Contract,
) -> Result<Option<Self::Contract>, Self::Error>;
/// Retrieves the current nonce.
async fn get_nonce(&self) -> Result<Option<Nonce>, Self::Error>;
/// Sets a new nonce for replay protection.
async fn set_nonce(&self, nonce: Nonce) -> Result<Option<Nonce>, Self::Error>;
/// Retrieves the current sequence number.
async fn get_seq_num(&self) -> Result<u64, Self::Error>;
/// Increments the sequence number by the given count.
async fn inc_seq_num(&self, count: usize) -> Result<u64, Self::Error>;
/// Retrieves the current trusted height & hash.
async fn get_trusted_height_hash(&self) -> Result<(Self::Height, Self::Hash), Self::Error>;
/// Sets a new trusted height & hash.
async fn set_trusted_height_hash(
&self,
height: Self::Height,
hash: Self::Hash,
) -> Result<(Self::Height, Self::Hash), Self::Error>;
}