pub struct GapAwarePieceSelector { /* private fields */ }Expand description
BEP-19 piece selection strategy.
Modifies “rarest first” to create gaps that HTTP/FTP can fill efficiently.
Implementations§
Source§impl GapAwarePieceSelector
impl GapAwarePieceSelector
Sourcepub fn set_peer_count(&mut self, count: usize)
pub fn set_peer_count(&mut self, count: usize)
Updates the peer count.
Sourcepub fn select_piece(
&self,
piece_availability: &[usize],
our_pieces: &[bool],
peer_pieces: &[bool],
) -> Option<u32>
pub fn select_piece( &self, piece_availability: &[usize], our_pieces: &[bool], peer_pieces: &[bool], ) -> Option<u32>
Selects a piece using BEP-19 gap-aware strategy.
Priority logic:
- If piece_rarity < (cur_rarest - X), select it
- Else if piece_rarity <= (cur_rarest + X) AND gap > cur_gap, select it
Arguments:
piece_availability: For each piece, how many peers have itour_pieces: Which pieces we already havepeer_pieces: Which pieces the current peer has
Returns: Selected piece index, or None if no suitable piece found
Sourcepub fn select_gap_filling_piece(
&self,
our_pieces: &[bool],
peer_pieces: &[bool],
) -> Option<u32>
pub fn select_gap_filling_piece( &self, our_pieces: &[bool], peer_pieces: &[bool], ) -> Option<u32>
Selects a piece for gap-filling mode (used when > 50% complete).
Finds the piece with the smallest gap to a completed section.
Sourcepub fn should_use_gap_filling(&self, our_pieces: &[bool]) -> bool
pub fn should_use_gap_filling(&self, our_pieces: &[bool]) -> bool
Returns true if we should use gap-filling mode.
Gap-filling is activated when completion > 50%.
Trait Implementations§
Source§impl Clone for GapAwarePieceSelector
impl Clone for GapAwarePieceSelector
Source§fn clone(&self) -> GapAwarePieceSelector
fn clone(&self) -> GapAwarePieceSelector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GapAwarePieceSelector
impl RefUnwindSafe for GapAwarePieceSelector
impl Send for GapAwarePieceSelector
impl Sync for GapAwarePieceSelector
impl Unpin for GapAwarePieceSelector
impl UnwindSafe for GapAwarePieceSelector
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