Struct ethcore_network::NetworkContext
[−]
[src]
pub struct NetworkContext<'s> { /* fields omitted */ }
IO access point. This is passed to all IO handlers and provides an interface to the IO subsystem.
Methods
impl<'s> NetworkContext<'s>
[src]
fn send(&self,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>
Send a packet over the network to another peer.
fn send_protocol(&self,
protocol: ProtocolId,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>
protocol: ProtocolId,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>
Send a packet over the network to another peer using specified protocol.
fn respond(&self,
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>
packet_id: PacketId,
data: Vec<u8>)
-> Result<(), NetworkError>
Respond to a current network message. Panics if no there is no packet in the context. If the session is expired returns nothing.
fn io_channel(&self) -> IoChannel<NetworkIoMessage>
Get an IoChannel.
fn disable_peer(&self, peer: PeerId)
Disconnect a peer and prevent it from connecting again.
fn disconnect_peer(&self, peer: PeerId)
Disconnect peer. Reconnect can be attempted later.
fn is_expired(&self) -> bool
Check if the session is still active.
fn register_timer(&self, token: TimerToken, ms: u64) -> Result<(), NetworkError>
Register a new IO timer. 'IoHandler::timeout' will be called with the token.
fn peer_client_version(&self, peer: PeerId) -> String
Returns peer identification string
fn session_info(&self, peer: PeerId) -> Option<SessionInfo>
Returns information on p2p session
fn protocol_version(&self, protocol: ProtocolId, peer: PeerId) -> Option<u8>
Returns max version for a given protocol.
fn subprotocol_name(&self) -> ProtocolId
Returns this object's subprotocol name.