mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
[refactor] clean up logic in testmempoolaccept
Cleans up reundant code and reduces the diff of the next commit.
This commit is contained in:
parent
f72d80b07a
commit
9db10a5506
1 changed files with 16 additions and 21 deletions
|
@ -955,35 +955,30 @@ static RPCHelpMan testmempoolaccept()
|
|||
nullptr /* plTxnReplaced */, false /* bypass_limits */, /* test_accept */ true, &fee);
|
||||
}
|
||||
|
||||
// Check that fee does not exceed maximum fee
|
||||
if (test_accept_res && max_raw_tx_fee && fee > max_raw_tx_fee) {
|
||||
result_0.pushKV("allowed", false);
|
||||
result_0.pushKV("reject-reason", "max-fee-exceeded");
|
||||
result.push_back(std::move(result_0));
|
||||
return result;
|
||||
}
|
||||
result_0.pushKV("allowed", test_accept_res);
|
||||
|
||||
// Only return the fee and vsize if the transaction would pass ATMP.
|
||||
// These can be used to calculate the feerate.
|
||||
if (test_accept_res) {
|
||||
result_0.pushKV("vsize", virtual_size);
|
||||
UniValue fees(UniValue::VOBJ);
|
||||
fees.pushKV("base", ValueFromAmount(fee));
|
||||
result_0.pushKV("fees", fees);
|
||||
// Check that fee does not exceed maximum fee
|
||||
if (max_raw_tx_fee && fee > max_raw_tx_fee) {
|
||||
result_0.pushKV("allowed", false);
|
||||
result_0.pushKV("reject-reason", "max-fee-exceeded");
|
||||
} else {
|
||||
result_0.pushKV("allowed", true);
|
||||
result_0.pushKV("vsize", virtual_size);
|
||||
UniValue fees(UniValue::VOBJ);
|
||||
fees.pushKV("base", ValueFromAmount(fee));
|
||||
result_0.pushKV("fees", fees);
|
||||
}
|
||||
result.push_back(std::move(result_0));
|
||||
} else {
|
||||
if (state.IsInvalid()) {
|
||||
if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) {
|
||||
result_0.pushKV("reject-reason", "missing-inputs");
|
||||
} else {
|
||||
result_0.pushKV("reject-reason", strprintf("%s", state.GetRejectReason()));
|
||||
}
|
||||
result_0.pushKV("allowed", false);
|
||||
if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) {
|
||||
result_0.pushKV("reject-reason", "missing-inputs");
|
||||
} else {
|
||||
result_0.pushKV("reject-reason", state.GetRejectReason());
|
||||
}
|
||||
result.push_back(std::move(result_0));
|
||||
}
|
||||
|
||||
result.push_back(std::move(result_0));
|
||||
return result;
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue