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
use std::sync::Arc; use crate::traits::{ServiceMapping, Storage}; use crate::types::{Address, Bloom, MerkleRoot, Receipt, SignedTransaction, TransactionRequest}; use crate::ProtocolResult; #[derive(Debug, Clone)] pub struct ExecutorResp { pub receipts: Vec<Receipt>, pub all_cycles_used: u64, pub logs_bloom: Bloom, pub state_root: MerkleRoot, } #[derive(Debug, Clone)] pub struct ExecutorParams { pub state_root: MerkleRoot, pub epoch_id: u64, pub timestamp: u64, pub cycels_limit: u64, } #[derive(Debug, Clone)] pub struct ExecResp { pub ret: String, pub is_error: bool, } pub trait ExecutorFactory<DB: cita_trie::DB, S: Storage, Mapping: ServiceMapping>: Send + Sync { fn from_root( root: MerkleRoot, db: Arc<DB>, storage: Arc<S>, mapping: Arc<Mapping>, ) -> ProtocolResult<Box<dyn Executor>>; } pub trait Executor { fn exec( &mut self, params: &ExecutorParams, txs: &[SignedTransaction], ) -> ProtocolResult<ExecutorResp>; fn read( &self, params: &ExecutorParams, caller: &Address, cycles_price: u64, request: &TransactionRequest, ) -> ProtocolResult<ExecResp>; }