@@ -419,66 +419,65 @@ impl TransactionsQueue {
419419 info ! ( "Transaction {} failed on-chain for relayer: {}" , id, self . relayer. name) ;
420420 }
421421
422- let ( winner_transaction, loser_transaction, loser_status) =
423- if comp_tx. original . id == * id {
424- let loser_status = if let Some ( ( _, comp_type) ) = & comp_tx. competitive {
425- match comp_type {
426- CompetitionType :: Cancel => TransactionStatus :: DROPPED ,
427- CompetitionType :: Replace => TransactionStatus :: DROPPED ,
428- }
429- } else {
430- TransactionStatus :: DROPPED
431- } ;
432-
433- let winner = Transaction {
434- status : transaction_status,
435- mined_at : Some ( Utc :: now ( ) ) ,
436- cancelled_by_transaction_id : None ,
437- ..comp_tx. original
438- } ;
439-
440- ( winner, comp_tx. competitive . map ( |( tx, _) | tx) , loser_status)
441- } else if let Some ( ( competitor, comp_type) ) = comp_tx. competitive {
442- let ( loser_status, loser_transaction) = match comp_type {
443- CompetitionType :: Cancel => {
444- // When cancel wins, original transaction becomes a cancelled no-op
445- let cancelled_original = Transaction {
446- status : TransactionStatus :: CANCELLED ,
447- is_noop : true ,
448- to : self . relay_address ( ) ,
449- value : TransactionValue :: zero ( ) ,
450- data : TransactionData :: empty ( ) ,
451- cancelled_by_transaction_id : Some ( competitor. id ) ,
452- ..comp_tx. original
453- } ;
454- ( TransactionStatus :: CANCELLED , cancelled_original)
455- }
456- CompetitionType :: Replace => {
457- let replaced_original = Transaction {
458- status : TransactionStatus :: REPLACED ,
459- ..comp_tx. original
460- } ;
461- ( TransactionStatus :: REPLACED , replaced_original)
462- }
463- } ;
464-
465- let winner = Transaction {
466- status : transaction_status,
467- mined_at : Some ( Utc :: now ( ) ) ,
468- ..competitor
469- } ;
470-
471- ( winner, Some ( loser_transaction) , loser_status)
422+ let ( winner_transaction, loser_transaction, loser_status) = if comp_tx. original . id
423+ == * id
424+ {
425+ let loser_status = if let Some ( ( _, comp_type) ) = & comp_tx. competitive {
426+ match comp_type {
427+ CompetitionType :: Cancel => TransactionStatus :: DROPPED ,
428+ CompetitionType :: Replace => TransactionStatus :: DROPPED ,
429+ }
472430 } else {
473- return Err (
474- MoveInmempoolTransactionToMinedError :: TransactionIdDoesNotMatch (
475- self . relayer . id ,
476- * id,
477- comp_tx. original ,
478- ) ,
479- ) ;
431+ TransactionStatus :: DROPPED
480432 } ;
481433
434+ let winner = Transaction {
435+ status : transaction_status,
436+ mined_at : Some ( Utc :: now ( ) ) ,
437+ cancelled_by_transaction_id : None ,
438+ ..comp_tx. original
439+ } ;
440+
441+ ( winner, comp_tx. competitive . map ( |( tx, _) | tx) , loser_status)
442+ } else if let Some ( ( competitor, comp_type) ) = comp_tx. competitive {
443+ let ( loser_status, loser_transaction) = match comp_type {
444+ CompetitionType :: Cancel => {
445+ // When cancel wins, original transaction becomes a cancelled no-op
446+ let cancelled_original = Transaction {
447+ status : TransactionStatus :: CANCELLED ,
448+ is_noop : true ,
449+ to : self . relay_address ( ) ,
450+ value : TransactionValue :: zero ( ) ,
451+ data : TransactionData :: empty ( ) ,
452+ cancelled_by_transaction_id : Some ( competitor. id ) ,
453+ ..comp_tx. original
454+ } ;
455+ ( TransactionStatus :: CANCELLED , cancelled_original)
456+ }
457+ CompetitionType :: Replace => {
458+ let replaced_original = Transaction {
459+ status : TransactionStatus :: REPLACED ,
460+ ..comp_tx. original
461+ } ;
462+ ( TransactionStatus :: REPLACED , replaced_original)
463+ }
464+ } ;
465+
466+ let winner = Transaction {
467+ status : transaction_status,
468+ mined_at : Some ( Utc :: now ( ) ) ,
469+ ..competitor
470+ } ;
471+
472+ ( winner, Some ( loser_transaction) , loser_status)
473+ } else {
474+ return Err ( MoveInmempoolTransactionToMinedError :: TransactionIdDoesNotMatch (
475+ self . relayer . id ,
476+ * id,
477+ comp_tx. original ,
478+ ) ) ;
479+ } ;
480+
482481 let mut mining_transactions = self . mined_transactions . lock ( ) . await ;
483482 mining_transactions. insert ( winner_transaction. id , winner_transaction. clone ( ) ) ;
484483
0 commit comments