Add flag for web3 server

This commit is contained in:
Paul Hauner
2019-09-03 16:40:53 +10:00
parent 29584ca087
commit d80d9dba4c
7 changed files with 85 additions and 57 deletions

View File

@@ -48,7 +48,9 @@ pub enum Error {
BackendError(String),
}
pub trait Eth1ChainBackend<T: EthSpec> {
pub trait Eth1ChainBackend<T: EthSpec>: Sized + Send + Sync {
fn new(server: String) -> Result<Self>;
/// Returns the `Eth1Data` that should be included in a block being produced for the given
/// `state`.
fn eth1_data(&self, beacon_state: &BeaconState<T>) -> Result<Eth1Data>;
@@ -68,6 +70,10 @@ pub struct InteropEth1ChainBackend<T: EthSpec> {
}
impl<T: EthSpec> Eth1ChainBackend<T> for InteropEth1ChainBackend<T> {
fn new(_server: String) -> Result<Self> {
Ok(Self::default())
}
fn eth1_data(&self, state: &BeaconState<T>) -> Result<Eth1Data> {
let current_epoch = state.current_epoch();
let slots_per_voting_period = T::slots_per_eth1_voting_period() as u64;

View File

@@ -19,7 +19,7 @@ pub use self::beacon_chain::{
pub use self::checkpoint::CheckPoint;
pub use self::errors::{BeaconChainError, BlockProductionError};
pub use beacon_chain_builder::BeaconChainBuilder;
pub use eth1_chain::InteropEth1ChainBackend;
pub use eth1_chain::{Eth1ChainBackend, InteropEth1ChainBackend};
pub use lmd_ghost;
pub use metrics::scrape_for_metrics;
pub use parking_lot;