mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Initial Libp2p RPC implementation.
This commit is contained in:
38
beacon_node/libp2p/src/rpc/methods.rs
Normal file
38
beacon_node/libp2p/src/rpc/methods.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
/// Available RPC methods types and ids.
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use types::{Epoch, Hash256, Slot};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RPCMethod {
|
||||
Hello,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl From<u16> for RPCMethod {
|
||||
fn from(method_id: u16) -> Self {
|
||||
match method_id {
|
||||
0 => RPCMethod::Hello,
|
||||
_ => RPCMethod::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum RPCRequest {
|
||||
HelloRequest,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum RPCResponse {
|
||||
HelloResponse(HelloResponse),
|
||||
}
|
||||
|
||||
// request/response structs for RPC methods
|
||||
#[derive(Encode, Decode, Clone, Debug)]
|
||||
pub struct HelloResponse {
|
||||
pub network_id: u8,
|
||||
pub latest_finalized_root: Hash256,
|
||||
pub latest_finalized_epoch: Epoch,
|
||||
pub best_root: Hash256,
|
||||
pub best_slot: Slot,
|
||||
}
|
||||
Reference in New Issue
Block a user