Implement get_block_roots for syncing

This commit is contained in:
Paul Hauner
2019-03-22 14:20:49 +11:00
parent f96a3282b5
commit 96ba1c8f77
5 changed files with 146 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ use beacon_chain::{
CheckPoint,
};
use eth2_libp2p::HelloMessage;
use types::{Epoch, Hash256, Slot};
use types::{BeaconStateError, Epoch, Hash256, Slot};
/// The network's API to the beacon chain.
pub trait BeaconChain: Send + Sync {
@@ -29,6 +29,12 @@ pub trait BeaconChain: Send + Sync {
fn finalized_epoch(&self) -> Epoch;
fn hello_message(&self) -> HelloMessage;
fn get_block_roots(
&self,
start_slot: Slot,
count: Slot,
) -> Result<Vec<Hash256>, BeaconStateError>;
}
impl<T, U, F> BeaconChain for RawBeaconChain<T, U, F>
@@ -81,4 +87,12 @@ where
best_slot: self.best_slot(),
}
}
fn get_block_roots(
&self,
start_slot: Slot,
count: Slot,
) -> Result<Vec<Hash256>, BeaconStateError> {
self.get_block_roots(start_slot, count)
}
}