pub fn remove_lower_nonce_withdrawals(
        &mut self,
        nonce: u32,
        capacity: CKBCapacity,
    ) -> Vec<WithdrawalRequestExtra> {
        let mut removed = Vec::default();

        // remove lower nonce withdrawals
        while !self.withdrawals.is_empty() {
            let withdrawal_nonce: u32 = self.withdrawals[0].raw().nonce().unpack();
            if withdrawal_nonce >= nonce {
                break;
            }
            removed.push(self.withdrawals.remove(0));
        }

        // remove lower balance withdrawals
        if let Some(withdrawal) = self.withdrawals.get(0) {
            let withdrawal_capacity: u64 = withdrawal.raw().capacity().unpack();
            let capacity = capacity.to_layer1().unwrap();
            if withdrawal_capacity > capacity {
                // TODO instead of remove all withdrawals, put them into future queue
                removed.extend_from_slice(&self.withdrawals);
                self.withdrawals.clear();
            }
        }

        removed
    }
// remove and return withdrawals which withdrawal.nonce is lower than nonce & have not enough balance
remove and return withdrawals which withdrawal.nonce is lower than nonce & have not enough balance
remove and return withdrawals which withdrawal . nonce is lower than nonce & have not enough balance
pub fn remove_lower_nonce_withdrawals(
        &mut self,
        nonce: u32,
        capacity: CKBCapacity,
    ) -> Vec<WithdrawalRequestExtra> {
        let mut removed = Vec::default();
        // remove lower nonce withdrawals
        while !self.withdrawals.is_empty() {
            let withdrawal_nonce: u32 = self.withdrawals[0].raw().nonce().unpack();
            if withdrawal_nonce >= nonce {
                break;
            }
            removed.push(self.withdrawals.remove(0));
        }
        // remove lower balance withdrawals
        if let Some(withdrawal) = self.withdrawals.get(0) {
            let withdrawal_capacity: u64 = withdrawal.raw().capacity().unpack();
            let capacity = capacity.to_layer1().unwrap();
            if withdrawal_capacity > capacity {
                // TODO instead of remove all withdrawals, put them into future queue
                removed.extend_from_slice(&self.withdrawals);
                self.withdrawals.clear();
            }
        }
        removed
    }
pub fn remove_lower_nonce_withdrawals ( & mut self , nonce : u32 , capacity : CKBCapacity , ) -> Vec < WithdrawalRequestExtra > { let mut removed = Vec :: default ( ) ; // remove lower nonce withdrawals while ! self . withdrawals . is_empty ( ) { let withdrawal_nonce : u32 = self . withdrawals [ 0 ] . raw ( ) . nonce ( ) . unpack ( ) ; if withdrawal_nonce >= nonce { break ; } removed . push ( self . withdrawals . remove ( 0 ) ) ; } // remove lower balance withdrawals if let Some ( withdrawal ) = self . withdrawals . get ( 0 ) { let withdrawal_capacity : u64 = withdrawal . raw ( ) . capacity ( ) . unpack ( ) ; let capacity = capacity . to_layer1 ( ) . unwrap ( ) ; if withdrawal_capacity > capacity { // TODO instead of remove all withdrawals, put them into future queue removed . extend_from_slice ( & self . withdrawals ) ; self . withdrawals . clear ( ) ; } } removed }
remove and return withdrawals which withdrawal.nonce is lower than nonce & have not enough balance
remove and return withdrawals which withdrawal . nonce is lower than nonce & have not enough balance
&mut self
nonce
u32
capacity
CKBCapacity
&mut self
nonce
u32
capacity
CKBCapacity