pub fn insert<K: AsRef<[u8]>>(
        &mut self,
        transaction_blockhash: &Hash,
        key: &K,
        slot: Slot,
        res: T,
    ) {
        let max_key_index = key.as_ref().len().saturating_sub(CACHED_KEY_SIZE + 1);
        let hash_map = self.cache.entry(*transaction_blockhash).or_insert_with(|| {
            let key_index = thread_rng().gen_range(0, max_key_index + 1);
            (slot, key_index, HashMap::new())
        });

        hash_map.0 = std::cmp::max(slot, hash_map.0);
        let key_index = hash_map.1.min(max_key_index);
        let mut key_slice = [0u8; CACHED_KEY_SIZE];
        key_slice.clone_from_slice(&key.as_ref()[key_index..key_index + CACHED_KEY_SIZE]);
        self.insert_with_slice(transaction_blockhash, slot, key_index, key_slice, res);
    }
/// Insert a new key for a specific slot.
Insert a new key for a specific slot.
Insert a new key for a specific slot .
pub fn insert<K: AsRef<[u8]>>(
        &mut self,
        transaction_blockhash: &Hash,
        key: &K,
        slot: Slot,
        res: T,
    ) {
        let max_key_index = key.as_ref().len().saturating_sub(CACHED_KEY_SIZE + 1);
        let hash_map = self.cache.entry(*transaction_blockhash).or_insert_with(|| {
            let key_index = thread_rng().gen_range(0, max_key_index + 1);
            (slot, key_index, HashMap::new())
        });
        hash_map.0 = std::cmp::max(slot, hash_map.0);
        let key_index = hash_map.1.min(max_key_index);
        let mut key_slice = [0u8; CACHED_KEY_SIZE];
        key_slice.clone_from_slice(&key.as_ref()[key_index..key_index + CACHED_KEY_SIZE]);
        self.insert_with_slice(transaction_blockhash, slot, key_index, key_slice, res);
    }
pub fn insert < K : AsRef < [ u8 ] > > ( & mut self , transaction_blockhash : & Hash , key : & K , slot : Slot , res : T , ) { let max_key_index = key . as_ref ( ) . len ( ) . saturating_sub ( CACHED_KEY_SIZE + 1 ) ; let hash_map = self . cache . entry ( * transaction_blockhash ) . or_insert_with ( | | { let key_index = thread_rng ( ) . gen_range ( 0 , max_key_index + 1 ) ; ( slot , key_index , HashMap :: new ( ) ) } ) ; hash_map . 0 = std :: cmp :: max ( slot , hash_map . 0 ) ; let key_index = hash_map . 1 . min ( max_key_index ) ; let mut key_slice = [ 0u8 ; CACHED_KEY_SIZE ] ; key_slice . clone_from_slice ( & key . as_ref ( ) [ key_index .. key_index + CACHED_KEY_SIZE ] ) ; self . insert_with_slice ( transaction_blockhash , slot , key_index , key_slice , res ) ; }
Insert a new key for a specific slot.
Insert a new key for a specific slot .
&mut self
transaction_blockhash
&Hash
key
&K
slot
Slot
res
T