pub(crate) fn trim(
        &mut self,
        cap: usize, // Capacity hint for number of unique pubkeys.
        // Set of pubkeys to never drop.
        // e.g. known validators, self pubkey, ...
        keep: &[Pubkey],
        stakes: &HashMap<Pubkey, u64>,
        now: u64,
    ) -> Result</*num purged:*/ usize, CrdsError> {
        if self.should_trim(cap) {
            let size = self.records.len().saturating_sub(cap);
            self.drop(size, keep, stakes, now)
        } else {
            Ok(0)
        }
    }
/// Trims the table by dropping all values associated with the pubkeys with
/// the lowest stake, so that the number of unique pubkeys are bounded.
Trims the table by dropping all values associated with the pubkeys with
the lowest stake, so that the number of unique pubkeys are bounded.
Trims the table by dropping all values associated with the pubkeys with the lowest stake so that the number of unique pubkeys are bounded .
pub(crate) fn trim(
        &mut self,
        cap: usize, // Capacity hint for number of unique pubkeys.
        // Set of pubkeys to never drop.
        // e.g. known validators, self pubkey, ...
        keep: &[Pubkey],
        stakes: &HashMap<Pubkey, u64>,
        now: u64,
    ) -> Result</*num purged:*/ usize, CrdsError> {
        if self.should_trim(cap) {
            let size = self.records.len().saturating_sub(cap);
            self.drop(size, keep, stakes, now)
        } else {
            Ok(0)
        }
    }
pub ( crate ) fn trim ( & mut self , cap : usize , // Capacity hint for number of unique pubkeys. // Set of pubkeys to never drop. // e.g. known validators, self pubkey, ... keep : & [ Pubkey ] , stakes : & HashMap < Pubkey , u64 > , now : u64 , ) -> Result < /*num purged:*/ usize , CrdsError > { if self . should_trim ( cap ) { let size = self . records . len ( ) . saturating_sub ( cap ) ; self . drop ( size , keep , stakes , now ) } else { Ok ( 0 ) } }
Trims the table by dropping all values associated with the pubkeys with
the lowest stake, so that the number of unique pubkeys are bounded.
Trims the table by dropping all values associated with the pubkeys with the lowest stake so that the number of unique pubkeys are bounded .
&mut self
cap
usize
keep
&[Pubkey]
stakes
&HashMap<Pubkey, u64>
now
u64