3
3
//! Each chain type is stored in it's own map. A variety of helper functions are given along with
4
4
//! this struct to simplify the logic of the other layers of sync.
5
5
6
- use super :: block_storage:: BlockStorage ;
7
6
use super :: chain:: { ChainId , ProcessingResult , RemoveChain , SyncingChain } ;
8
7
use super :: sync_type:: RangeSyncType ;
9
8
use crate :: metrics;
10
9
use crate :: sync:: network_context:: SyncNetworkContext ;
11
- use beacon_chain:: BeaconChainTypes ;
10
+ use beacon_chain:: { BeaconChain , BeaconChainTypes } ;
12
11
use fnv:: FnvHashMap ;
13
12
use lighthouse_network:: PeerId ;
14
13
use lighthouse_network:: SyncInfo ;
@@ -37,10 +36,13 @@ pub enum RangeSyncState {
37
36
Idle ,
38
37
}
39
38
39
+ pub type SyncChainStatus =
40
+ Result < Option < ( RangeSyncType , Slot /* from */ , Slot /* to */ ) > , & ' static str > ;
41
+
40
42
/// A collection of finalized and head chains currently being processed.
41
- pub struct ChainCollection < T : BeaconChainTypes , C > {
43
+ pub struct ChainCollection < T : BeaconChainTypes > {
42
44
/// The beacon chain for processing.
43
- beacon_chain : Arc < C > ,
45
+ beacon_chain : Arc < BeaconChain < T > > ,
44
46
/// The set of finalized chains being synced.
45
47
finalized_chains : FnvHashMap < ChainId , SyncingChain < T > > ,
46
48
/// The set of head chains being synced.
@@ -51,8 +53,8 @@ pub struct ChainCollection<T: BeaconChainTypes, C> {
51
53
log : slog:: Logger ,
52
54
}
53
55
54
- impl < T : BeaconChainTypes , C : BlockStorage > ChainCollection < T , C > {
55
- pub fn new ( beacon_chain : Arc < C > , log : slog:: Logger ) -> Self {
56
+ impl < T : BeaconChainTypes > ChainCollection < T > {
57
+ pub fn new ( beacon_chain : Arc < BeaconChain < T > > , log : slog:: Logger ) -> Self {
56
58
ChainCollection {
57
59
beacon_chain,
58
60
finalized_chains : FnvHashMap :: default ( ) ,
@@ -213,9 +215,7 @@ impl<T: BeaconChainTypes, C: BlockStorage> ChainCollection<T, C> {
213
215
}
214
216
}
215
217
216
- pub fn state (
217
- & self ,
218
- ) -> Result < Option < ( RangeSyncType , Slot /* from */ , Slot /* to */ ) > , & ' static str > {
218
+ pub fn state ( & self ) -> SyncChainStatus {
219
219
match self . state {
220
220
RangeSyncState :: Finalized ( ref syncing_id) => {
221
221
let chain = self
@@ -409,7 +409,8 @@ impl<T: BeaconChainTypes, C: BlockStorage> ChainCollection<T, C> {
409
409
let log_ref = & self . log ;
410
410
411
411
let is_outdated = |target_slot : & Slot , target_root : & Hash256 | {
412
- target_slot <= & local_finalized_slot || beacon_chain. is_block_known ( target_root)
412
+ target_slot <= & local_finalized_slot
413
+ || beacon_chain. block_is_known_to_fork_choice ( target_root)
413
414
} ;
414
415
415
416
// Retain only head peers that remain relevant
0 commit comments