Trait ethcore_light::net::IoContext
[−]
[src]
pub trait IoContext { fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>); fn respond(&self, packet_id: u8, packet_body: Vec<u8>); fn disconnect_peer(&self, peer: PeerId); fn disable_peer(&self, peer: PeerId); fn protocol_version(&self, peer: PeerId) -> Option<u8>; fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>; }
An I/O context which allows sending and receiving packets as well as disconnecting peers. This is used as a generalization of the portions of a p2p network which the light protocol structure makes use of.
Required Methods
fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>)
Send a packet to a specific peer.
fn respond(&self, packet_id: u8, packet_body: Vec<u8>)
Respond to a peer's message. Only works if this context is a byproduct of a packet handler.
fn disconnect_peer(&self, peer: PeerId)
Disconnect a peer.
fn disable_peer(&self, peer: PeerId)
Disable a peer -- this is a disconnect + a time-out.
fn protocol_version(&self, peer: PeerId) -> Option<u8>
Get a peer's protocol version.
fn persistent_peer_id(&self, peer: PeerId) -> Option<NodeId>
Persistent peer id
Implementors
impl<'a> IoContext for NetworkContext<'a>