pub struct PieceProvider<PV> { /* private fields */ }
Expand description
Piece provider with cancellation and piece validator.
Use NoPieceValidator
to disable validation.
Implementations§
source§impl<PV> PieceProvider<PV>where
PV: PieceValidator,
impl<PV> PieceProvider<PV>where
PV: PieceValidator,
sourcepub async fn get_from_cache<'a, PieceIndices>(
&'a self,
piece_indices: PieceIndices,
) -> impl Stream<Item = (PieceIndex, Option<Piece>)> + Unpin + 'awhere
PieceIndices: IntoIterator<Item = PieceIndex> + 'a,
pub async fn get_from_cache<'a, PieceIndices>(
&'a self,
piece_indices: PieceIndices,
) -> impl Stream<Item = (PieceIndex, Option<Piece>)> + Unpin + 'awhere
PieceIndices: IntoIterator<Item = PieceIndex> + 'a,
Get pieces with provided indices from cache.
Number of elements in returned stream is the same as number of unique piece_indices
.
sourcepub async fn get_piece_from_cache(
&self,
piece_index: PieceIndex,
) -> Option<Piece>
pub async fn get_piece_from_cache( &self, piece_index: PieceIndex, ) -> Option<Piece>
Returns piece by its index from farmer’s piece cache (L2)
sourcepub async fn get_piece_from_peer(
&self,
peer_id: PeerId,
piece_index: PieceIndex,
) -> Option<Piece>
pub async fn get_piece_from_peer( &self, peer_id: PeerId, piece_index: PieceIndex, ) -> Option<Piece>
Get piece from a particular peer.
sourcepub async fn get_piece_from_archival_storage(
&self,
piece_index: PieceIndex,
max_random_walking_rounds: usize,
) -> Option<Piece>
pub async fn get_piece_from_archival_storage( &self, piece_index: PieceIndex, max_random_walking_rounds: usize, ) -> Option<Piece>
Get piece from archival storage (L1). The algorithm tries to get a piece from currently connected peers and falls back to random walking.
Trait Implementations§
Auto Trait Implementations§
impl<PV> Freeze for PieceProvider<PV>where
PV: Freeze,
impl<PV> !RefUnwindSafe for PieceProvider<PV>
impl<PV> Send for PieceProvider<PV>where
PV: Send,
impl<PV> Sync for PieceProvider<PV>where
PV: Sync,
impl<PV> Unpin for PieceProvider<PV>where
PV: Unpin,
impl<PV> !UnwindSafe for PieceProvider<PV>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more