oasis_runtime_sdk/
schedule_control.rs1use oasis_core_runtime::{
3 common::crypto::hash::Hash, transaction::types::TxnBatch, types::Body, Protocol,
4};
5
6const MODULE_NAME: &str = "schedule_control";
8
9#[derive(Debug, thiserror::Error, oasis_runtime_sdk_macros::Error)]
11pub enum Error {
12 #[error("failed to fetch batch from host")]
13 #[sdk_error(code = 1)]
14 FailedToFetchBatch,
15}
16
17pub trait ScheduleControlHost: Send + Sync {
19 fn fetch_tx_batch(&self, offset: Option<Hash>, limit: u32) -> Result<Option<TxnBatch>, Error>;
25}
26
27impl ScheduleControlHost for Protocol {
28 fn fetch_tx_batch(&self, offset: Option<Hash>, limit: u32) -> Result<Option<TxnBatch>, Error> {
29 match self.call_host(Body::HostFetchTxBatchRequest { offset, limit }) {
30 Ok(Body::HostFetchTxBatchResponse { batch }) => Ok(batch),
31 _ => Err(Error::FailedToFetchBatch),
32 }
33 }
34}