Implement skeleton network/sync framework.

This commit is contained in:
Age Manning
2019-03-04 18:31:01 +11:00
parent 3b8f29a914
commit b68adc1ae3
16 changed files with 147 additions and 39 deletions

View File

@@ -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,
}

View File

@@ -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,
}
}
}