mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 20:22:02 +00:00
Implement skeleton network/sync framework.
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
/// Stores the various syncing methods for the beacon chain.
|
||||
mod simple_sync;
|
||||
|
||||
pub use crate::SimpleSync;
|
||||
pub use simple_sync::SimpleSync;
|
||||
|
||||
/// Currently implemented sync methods.
|
||||
pub enum SyncMethod {
|
||||
SimpleSync,
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use libp2p::PeerId;
|
||||
use std::collections::HashMap;
|
||||
use types::{Slot, H256};
|
||||
use types::{Hash256, Slot};
|
||||
|
||||
/// Keeps track of syncing information for known connected peers.
|
||||
pub struct PeerSyncInfo {
|
||||
best_slot: Slot,
|
||||
best_slot_hash: H256,
|
||||
best_slot_hash: Hash256,
|
||||
}
|
||||
|
||||
/// The current syncing state.
|
||||
@@ -16,7 +17,17 @@ pub enum SyncState {
|
||||
|
||||
/// Simple Syncing protocol.
|
||||
pub struct SimpleSync {
|
||||
genesis_hash: H256,
|
||||
genesis_hash: Hash256,
|
||||
known_peers: HashMap<PeerId, PeerSyncInfo>,
|
||||
state: SyncState,
|
||||
}
|
||||
|
||||
impl SimpleSync {
|
||||
pub fn new(genesis_hash: Hash256) -> Self {
|
||||
SimpleSync {
|
||||
genesis_hash,
|
||||
known_peers: HashMap::new(),
|
||||
state: SyncState::Idle,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user