Struct libp2p_bitswap::Bitswap
source · [−]pub struct Bitswap<P: StoreParams> { /* private fields */ }Expand description
Network behaviour that handles sending and receiving blocks.
Implementations
sourceimpl<P: StoreParams> Bitswap<P>
impl<P: StoreParams> Bitswap<P>
sourcepub fn new<S: BitswapStore<Params = P>>(config: BitswapConfig, store: S) -> Self
pub fn new<S: BitswapStore<Params = P>>(config: BitswapConfig, store: S) -> Self
Creates a new Bitswap behaviour.
sourcepub fn add_address(&mut self, peer_id: &PeerId, addr: Multiaddr)
pub fn add_address(&mut self, peer_id: &PeerId, addr: Multiaddr)
Adds an address for a peer.
sourcepub fn remove_address(&mut self, peer_id: &PeerId, addr: &Multiaddr)
pub fn remove_address(&mut self, peer_id: &PeerId, addr: &Multiaddr)
Removes an address for a peer.
sourcepub fn get(&mut self, cid: Cid, peers: impl Iterator<Item = PeerId>) -> QueryId
pub fn get(&mut self, cid: Cid, peers: impl Iterator<Item = PeerId>) -> QueryId
Starts a get query with an initial guess of providers.
sourcepub fn sync(
&mut self,
cid: Cid,
peers: Vec<PeerId>,
missing: impl Iterator<Item = Cid>
) -> QueryId
pub fn sync(
&mut self,
cid: Cid,
peers: Vec<PeerId>,
missing: impl Iterator<Item = Cid>
) -> QueryId
Starts a sync query with an the initial set of missing blocks.
sourcepub fn cancel(&mut self, id: QueryId) -> bool
pub fn cancel(&mut self, id: QueryId) -> bool
Cancels an in progress query. Returns true if a query was cancelled.
sourcepub fn register_metrics(&self, registry: &Registry) -> Result<()>
pub fn register_metrics(&self, registry: &Registry) -> Result<()>
Registers prometheus metrics.
Trait Implementations
sourceimpl<P: StoreParams> NetworkBehaviour for Bitswap<P>
impl<P: StoreParams> NetworkBehaviour for Bitswap<P>
type ConnectionHandler = <RequestResponse<BitswapCodec<P>> as NetworkBehaviour>::ConnectionHandler
type ConnectionHandler = <RequestResponse<BitswapCodec<P>> as NetworkBehaviour>::ConnectionHandler
Handler for all the protocols the network behaviour supports.
type OutEvent = BitswapEvent
type OutEvent = BitswapEvent
Event generated by the NetworkBehaviour and that the swarm will report back.
sourcefn new_handler(&mut self) -> Self::ConnectionHandler
fn new_handler(&mut self) -> Self::ConnectionHandler
Creates a new [ConnectionHandler] for a connection with a peer. Read more
sourcefn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Addresses that this behaviour is aware of for this specific peer, and that may allow reaching the peer. Read more
sourcefn inject_connection_established(
&mut self,
peer_id: &PeerId,
conn: &ConnectionId,
endpoint: &ConnectedPoint,
failed_addressses: Option<&Vec<Multiaddr>>,
other_established: usize
)
fn inject_connection_established(
&mut self,
peer_id: &PeerId,
conn: &ConnectionId,
endpoint: &ConnectedPoint,
failed_addressses: Option<&Vec<Multiaddr>>,
other_established: usize
)
Informs the behaviour about a newly established connection to a peer.
sourcefn inject_connection_closed(
&mut self,
peer_id: &PeerId,
conn: &ConnectionId,
endpoint: &ConnectedPoint,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
remaining_established: usize
)
fn inject_connection_closed(
&mut self,
peer_id: &PeerId,
conn: &ConnectionId,
endpoint: &ConnectedPoint,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
remaining_established: usize
)
Informs the behaviour about a closed connection to a peer. Read more
sourcefn inject_dial_failure(
&mut self,
peer_id: Option<PeerId>,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
error: &DialError
)
fn inject_dial_failure(
&mut self,
peer_id: Option<PeerId>,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
error: &DialError
)
Indicates to the behaviour that the dial to a known or unknown node failed.
sourcefn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
Indicates to the behaviour that we have started listening on a new multiaddr.
sourcefn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
Indicates to the behaviour that a multiaddr we were listening on has expired, which means that we are no longer listening in it. Read more
sourcefn inject_new_external_addr(&mut self, addr: &Multiaddr)
fn inject_new_external_addr(&mut self, addr: &Multiaddr)
Indicates to the behaviour that we have discovered a new external address for us.
sourcefn inject_expired_external_addr(&mut self, addr: &Multiaddr)
fn inject_expired_external_addr(&mut self, addr: &Multiaddr)
Indicates to the behaviour that an external address was removed.
sourcefn inject_listener_error(&mut self, id: ListenerId, err: &(dyn Error + 'static))
fn inject_listener_error(&mut self, id: ListenerId, err: &(dyn Error + 'static))
A listener experienced an error.
sourcefn inject_listener_closed(&mut self, id: ListenerId, reason: Result<(), &Error>)
fn inject_listener_closed(&mut self, id: ListenerId, reason: Result<(), &Error>)
A listener closed.
sourcefn inject_event(
&mut self,
peer_id: PeerId,
conn: ConnectionId,
event: <Self::ConnectionHandler as ConnectionHandler>::OutEvent
)
fn inject_event(
&mut self,
peer_id: PeerId,
conn: ConnectionId,
event: <Self::ConnectionHandler as ConnectionHandler>::OutEvent
)
Informs the behaviour about an event generated by the handler dedicated to the peer identified by peer_id.
for the behaviour. Read more
sourcefn poll(
&mut self,
cx: &mut Context<'_>,
pp: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>>
fn poll(
&mut self,
cx: &mut Context<'_>,
pp: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>>
Polls for things that swarm should do. Read more
fn inject_address_change(
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
fn inject_address_change(
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
Informs the behaviour that the [ConnectedPoint] of an existing connection has changed.
fn inject_listen_failure(
&mut self,
_local_addr: &Multiaddr,
_send_back_addr: &Multiaddr,
_handler: Self::ConnectionHandler
)
fn inject_listen_failure(
&mut self,
_local_addr: &Multiaddr,
_send_back_addr: &Multiaddr,
_handler: Self::ConnectionHandler
)
Indicates to the behaviour that an error happened on an incoming connection during its initial handshake. Read more
fn inject_new_listener(&mut self, _id: ListenerId)
fn inject_new_listener(&mut self, _id: ListenerId)
Indicates to the behaviour that a new listener was created.
Auto Trait Implementations
impl<P> !RefUnwindSafe for Bitswap<P>
impl<P> Send for Bitswap<P>
impl<P> !Sync for Bitswap<P>
impl<P> Unpin for Bitswap<P>
impl<P> !UnwindSafe for Bitswap<P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more