mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Allow sync to to request block bodies.
This commit is contained in:
@@ -8,7 +8,9 @@ use beacon_chain::{
|
||||
CheckPoint,
|
||||
};
|
||||
use eth2_libp2p::HelloMessage;
|
||||
use types::{BeaconStateError, Epoch, Hash256, Slot};
|
||||
use types::{BeaconBlock, BeaconStateError, Epoch, Hash256, Slot};
|
||||
|
||||
pub use beacon_chain::BeaconChainError;
|
||||
|
||||
/// The network's API to the beacon chain.
|
||||
pub trait BeaconChain: Send + Sync {
|
||||
@@ -20,6 +22,8 @@ pub trait BeaconChain: Send + Sync {
|
||||
|
||||
fn head(&self) -> RwLockReadGuard<CheckPoint>;
|
||||
|
||||
fn get_block(&self, block_root: &Hash256) -> Result<Option<BeaconBlock>, BeaconChainError>;
|
||||
|
||||
fn best_slot(&self) -> Slot;
|
||||
|
||||
fn best_block_root(&self) -> Hash256;
|
||||
@@ -35,6 +39,8 @@ pub trait BeaconChain: Send + Sync {
|
||||
start_slot: Slot,
|
||||
count: Slot,
|
||||
) -> Result<Vec<Hash256>, BeaconStateError>;
|
||||
|
||||
fn is_new_block_root(&self, beacon_block_root: &Hash256) -> Result<bool, BeaconChainError>;
|
||||
}
|
||||
|
||||
impl<T, U, F> BeaconChain for RawBeaconChain<T, U, F>
|
||||
@@ -59,6 +65,10 @@ where
|
||||
self.head()
|
||||
}
|
||||
|
||||
fn get_block(&self, block_root: &Hash256) -> Result<Option<BeaconBlock>, BeaconChainError> {
|
||||
self.get_block(block_root)
|
||||
}
|
||||
|
||||
fn finalized_epoch(&self) -> Epoch {
|
||||
self.get_state().finalized_epoch
|
||||
}
|
||||
@@ -95,4 +105,8 @@ where
|
||||
) -> Result<Vec<Hash256>, BeaconStateError> {
|
||||
self.get_block_roots(start_slot, count)
|
||||
}
|
||||
|
||||
fn is_new_block_root(&self, beacon_block_root: &Hash256) -> Result<bool, BeaconChainError> {
|
||||
self.is_new_block_root(beacon_block_root)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user