/// Resolve a transaction
/// A transaction can only be resolved by whoever issued it.
/// If the transaction is not under dispute, it does nothing.
Resolve a transaction
A transaction can only be resolved by whoever issued it.
If the transaction is not under dispute, it does nothing.
Resolve a transaction A transaction can only be resolved by whoever issued it . If the transaction is not under dispute it does nothing .
fn resolve(client: &mut Client, tx: u32, tx_hist: &mut TransactionLog) -> bool {
    match tx_hist.find(tx) {
        Some(transaction) => {
            // make sure the transaction was issued by the client making this request
            if client.id() != transaction.client {
                log::warn!("unauthorized client tried to resolve transaction {}", tx);
                return false;
            }
            if transaction.under_dispute() {
                if let Err(_) = client.release(transaction.amount) {
                    log::warn!("Insufficient held funds to resolve transaction {}", tx);
                    return false;
                }
                tx_hist.undispute(tx);
            } else {
                log::debug!(
                    "transaction {} isn't under dispute. It cannot be resolved.",
                    tx
                );
                return false;
            }
        }
        None => {
            log::debug!("Invalid transaction number");
            return false;
        }
    }
    log::trace!(
        "resolving dispute on transaction {} made by client {}",
        tx,
        client.id()
    );
    true
}
fn resolve ( client : & mut Client , tx : u32 , tx_hist : & mut TransactionLog ) -> bool { match tx_hist . find ( tx ) { Some ( transaction ) => { // make sure the transaction was issued by the client making this request if client . id ( ) != transaction . client { log :: warn ! ( " " tx ) ; return false ; } if transaction . under_dispute ( ) { if let Err ( _ ) = client . release ( transaction . amount ) { log :: warn ! ( " " tx ) ; return false ; } tx_hist . undispute ( tx ) ; } else { log :: debug ! ( " " tx ) ; return false ; } } None => { log :: debug ! ( " " ) ; return false ; } } log :: trace ! ( " " tx client id ( ) ) ; true }
Resolve a transaction
A transaction can only be resolved by whoever issued it.
Resolve a transaction A transaction can only be resolved by whoever issued it .
client
&mut Client
tx
u32
tx_hist
&mut TransactionLog