Implement BeaconBlockBodies RPC method

This commit is contained in:
Age Manning 2019-03-21 11:16:09 +11:00
parent 56cd77ead8
commit 3063d5eac9
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93

View File

@ -95,6 +95,11 @@ fn decode(packet: Vec<u8>) -> Result<RPCEvent, DecodeError> {
BeaconBlockHeadersRequest::ssz_decode(&packet, index)?;
RPCRequest::BeaconBlockHeaders(block_headers_request)
}
RPCMethod::BeaconBlockBodies => {
let (block_bodies_request, _index) =
BeaconBlockBodiesRequest::ssz_decode(&packet, index)?;
RPCRequest::BeaconBlockBodies(block_bodies_request)
}
RPCMethod::Unknown | _ => return Err(DecodeError::UnknownRPCMethod),
};
@ -120,6 +125,10 @@ fn decode(packet: Vec<u8>) -> Result<RPCEvent, DecodeError> {
let (body, _index) = BeaconBlockHeadersResponse::ssz_decode(&packet, index)?;
RPCResponse::BeaconBlockHeaders(body)
}
RPCMethod::BeaconBlockBodies => {
let (body, _index) = BeaconBlockBodiesResponse::ssz_decode(&packet, index)?;
RPCResponse::BeaconBlockBodies(body)
}
RPCMethod::Unknown | _ => return Err(DecodeError::UnknownRPCMethod),
};
Ok(RPCEvent::Response {