mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 21:34:46 +00:00
Rename RPC reqeusts, correct RPC internals
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
use super::methods::HelloResponse;
|
||||
use super::methods::{RPCMethod, RPCRequest, RPCResponse};
|
||||
//use crate::rpc_proto;
|
||||
//use byteorder::{BigEndian, ByteOrder};
|
||||
//use bytes::BytesMut;
|
||||
use futures::{future, stream, Future, Stream};
|
||||
use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, PeerId, UpgradeInfo};
|
||||
//use std::{io, iter};
|
||||
use super::methods::{HelloBody, RPCMethod, RPCRequest, RPCResponse};
|
||||
use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use ssz::{ssz_encode, Decodable, Encodable, SszStream};
|
||||
use std::io;
|
||||
use std::iter;
|
||||
@@ -83,7 +77,10 @@ fn decode(packet: Vec<u8>) -> Result<RpcEvent, DecodeError> {
|
||||
|
||||
if request {
|
||||
let body = match RPCMethod::from(method_id) {
|
||||
RPCMethod::Hello => RPCRequest::HelloRequest,
|
||||
RPCMethod::Hello => {
|
||||
let (hello_body, _index) = HelloBody::ssz_decode(&packet, index)?;
|
||||
RPCRequest::Hello(hello_body)
|
||||
}
|
||||
RPCMethod::Unknown => return Err(DecodeError::UnknownRPCMethod),
|
||||
};
|
||||
|
||||
@@ -97,8 +94,8 @@ fn decode(packet: Vec<u8>) -> Result<RpcEvent, DecodeError> {
|
||||
else {
|
||||
let result = match RPCMethod::from(method_id) {
|
||||
RPCMethod::Hello => {
|
||||
let (hello_response, _index) = HelloResponse::ssz_decode(&packet, index)?;
|
||||
RPCResponse::HelloResponse(hello_response)
|
||||
let (body, _index) = HelloBody::ssz_decode(&packet, index)?;
|
||||
RPCResponse::Hello(body)
|
||||
}
|
||||
RPCMethod::Unknown => return Err(DecodeError::UnknownRPCMethod),
|
||||
};
|
||||
@@ -137,8 +134,8 @@ impl Encodable for RpcEvent {
|
||||
s.append(id);
|
||||
s.append(method_id);
|
||||
match body {
|
||||
RPCRequest::HelloRequest => {}
|
||||
}
|
||||
RPCRequest::Hello(body) => s.append(body),
|
||||
};
|
||||
}
|
||||
RpcEvent::Response {
|
||||
id,
|
||||
@@ -149,7 +146,7 @@ impl Encodable for RpcEvent {
|
||||
s.append(id);
|
||||
s.append(method_id);
|
||||
match result {
|
||||
RPCResponse::HelloResponse(response) => {
|
||||
RPCResponse::Hello(response) => {
|
||||
s.append(response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user