@@ -203,7 +203,6 @@ def cancel_order_match(db, order_match, status, block_index, tx_index):
203
203
204
204
if status == "expired" :
205
205
# Record order match expiration.
206
- cursor = db .cursor () # noqa: F841
207
206
bindings = {
208
207
"order_match_id" : order_match ["id" ],
209
208
"tx0_address" : order_match ["tx0_address" ],
@@ -545,7 +544,7 @@ def match(db, tx, block_index=None):
545
544
tx0_fee_provided_remaining = tx0 ["fee_provided_remaining" ]
546
545
547
546
# Make sure that that both orders still have funds remaining (if order involves BTC, and so cannot be ‘filled’).
548
- if tx0 ["give_asset" ] == config . BTC or tx0 ["get_asset" ] == config . BTC : # Gratuitous
547
+ if config . BTC in [ tx0 ["give_asset" ], tx0 ["get_asset" ]] : # Gratuitous
549
548
if tx0_give_remaining <= 0 or tx1_give_remaining <= 0 :
550
549
logger .trace ("Skipping: negative give quantity remaining" )
551
550
continue
@@ -637,17 +636,19 @@ def match(db, tx, block_index=None):
637
636
)
638
637
639
638
logger .trace (
640
- f"Tx0 fee provided remaining: { tx0_fee_provided_remaining / config .UNIT } ; required fee: { fee / config .UNIT } "
639
+ "Tx0 fee provided remaining: %s; required fee: %s" ,
640
+ tx0_fee_provided_remaining / config .UNIT ,
641
+ fee / config .UNIT ,
641
642
)
642
643
if tx0_fee_provided_remaining < fee :
643
644
logger .trace ("Skipping: tx0 fee provided remaining is too low." )
644
645
continue
645
- else :
646
- tx0_fee_provided_remaining -= fee
647
- if protocol .after_block_or_test_network (
648
- block_index , 287800
649
- ): # Protocol change.
650
- tx1_fee_required_remaining -= fee
646
+
647
+ tx0_fee_provided_remaining -= fee
648
+ if protocol .after_block_or_test_network (
649
+ block_index , 287800
650
+ ): # Protocol change.
651
+ tx1_fee_required_remaining -= fee
651
652
652
653
elif tx1 ["give_asset" ] == config .BTC :
653
654
if protocol .after_block_or_test_network (
@@ -664,17 +665,21 @@ def match(db, tx, block_index=None):
664
665
)
665
666
666
667
logger .trace (
667
- f"Tx1 fee provided remaining: { tx1_fee_provided_remaining / config .UNIT } ; required fee: { fee / config .UNIT } "
668
+ "Tx1 fee provided remaining: %(fee_provided)s; required fee: %(required_fee)s" ,
669
+ {
670
+ "fee_provided" : tx1_fee_provided_remaining / config .UNIT ,
671
+ "required_fee" : fee / config .UNIT ,
672
+ },
668
673
)
669
674
if tx1_fee_provided_remaining < fee :
670
675
logger .trace ("Skipping: tx1 fee provided remaining is too low." )
671
676
continue
672
- else :
673
- tx1_fee_provided_remaining -= fee
674
- if protocol .after_block_or_test_network (
675
- block_index , 287800
676
- ): # Protocol change.
677
- tx0_fee_required_remaining -= fee
677
+
678
+ tx1_fee_provided_remaining -= fee
679
+ if protocol .after_block_or_test_network (
680
+ block_index , 287800
681
+ ): # Protocol change.
682
+ tx0_fee_required_remaining -= fee
678
683
679
684
else : # Don’t deduct.
680
685
if tx1 ["get_asset" ] == config .BTC :
@@ -722,7 +727,7 @@ def match(db, tx, block_index=None):
722
727
if tx0_give_remaining <= 0 or (
723
728
tx0_get_remaining <= 0 and protocol .after_block_or_test_network (block_index , 292000 )
724
729
): # Protocol change
725
- if tx0 ["give_asset" ] != config . BTC and tx0 ["get_asset" ] != config . BTC :
730
+ if config . BTC not in [ tx0 ["give_asset" ], tx0 ["get_asset" ]] :
726
731
# Fill order, and recredit give_remaining.
727
732
tx0_status = "filled"
728
733
ledger .events .credit (
@@ -747,7 +752,7 @@ def match(db, tx, block_index=None):
747
752
if tx1_give_remaining <= 0 or (
748
753
tx1_get_remaining <= 0 and protocol .after_block_or_test_network (block_index , 292000 )
749
754
): # Protocol change
750
- if tx1 ["give_asset" ] != config . BTC and tx1 ["get_asset" ] != config . BTC :
755
+ if config . BTC not in [ tx1 ["give_asset" ], tx1 ["get_asset" ]] :
751
756
# Fill order, and recredit give_remaining.
752
757
tx1_status = "filled"
753
758
ledger .events .credit (
0 commit comments