use bytes::Bytes;
use vapory_types::{H256, U256, Address};
use types::{
transaction::{SignedTransaction, CallError},
call_analytics::CallAnalytics,
errors::VapcoreError as Error,
errors::VapcoreResult,
header::Header,
};
use crate::block::{OpenBlock, SealedBlock, ClosedBlock};
use enjen::Engine;
use mashina::executed::Executed;
use account_state::state::StateInfo;
pub trait Call {
type State: StateInfo;
fn call(&self, tx: &SignedTransaction, analytics: CallAnalytics, state: &mut Self::State, header: &Header) -> Result<Executed, CallError>;
fn call_many(&self, txs: &[(SignedTransaction, CallAnalytics)], state: &mut Self::State, header: &Header) -> Result<Vec<Executed>, CallError>;
fn estimate_gas(&self, t: &SignedTransaction, state: &Self::State, header: &Header) -> Result<U256, CallError>;
}
pub trait EngineInfo {
fn engine(&self) -> &dyn Engine;
}
pub trait ReopenBlock {
fn reopen_block(&self, block: ClosedBlock) -> OpenBlock;
}
pub trait PrepareOpenBlock {
fn prepare_open_block(&self,
author: Address,
gas_range_target: (U256, U256),
extra_data: Bytes
) -> Result<OpenBlock, Error>;
}
pub trait BlockProducer: PrepareOpenBlock + ReopenBlock {}
pub trait ImportSealedBlock {
fn import_sealed_block(&self, block: SealedBlock) -> VapcoreResult<H256>;
}
pub trait BroadcastProposalBlock {
fn broadcast_proposal_block(&self, block: SealedBlock);
}
pub trait SealedBlockImporter: ImportSealedBlock + BroadcastProposalBlock {}