Initial handling RPC responses
This commit is contained in:
parent
2657dc1465
commit
67c09021f0
@ -8,7 +8,7 @@ use futures::future;
|
|||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
rpc::{RPCMethod, RPCRequest, RPCResponse},
|
rpc::{RPCMethod, RPCRequest, RPCResponse},
|
||||||
PeerId, RPCEvent,
|
HelloMessage, PeerId, RPCEvent,
|
||||||
};
|
};
|
||||||
use slog::warn;
|
use slog::warn;
|
||||||
use slog::{debug, trace};
|
use slog::{debug, trace};
|
||||||
@ -115,7 +115,7 @@ impl MessageHandler {
|
|||||||
match rpc_message {
|
match rpc_message {
|
||||||
RPCEvent::Request {
|
RPCEvent::Request {
|
||||||
id,
|
id,
|
||||||
method_id: _,
|
method_id: _, // TODO: Clean up RPC Message types, have a cleaner type by this point.
|
||||||
body,
|
body,
|
||||||
} => self.handle_rpc_request(peer_id, id, body),
|
} => self.handle_rpc_request(peer_id, id, body),
|
||||||
RPCEvent::Response {
|
RPCEvent::Response {
|
||||||
@ -126,11 +126,31 @@ impl MessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_rpc_request(&mut self, peer_id: PeerId, id: u64, request: RPCRequest) {}
|
/// A new RPC request has been received from the network.
|
||||||
|
fn handle_rpc_request(&mut self, peer_id: PeerId, id: u64, request: RPCRequest) {
|
||||||
|
match request {
|
||||||
|
RPCRequest::Hello(hello_message) => {
|
||||||
|
self.handle_hello_response(peer_id, id, hello_message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An RPC response has been received from the network.
|
||||||
// we match on id and ignore responses past the timeout.
|
// we match on id and ignore responses past the timeout.
|
||||||
fn handle_rpc_response(&mut self, peer_id: PeerId, id: u64, response: RPCResponse) {}
|
fn handle_rpc_response(&mut self, peer_id: PeerId, id: u64, response: RPCResponse) {}
|
||||||
|
|
||||||
|
fn handle_hello_response(&mut self, peer_id: PeerId, id: u64, response: HelloMessage) {
|
||||||
|
/*
|
||||||
|
// if response id is not in our list, ignore (likely RPC timeout)
|
||||||
|
match self.requests.get(peer_id) {
|
||||||
|
None => return;
|
||||||
|
Some(rpc_info) => {
|
||||||
|
if rpc_info.con
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// Sends a HELLO RPC request to a newly connected peer.
|
/// Sends a HELLO RPC request to a newly connected peer.
|
||||||
fn send_hello_request(&mut self, peer_id: PeerId) {
|
fn send_hello_request(&mut self, peer_id: PeerId) {
|
||||||
// generate a unique id for the peer
|
// generate a unique id for the peer
|
||||||
|
Loading…
Reference in New Issue
Block a user