fn should_skip_retransmit(shred: &Shred, shreds_received: &Mutex<ShredFilterAndHasher>) -> bool {
    let key = (shred.slot(), shred.index(), shred.is_data());
    let mut shreds_received = shreds_received.lock().unwrap();
    let (cache, hasher) = shreds_received.deref_mut();
    match cache.get_mut(&key) {
        Some(sent) if sent.len() >= MAX_DUPLICATE_COUNT => true,
        Some(sent) => {
            let hash = hasher.hash_shred(shred);
            if sent.contains(&hash) {
                true
            } else {
                sent.push(hash);
                false
            }
        }
        None => {
            let hash = hasher.hash_shred(shred);
            cache.put(key, vec![hash]);
            false
        }
    }
}
// Returns true if shred is already received and should skip retransmit.
Returns true if shred is already received and should skip retransmit.
Returns true if shred is already received and should skip retransmit .
fn should_skip_retransmit(shred: &Shred, shreds_received: &Mutex<ShredFilterAndHasher>) -> bool {
    let key = (shred.slot(), shred.index(), shred.is_data());
    let mut shreds_received = shreds_received.lock().unwrap();
    let (cache, hasher) = shreds_received.deref_mut();
    match cache.get_mut(&key) {
        Some(sent) if sent.len() >= MAX_DUPLICATE_COUNT => true,
        Some(sent) => {
            let hash = hasher.hash_shred(shred);
            if sent.contains(&hash) {
                true
            } else {
                sent.push(hash);
                false
            }
        }
        None => {
            let hash = hasher.hash_shred(shred);
            cache.put(key, vec![hash]);
            false
        }
    }
}
fn should_skip_retransmit ( shred : & Shred , shreds_received : & Mutex < ShredFilterAndHasher > ) -> bool { let key = ( shred . slot ( ) , shred . index ( ) , shred . is_data ( ) ) ; let mut shreds_received = shreds_received . lock ( ) . unwrap ( ) ; let ( cache , hasher ) = shreds_received . deref_mut ( ) ; match cache . get_mut ( & key ) { Some ( sent ) if sent . len ( ) >= MAX_DUPLICATE_COUNT => true , Some ( sent ) => { let hash = hasher . hash_shred ( shred ) ; if sent . contains ( & hash ) { true } else { sent . push ( hash ) ; false } } None => { let hash = hasher . hash_shred ( shred ) ; cache . put ( key , vec ! [ hash ] ) ; false } } }
Returns true if shred is already received and should skip retransmit.
Returns true if shred is already received and should skip retransmit .
shred
&Shred
shreds_received
&Mutex<ShredFilterAndHasher>
shred
&Shred
shreds_received
&Mutex<ShredFilterAndHasher>