mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Remove sync crate, move into network crate
This commit is contained in:
11
beacon_node/network/src/sync/mod.rs
Normal file
11
beacon_node/network/src/sync/mod.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
/// Syncing for lighthouse.
|
||||
///
|
||||
/// Stores the various syncing methods for the beacon chain.
|
||||
mod simple_sync;
|
||||
|
||||
pub use simple_sync::SimpleSync;
|
||||
|
||||
/// Currently implemented sync methods.
|
||||
pub enum SyncMethod {
|
||||
SimpleSync,
|
||||
}
|
||||
39
beacon_node/network/src/sync/simple_sync.rs
Normal file
39
beacon_node/network/src/sync/simple_sync.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use crate::beacon_chain::BeaconChain;
|
||||
use libp2p::PeerId;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use types::{Epoch, Hash256, Slot};
|
||||
|
||||
/// Keeps track of syncing information for known connected peers.
|
||||
pub struct PeerSyncInfo {
|
||||
latest_finalized_root: Hash256,
|
||||
latest_finalized_epoch: Epoch,
|
||||
best_root: Hash256,
|
||||
best_slot: Slot,
|
||||
}
|
||||
|
||||
/// The current syncing state.
|
||||
pub enum SyncState {
|
||||
Idle,
|
||||
Downloading,
|
||||
Stopped,
|
||||
}
|
||||
|
||||
/// Simple Syncing protocol.
|
||||
//TODO: Decide for HELLO messages whether its better to keep current in RAM or build on the fly
|
||||
//when asked.
|
||||
pub struct SimpleSync {
|
||||
known_peers: HashMap<PeerId, PeerSyncInfo>,
|
||||
state: SyncState,
|
||||
network_id: u8,
|
||||
}
|
||||
|
||||
impl SimpleSync {
|
||||
pub fn new(beacon_chain: Arc<BeaconChain>) -> Self {
|
||||
SimpleSync {
|
||||
known_peers: HashMap::new(),
|
||||
state: SyncState::Idle,
|
||||
network_id: beacon_chain.get_spec().network_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user