mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 19:34:37 +00:00
Add first changes to syncing logic
- Adds testing framework - Breaks out new `NetworkContext` object
This commit is contained in:
@@ -5,6 +5,7 @@ authors = ["Age Manning <Age@AgeManning.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
beacon_chain = { path = "../beacon_chain" }
|
||||
# SigP repository until PR is merged
|
||||
libp2p = { git = "https://github.com/SigP/rust-libp2p", branch = "gossipsub" }
|
||||
types = { path = "../../eth2/types" }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use beacon_chain::parking_lot::RwLockReadGuard;
|
||||
/// Available RPC methods types and ids.
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use types::{BeaconBlockBody, BeaconBlockHeader, Epoch, Hash256, Slot};
|
||||
@@ -60,6 +61,20 @@ pub enum RPCRequest {
|
||||
BeaconChainState(BeaconChainStateRequest),
|
||||
}
|
||||
|
||||
impl RPCRequest {
|
||||
pub fn method_id(&self) -> u16 {
|
||||
let method = match self {
|
||||
RPCRequest::Hello(_) => RPCMethod::Hello,
|
||||
RPCRequest::Goodbye(_) => RPCMethod::Goodbye,
|
||||
RPCRequest::BeaconBlockRoots(_) => RPCMethod::BeaconBlockRoots,
|
||||
RPCRequest::BeaconBlockHeaders(_) => RPCMethod::BeaconBlockHeaders,
|
||||
RPCRequest::BeaconBlockBodies(_) => RPCMethod::BeaconBlockBodies,
|
||||
RPCRequest::BeaconChainState(_) => RPCMethod::BeaconChainState,
|
||||
};
|
||||
method.into()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum RPCResponse {
|
||||
Hello(HelloMessage),
|
||||
@@ -69,6 +84,19 @@ pub enum RPCResponse {
|
||||
BeaconChainState(BeaconChainStateResponse),
|
||||
}
|
||||
|
||||
impl RPCResponse {
|
||||
pub fn method_id(&self) -> u16 {
|
||||
let method = match self {
|
||||
RPCResponse::Hello(_) => RPCMethod::Hello,
|
||||
RPCResponse::BeaconBlockRoots(_) => RPCMethod::BeaconBlockRoots,
|
||||
RPCResponse::BeaconBlockHeaders(_) => RPCMethod::BeaconBlockHeaders,
|
||||
RPCResponse::BeaconBlockBodies(_) => RPCMethod::BeaconBlockBodies,
|
||||
RPCResponse::BeaconChainState(_) => RPCMethod::BeaconChainState,
|
||||
};
|
||||
method.into()
|
||||
}
|
||||
}
|
||||
|
||||
/* Request/Response data structures for RPC methods */
|
||||
|
||||
/// The HELLO request/response handshake message.
|
||||
|
||||
Reference in New Issue
Block a user