Struct ethcore_network_devp2p::NetworkContext
source · [−]pub struct NetworkContext<'s> { /* private fields */ }
Expand description
IO access point. This is passed to all IO handlers and provides an interface to the IO subsystem.
Trait Implementations
sourceimpl<'s> NetworkContext for NetworkContext<'s>
impl<'s> NetworkContext for NetworkContext<'s>
sourcefn send(
&self,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>
) -> Result<(), Error>
fn send(
&self,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>
) -> Result<(), Error>
Send a packet over the network to another peer.
sourcefn send_protocol(
&self,
protocol: ProtocolId,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>
) -> Result<(), Error>
fn send_protocol(
&self,
protocol: ProtocolId,
peer: PeerId,
packet_id: PacketId,
data: Vec<u8>
) -> Result<(), Error>
Send a packet over the network to another peer using specified protocol.
sourcefn respond(&self, packet_id: PacketId, data: Vec<u8>) -> Result<(), Error>
fn respond(&self, packet_id: PacketId, data: Vec<u8>) -> Result<(), Error>
Respond to a current network message. Panics if no there is no packet in the context. If the session is expired returns nothing.
sourcefn disable_peer(&self, peer: PeerId)
fn disable_peer(&self, peer: PeerId)
Disconnect a peer and prevent it from connecting again.
sourcefn disconnect_peer(&self, peer: PeerId)
fn disconnect_peer(&self, peer: PeerId)
Disconnect peer. Reconnect can be attempted later.
sourcefn is_expired(&self) -> bool
fn is_expired(&self) -> bool
Check if the session is still active.
sourcefn register_timer(
&self,
token: TimerToken,
delay: Duration
) -> Result<(), Error>
fn register_timer(
&self,
token: TimerToken,
delay: Duration
) -> Result<(), Error>
Register a new IO timer. ‘IoHandler::timeout’ will be called with the token.
sourcefn peer_client_version(&self, peer: PeerId) -> ClientVersion
fn peer_client_version(&self, peer: PeerId) -> ClientVersion
Returns peer identification string
sourcefn session_info(&self, peer: PeerId) -> Option<SessionInfo>
fn session_info(&self, peer: PeerId) -> Option<SessionInfo>
Returns information on p2p session
sourcefn protocol_version(&self, protocol: ProtocolId, peer: PeerId) -> Option<u8>
fn protocol_version(&self, protocol: ProtocolId, peer: PeerId) -> Option<u8>
Returns max version for a given protocol.
sourcefn subprotocol_name(&self) -> ProtocolId
fn subprotocol_name(&self) -> ProtocolId
Returns this object’s subprotocol name.
sourcefn is_reserved_peer(&self, peer: PeerId) -> bool
fn is_reserved_peer(&self, peer: PeerId) -> bool
Returns whether the given peer ID is a reserved peer.
Auto Trait Implementations
impl<'s> !RefUnwindSafe for NetworkContext<'s>
impl<'s> Send for NetworkContext<'s>
impl<'s> Sync for NetworkContext<'s>
impl<'s> Unpin for NetworkContext<'s>
impl<'s> !UnwindSafe for NetworkContext<'s>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more