pub(crate) fn handle_blocks(
    wallet: &Wallet,
    wallet_state: &WalletState,
    blocks: &[FilteredBlock],
    enclave_transactions: &[Transaction],
) -> Result<WalletStateMemento, SyncerLogicError> {
    let enclave_transactions = enclave_transactions
        .iter()
        .map(|tx| (tx.id(), tx))
        .collect::<HashMap<_, _>>();
    let mut memento = WalletStateMemento::default();

    for block in blocks {
        for tx in block.staking_transactions.iter() {
            if block.valid_transaction_ids.contains(&tx.id()) {
                handle_transaction(
                    wallet,
                    wallet_state,
                    &mut memento,
                    tx,
                    block.block_height,
                    block.block_time,
                )?;
            }
        }

        for txid in block.enclave_transaction_ids.iter() {
            if let Some(tx) = enclave_transactions.get(txid) {
                handle_transaction(
                    wallet,
                    wallet_state,
                    &mut memento,
                    tx,
                    block.block_height,
                    block.block_time,
                )?;
            }
        }
    }
    Ok(memento)
}
/// Update wallet state with batch blocks
Update wallet state with batch blocks
Update wallet state with batch blocks
pub(crate) fn handle_blocks(
    wallet: &Wallet,
    wallet_state: &WalletState,
    blocks: &[FilteredBlock],
    enclave_transactions: &[Transaction],
) -> Result<WalletStateMemento, SyncerLogicError> {
    let enclave_transactions = enclave_transactions
        .iter()
        .map(|tx| (tx.id(), tx))
        .collect::<HashMap<_, _>>();
    let mut memento = WalletStateMemento::default();
    for block in blocks {
        for tx in block.staking_transactions.iter() {
            if block.valid_transaction_ids.contains(&tx.id()) {
                handle_transaction(
                    wallet,
                    wallet_state,
                    &mut memento,
                    tx,
                    block.block_height,
                    block.block_time,
                )?;
            }
        }
        for txid in block.enclave_transaction_ids.iter() {
            if let Some(tx) = enclave_transactions.get(txid) {
                handle_transaction(
                    wallet,
                    wallet_state,
                    &mut memento,
                    tx,
                    block.block_height,
                    block.block_time,
                )?;
            }
        }
    }
    Ok(memento)
}
pub ( crate ) fn handle_blocks ( wallet : & Wallet , wallet_state : & WalletState , blocks : & [ FilteredBlock ] , enclave_transactions : & [ Transaction ] , ) -> Result < WalletStateMemento , SyncerLogicError > { let enclave_transactions = enclave_transactions . iter ( ) . map ( | tx | ( tx . id ( ) , tx ) ) . collect :: < HashMap < _ , _ > > ( ) ; let mut memento = WalletStateMemento :: default ( ) ; for block in blocks { for tx in block . staking_transactions . iter ( ) { if block . valid_transaction_ids . contains ( & tx . id ( ) ) { handle_transaction ( wallet , wallet_state , & mut memento , tx , block . block_height , block . block_time , ) ? ; } } for txid in block . enclave_transaction_ids . iter ( ) { if let Some ( tx ) = enclave_transactions . get ( txid ) { handle_transaction ( wallet , wallet_state , & mut memento , tx , block . block_height , block . block_time , ) ? ; } } } Ok ( memento ) }
Update wallet state with batch blocks
Update wallet state with batch blocks
wallet
&Wallet
wallet_state
&WalletState
blocks
&[FilteredBlock]
enclave_transactions
&[Transaction]