2019-03-18 06:38:23 +00:00
|
|
|
use beacon_chain::BeaconChain as RawBeaconChain;
|
|
|
|
use beacon_chain::{
|
2019-03-18 13:26:15 +00:00
|
|
|
db::ClientDB,
|
|
|
|
fork_choice::ForkChoice,
|
|
|
|
parking_lot::RwLockReadGuard,
|
|
|
|
slot_clock::SlotClock,
|
|
|
|
types::{BeaconState, ChainSpec},
|
|
|
|
CheckPoint,
|
2019-03-18 06:38:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// The network's API to the beacon chain.
|
|
|
|
pub trait BeaconChain: Send + Sync {
|
2019-03-18 13:05:06 +00:00
|
|
|
fn get_spec(&self) -> &ChainSpec;
|
|
|
|
|
2019-03-18 13:26:15 +00:00
|
|
|
fn get_state(&self) -> RwLockReadGuard<BeaconState>;
|
|
|
|
|
2019-03-18 06:38:23 +00:00
|
|
|
fn head(&self) -> RwLockReadGuard<CheckPoint>;
|
|
|
|
|
|
|
|
fn finalized_head(&self) -> RwLockReadGuard<CheckPoint>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T, U, F> BeaconChain for RawBeaconChain<T, U, F>
|
|
|
|
where
|
|
|
|
T: ClientDB + Sized,
|
|
|
|
U: SlotClock,
|
|
|
|
F: ForkChoice,
|
|
|
|
{
|
2019-03-18 13:05:06 +00:00
|
|
|
fn get_spec(&self) -> &ChainSpec {
|
|
|
|
&self.spec
|
|
|
|
}
|
|
|
|
|
2019-03-18 13:26:15 +00:00
|
|
|
fn get_state(&self) -> RwLockReadGuard<BeaconState> {
|
|
|
|
self.state.read()
|
|
|
|
}
|
|
|
|
|
2019-03-18 06:38:23 +00:00
|
|
|
fn head(&self) -> RwLockReadGuard<CheckPoint> {
|
|
|
|
self.head()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn finalized_head(&self) -> RwLockReadGuard<CheckPoint> {
|
|
|
|
self.finalized_head()
|
|
|
|
}
|
|
|
|
}
|