pub fn apply_tx(&mut self, t: &Tx<E>) -> Option<TxAccountChanges<E>> {
        let dst_init = self.remove(&t.action.dst)?;
        let src_init = self.remove(&t.src)?;
        let src_final = {
            let mut src = src_init.clone();
            if src.amt < t.action.amt || src.next_tx_no != t.action.tx_no {
                return None;
            }
            src.amt = src.amt.checked_sub(t.action.amt)?;
            src.next_tx_no = src.next_tx_no.checked_add(1)?;
            src
        };
        let dst_final = {
            let mut dst = dst_init.clone();
            dst.amt = dst.amt.checked_add(t.action.amt)?;
            dst
        };
        self.insert(src_final.clone());
        self.insert(dst_final.clone());
        Some(TxAccountChanges {
            src_init,
            src_final,
            dst_init,
            dst_final,
        })
    }
/// Applies this transaction to the accounts:
///    * mutating the state and
///    * returning the changes made
Applies this transaction to the accounts:
mutating the state and
returning the changes made
Applies this transaction to the accounts : mutating the state and returning the changes made
pub fn apply_tx(&mut self, t: &Tx<E>) -> Option<TxAccountChanges<E>> {
        let dst_init = self.remove(&t.action.dst)?;
        let src_init = self.remove(&t.src)?;
        let src_final = {
            let mut src = src_init.clone();
            if src.amt < t.action.amt || src.next_tx_no != t.action.tx_no {
                return None;
            }
            src.amt = src.amt.checked_sub(t.action.amt)?;
            src.next_tx_no = src.next_tx_no.checked_add(1)?;
            src
        };
        let dst_final = {
            let mut dst = dst_init.clone();
            dst.amt = dst.amt.checked_add(t.action.amt)?;
            dst
        };
        self.insert(src_final.clone());
        self.insert(dst_final.clone());
        Some(TxAccountChanges {
            src_init,
            src_final,
            dst_init,
            dst_final,
        })
    }
pub fn apply_tx ( & mut self , t : & Tx < E > ) -> Option < TxAccountChanges < E > > { let dst_init = self . remove ( & t . action . dst ) ? ; let src_init = self . remove ( & t . src ) ? ; let src_final = { let mut src = src_init . clone ( ) ; if src . amt < t . action . amt || src . next_tx_no != t . action . tx_no { return None ; } src . amt = src . amt . checked_sub ( t . action . amt ) ? ; src . next_tx_no = src . next_tx_no . checked_add ( 1 ) ? ; src } ; let dst_final = { let mut dst = dst_init . clone ( ) ; dst . amt = dst . amt . checked_add ( t . action . amt ) ? ; dst } ; self . insert ( src_final . clone ( ) ) ; self . insert ( dst_final . clone ( ) ) ; Some ( TxAccountChanges { src_init , src_final , dst_init , dst_final , } ) }
Applies this transaction to the accounts:
 mutating the state and
 returning the changes made
Applies this transaction to the accounts : mutating the state and returning the changes made
&mut self
t
&Tx<E>
&mut self
t
&Tx<E>