2019-03-22 02:51:17 +00:00
|
|
|
use beacon_chain::BeaconChain as RawBeaconChain;
|
|
|
|
use beacon_chain::{
|
|
|
|
db::ClientDB,
|
|
|
|
fork_choice::ForkChoice,
|
|
|
|
parking_lot::RwLockReadGuard,
|
|
|
|
slot_clock::SlotClock,
|
|
|
|
types::{BeaconState, ChainSpec},
|
|
|
|
};
|
2019-03-26 04:26:05 +00:00
|
|
|
pub use beacon_chain::{BeaconChainError, BlockProcessingOutcome};
|
|
|
|
use types::BeaconBlock;
|
2019-03-22 02:51:17 +00:00
|
|
|
|
|
|
|
/// The RPC's API to the beacon chain.
|
|
|
|
pub trait BeaconChain: Send + Sync {
|
|
|
|
fn get_spec(&self) -> &ChainSpec;
|
|
|
|
|
|
|
|
fn get_state(&self) -> RwLockReadGuard<BeaconState>;
|
2019-03-26 04:26:05 +00:00
|
|
|
|
|
|
|
fn process_block(&self, block: BeaconBlock)
|
|
|
|
-> Result<BlockProcessingOutcome, BeaconChainError>;
|
2019-03-22 02:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T, U, F> BeaconChain for RawBeaconChain<T, U, F>
|
|
|
|
where
|
|
|
|
T: ClientDB + Sized,
|
|
|
|
U: SlotClock,
|
|
|
|
F: ForkChoice,
|
|
|
|
{
|
|
|
|
fn get_spec(&self) -> &ChainSpec {
|
|
|
|
&self.spec
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_state(&self) -> RwLockReadGuard<BeaconState> {
|
|
|
|
self.state.read()
|
|
|
|
}
|
2019-03-26 04:26:05 +00:00
|
|
|
|
|
|
|
fn process_block(
|
|
|
|
&self,
|
|
|
|
block: BeaconBlock,
|
|
|
|
) -> Result<BlockProcessingOutcome, BeaconChainError> {
|
|
|
|
self.process_block(block)
|
|
|
|
}
|
2019-03-22 02:51:17 +00:00
|
|
|
}
|