Struct vapcore_light::net::LightProtocol [−][src]
This is an implementation of the light vapory network protocol, abstracted
over a Provider
of data and a p2p network.
This is simply designed for request-response purposes. Higher level uses of the protocol, such as synchronization, will function as wrappers around this system.
Implementations
impl LightProtocol
[src]
pub fn new(provider: Arc<dyn Provider>, params: Params) -> Self
[src]
Create a new instance of the protocol manager.
pub fn peer_status(&self, peer: PeerId) -> Option<Status>
[src]
Attempt to get peer status.
pub fn peer_count(&self) -> (usize, usize)
[src]
Get number of (connected, active) peers.
pub fn leecher_count(&self) -> usize
[src]
Get the number of active light peers downloading from the node
pub fn request_from(
&self,
io: &dyn IoContext,
peer_id: PeerId,
requests: Requests
) -> Result<ReqId, Error>
[src]
&self,
io: &dyn IoContext,
peer_id: PeerId,
requests: Requests
) -> Result<ReqId, Error>
Make a request to a peer.
Fails on: nonexistent peer, network error, peer not server, insufficient credits. Does not check capabilities before sending. On success, returns a request id which can later be coordinated with an event.
pub fn make_announcement(&self, io: &dyn IoContext, announcement: Announcement)
[src]
Make an announcement of new chain head and capabilities to all peers. The announcement is expected to be valid.
pub fn add_handler(&mut self, handler: Arc<dyn Handler>)
[src]
Add an event handler.
These are intended to be added when the protocol structure is initialized as a means of customizing its behavior, and dispatching requests immediately upon events.
pub fn abort(&self)
[src]
Signal to handlers that network activity is being aborted and clear peer data.
pub fn handle_packet(
&self,
io: &dyn IoContext,
peer: PeerId,
packet_id: u8,
data: &[u8]
)
[src]
&self,
io: &dyn IoContext,
peer: PeerId,
packet_id: u8,
data: &[u8]
)
Handle a packet using the given io context. Packet data is untrusted, which means that invalid data won’t lead to issues.
pub fn on_connect(&self, peer: PeerId, io: &dyn IoContext)
[src]
called when a peer connects.
pub fn on_disconnect(&self, peer: PeerId, io: &dyn IoContext)
[src]
called when a peer disconnects.
pub fn with_context<F, T>(&self, io: &dyn IoContext, f: F) -> T where
F: FnOnce(&dyn BasicContext) -> T,
[src]
F: FnOnce(&dyn BasicContext) -> T,
Execute the given closure with a basic context derived from the I/O context.
Trait Implementations
impl NetworkProtocolHandler for LightProtocol
[src]
fn initialize(&self, io: &dyn NetworkContext)
[src]
fn read(
&self,
io: &dyn NetworkContext,
peer: &PeerId,
packet_id: u8,
data: &[u8]
)
[src]
&self,
io: &dyn NetworkContext,
peer: &PeerId,
packet_id: u8,
data: &[u8]
)
fn connected(&self, io: &dyn NetworkContext, peer: &PeerId)
[src]
fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId)
[src]
fn timeout(&self, io: &dyn NetworkContext, timer: TimerToken)
[src]
Auto Trait Implementations
impl !RefUnwindSafe for LightProtocol
impl Send for LightProtocol
impl Sync for LightProtocol
impl Unpin for LightProtocol
impl !UnwindSafe for LightProtocol
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,