pub fn insert(&mut self, fork: Fork, pubkey: &Pubkey, account_info: T) -> Vec<(Fork, T)> {
        let mut rv = vec![];
        let mut fork_vec: Vec<(Fork, T)> = vec![];
        {
            let entry = self.account_maps.entry(*pubkey).or_insert(vec![]);
            std::mem::swap(entry, &mut fork_vec);
        };

        // filter out old entries
        rv.extend(fork_vec.iter().filter(|(f, _)| *f == fork).cloned());
        fork_vec.retain(|(f, _)| *f != fork);

        // add the new entry
        fork_vec.push((fork, account_info));

        rv.extend(
            fork_vec
                .iter()
                .filter(|(fork, _)| self.is_purged(*fork))
                .cloned(),
        );
        fork_vec.retain(|(fork, _)| !self.is_purged(*fork));
        {
            let entry = self.account_maps.entry(*pubkey).or_insert(vec![]);
            std::mem::swap(entry, &mut fork_vec);
        };
        rv
    }
/// Insert a new fork.
/// @retval - The return value contains any squashed accounts that can freed from storage.
Insert a new fork.
@retval - The return value contains any squashed accounts that can freed from storage.
Insert a new fork . @retval - The return value contains any squashed accounts that can freed from storage .
pub fn insert(&mut self, fork: Fork, pubkey: &Pubkey, account_info: T) -> Vec<(Fork, T)> {
        let mut rv = vec![];
        let mut fork_vec: Vec<(Fork, T)> = vec![];
        {
            let entry = self.account_maps.entry(*pubkey).or_insert(vec![]);
            std::mem::swap(entry, &mut fork_vec);
        };
        // filter out old entries
        rv.extend(fork_vec.iter().filter(|(f, _)| *f == fork).cloned());
        fork_vec.retain(|(f, _)| *f != fork);
        // add the new entry
        fork_vec.push((fork, account_info));
        rv.extend(
            fork_vec
                .iter()
                .filter(|(fork, _)| self.is_purged(*fork))
                .cloned(),
        );
        fork_vec.retain(|(fork, _)| !self.is_purged(*fork));
        {
            let entry = self.account_maps.entry(*pubkey).or_insert(vec![]);
            std::mem::swap(entry, &mut fork_vec);
        };
        rv
    }
pub fn insert ( & mut self , fork : Fork , pubkey : & Pubkey , account_info : T ) -> Vec < ( Fork , T ) > { let mut rv = vec ! [ ] ; let mut fork_vec : Vec < ( Fork , T ) > = vec ! [ ] ; { let entry = self . account_maps . entry ( * pubkey ) . or_insert ( vec ! [ ] ) ; std :: mem :: swap ( entry , & mut fork_vec ) ; } ; // filter out old entries rv . extend ( fork_vec . iter ( ) . filter ( | ( f , _ ) | * f == fork ) . cloned ( ) ) ; fork_vec . retain ( | ( f , _ ) | * f != fork ) ; // add the new entry fork_vec . push ( ( fork , account_info ) ) ; rv . extend ( fork_vec . iter ( ) . filter ( | ( fork , _ ) | self . is_purged ( * fork ) ) . cloned ( ) , ) ; fork_vec . retain ( | ( fork , _ ) | ! self . is_purged ( * fork ) ) ; { let entry = self . account_maps . entry ( * pubkey ) . or_insert ( vec ! [ ] ) ; std :: mem :: swap ( entry , & mut fork_vec ) ; } ; rv }
Insert a new fork.
Insert a new fork .
&mut self
fork
Fork
pubkey
&Pubkey
account_info
T
&mut self
fork
Fork
pubkey
&Pubkey
account_info
T