Skip to content

Commit 1b875da

Browse files
authored
Merge pull request #5901 from fdefelici/refactor/cleanup-tx-success-method
Removed "fee" argument from `TransactionResult::success()` and `TransactionResult::success_with_soft_limit()`
2 parents dffe26d + 68ebdde commit 1b875da

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed

stackslib/src/chainstate/nakamoto/miner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ impl BlockBuilder for NakamotoBlockBuilder {
737737
}
738738

739739
let cost_before = clarity_tx.cost_so_far();
740-
let (fee, receipt) =
740+
let (_fee, receipt) =
741741
match StacksChainState::process_transaction(clarity_tx, tx, quiet, ast_rules) {
742742
Ok(x) => x,
743743
Err(e) => {
@@ -764,7 +764,7 @@ impl BlockBuilder for NakamotoBlockBuilder {
764764

765765
// save
766766
self.txs.push(tx.clone());
767-
TransactionResult::success_with_soft_limit(tx, fee, receipt, soft_limit_reached)
767+
TransactionResult::success_with_soft_limit(tx, receipt, soft_limit_reached)
768768
};
769769

770770
self.bytes_so_far += tx_len;

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,12 @@ impl TransactionResult {
465465
/// This method logs "transaction success" as a side effect.
466466
pub fn success(
467467
transaction: &StacksTransaction,
468-
fee: u64,
469468
receipt: StacksTransactionReceipt,
470469
) -> TransactionResult {
471470
Self::log_transaction_success(transaction);
472471
Self::Success(TransactionSuccess {
473472
tx: transaction.clone(),
474-
fee,
473+
fee: transaction.get_tx_fee(),
475474
receipt,
476475
soft_limit_reached: false,
477476
})
@@ -481,14 +480,13 @@ impl TransactionResult {
481480
/// This method logs "transaction success" as a side effect.
482481
pub fn success_with_soft_limit(
483482
transaction: &StacksTransaction,
484-
fee: u64,
485483
receipt: StacksTransactionReceipt,
486484
soft_limit_reached: bool,
487485
) -> TransactionResult {
488486
Self::log_transaction_success(transaction);
489487
Self::Success(TransactionSuccess {
490488
tx: transaction.clone(),
491-
fee,
489+
fee: transaction.get_tx_fee(),
492490
receipt,
493491
soft_limit_reached,
494492
})
@@ -1056,7 +1054,7 @@ impl<'a> StacksMicroblockBuilder<'a> {
10561054

10571055
let quiet = !cfg!(test);
10581056
match StacksChainState::process_transaction(clarity_tx, &tx, quiet, ast_rules) {
1059-
Ok((fee, receipt)) => Ok(TransactionResult::success(&tx, fee, receipt)),
1057+
Ok((_fee, receipt)) => Ok(TransactionResult::success(&tx, receipt)),
10601058
Err(e) => {
10611059
let (is_problematic, e) =
10621060
TransactionResult::is_problematic(&tx, e, clarity_tx.get_epoch());
@@ -2860,7 +2858,7 @@ impl BlockBuilder for StacksBlockBuilder {
28602858
self.txs.push(tx.clone());
28612859
self.total_anchored_fees += fee;
28622860

2863-
TransactionResult::success(tx, fee, receipt)
2861+
TransactionResult::success(tx, receipt)
28642862
} else {
28652863
// building up the microblocks
28662864
if tx.anchor_mode != TransactionAnchorMode::OffChainOnly
@@ -2950,7 +2948,7 @@ impl BlockBuilder for StacksBlockBuilder {
29502948
self.micro_txs.push(tx.clone());
29512949
self.total_streamed_fees += fee;
29522950

2953-
TransactionResult::success(tx, fee, receipt)
2951+
TransactionResult::success(tx, receipt)
29542952
};
29552953

29562954
self.bytes_so_far += tx_len;

stackslib/src/chainstate/stacks/tests/block_construction.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4999,7 +4999,6 @@ fn paramaterized_mempool_walk_test(
49994999
// Generate any success result
50005000
TransactionResult::success(
50015001
&available_tx.tx.tx,
5002-
available_tx.tx.metadata.tx_fee,
50035002
StacksTransactionReceipt::from_stx_transfer(
50045003
available_tx.tx.tx.clone(),
50055004
vec![],

stackslib/src/core/tests/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ fn mempool_walk_over_fork() {
278278
// Generate any success result
279279
TransactionResult::success(
280280
&available_tx.tx.tx,
281-
available_tx.tx.metadata.tx_fee,
282281
StacksTransactionReceipt::from_stx_transfer(
283282
available_tx.tx.tx.clone(),
284283
vec![],
@@ -316,7 +315,6 @@ fn mempool_walk_over_fork() {
316315
// Generate any success result
317316
TransactionResult::success(
318317
&available_tx.tx.tx,
319-
available_tx.tx.metadata.tx_fee,
320318
StacksTransactionReceipt::from_stx_transfer(
321319
available_tx.tx.tx.clone(),
322320
vec![],
@@ -353,7 +351,6 @@ fn mempool_walk_over_fork() {
353351
// Generate any success result
354352
TransactionResult::success(
355353
&available_tx.tx.tx,
356-
available_tx.tx.metadata.tx_fee,
357354
StacksTransactionReceipt::from_stx_transfer(
358355
available_tx.tx.tx.clone(),
359356
vec![],
@@ -395,7 +392,6 @@ fn mempool_walk_over_fork() {
395392
// Generate any success result
396393
TransactionResult::success(
397394
&available_tx.tx.tx,
398-
available_tx.tx.metadata.tx_fee,
399395
StacksTransactionReceipt::from_stx_transfer(
400396
available_tx.tx.tx.clone(),
401397
vec![],
@@ -435,7 +431,6 @@ fn mempool_walk_over_fork() {
435431
// Generate any success result
436432
TransactionResult::success(
437433
&available_tx.tx.tx,
438-
available_tx.tx.metadata.tx_fee,
439434
StacksTransactionReceipt::from_stx_transfer(
440435
available_tx.tx.tx.clone(),
441436
vec![],
@@ -661,7 +656,6 @@ fn test_iterate_candidates_consider_no_estimate_tx_prob() {
661656
// Generate any success result
662657
TransactionResult::success(
663658
&available_tx.tx.tx,
664-
available_tx.tx.metadata.tx_fee,
665659
StacksTransactionReceipt::from_stx_transfer(
666660
available_tx.tx.tx.clone(),
667661
vec![],
@@ -698,7 +692,6 @@ fn test_iterate_candidates_consider_no_estimate_tx_prob() {
698692
// Generate any success result
699693
TransactionResult::success(
700694
&available_tx.tx.tx,
701-
available_tx.tx.metadata.tx_fee,
702695
StacksTransactionReceipt::from_stx_transfer(
703696
available_tx.tx.tx.clone(),
704697
vec![],
@@ -735,7 +728,6 @@ fn test_iterate_candidates_consider_no_estimate_tx_prob() {
735728
// Generate any success result
736729
TransactionResult::success(
737730
&available_tx.tx.tx,
738-
available_tx.tx.metadata.tx_fee,
739731
StacksTransactionReceipt::from_stx_transfer(
740732
available_tx.tx.tx.clone(),
741733
vec![],
@@ -844,7 +836,6 @@ fn test_iterate_candidates_skipped_transaction() {
844836
// Generate any success result
845837
TransactionResult::success(
846838
&available_tx.tx.tx,
847-
available_tx.tx.metadata.tx_fee,
848839
StacksTransactionReceipt::from_stx_transfer(
849840
available_tx.tx.tx.clone(),
850841
vec![],
@@ -959,7 +950,6 @@ fn test_iterate_candidates_processing_error_transaction() {
959950
// Generate any success result
960951
TransactionResult::success(
961952
&available_tx.tx.tx,
962-
available_tx.tx.metadata.tx_fee,
963953
StacksTransactionReceipt::from_stx_transfer(
964954
available_tx.tx.tx.clone(),
965955
vec![],
@@ -1074,7 +1064,6 @@ fn test_iterate_candidates_problematic_transaction() {
10741064
// Generate any success result
10751065
TransactionResult::success(
10761066
&available_tx.tx.tx,
1077-
available_tx.tx.metadata.tx_fee,
10781067
StacksTransactionReceipt::from_stx_transfer(
10791068
available_tx.tx.tx.clone(),
10801069
vec![],
@@ -1226,7 +1215,6 @@ fn test_iterate_candidates_concurrent_write_lock() {
12261215
// Generate any success result
12271216
TransactionResult::success(
12281217
&available_tx.tx.tx,
1229-
available_tx.tx.metadata.tx_fee,
12301218
StacksTransactionReceipt::from_stx_transfer(
12311219
available_tx.tx.tx.clone(),
12321220
vec![],
@@ -2725,7 +2713,6 @@ fn test_filter_txs_by_type() {
27252713
// Generate any success result
27262714
TransactionResult::success(
27272715
&available_tx.tx.tx,
2728-
available_tx.tx.metadata.tx_fee,
27292716
StacksTransactionReceipt::from_stx_transfer(
27302717
available_tx.tx.tx.clone(),
27312718
vec![],
@@ -2760,7 +2747,6 @@ fn test_filter_txs_by_type() {
27602747
// Generate any success result
27612748
TransactionResult::success(
27622749
&available_tx.tx.tx,
2763-
available_tx.tx.metadata.tx_fee,
27642750
StacksTransactionReceipt::from_stx_transfer(
27652751
available_tx.tx.tx.clone(),
27662752
vec![],

0 commit comments

Comments
 (0)