mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Bugfix: RPC/blockchain: Actually round feerates down for getmempoolinfo fee histograms
This commit is contained in:
parent
d53d29ce1b
commit
0bfca0cf32
@ -701,12 +701,14 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool, const std::optional<MempoolHi
|
||||
const CAmount afees{e.GetModFeesWithAncestors()}, dfees{e.GetModFeesWithDescendants()};
|
||||
const uint32_t asize{uint32_t(e.GetSizeWithAncestors())}, dsize{uint32_t(e.GetSizeWithDescendants())};
|
||||
|
||||
const CAmount fpb{CFeeRate{fee, size}.GetFee(1)}; // Fee rate per byte
|
||||
const CAmount afpb{CFeeRate{afees, asize}.GetFee(1)}; // Fee rate per byte including ancestors
|
||||
const CAmount dfpb{CFeeRate{dfees, dsize}.GetFee(1)}; // Fee rate per byte including descendants
|
||||
// Do not use CFeeRate here, since it rounds up, and this should be rounding down
|
||||
const CAmount fpb{fee / size}; // Fee rate per byte
|
||||
const CAmount afpb{afees / asize}; // Fee rate per byte including ancestors
|
||||
const CAmount dfpb{dfees / dsize}; // Fee rate per byte including descendants
|
||||
|
||||
// Fee rate per byte including ancestors & descendants
|
||||
const CAmount tfpb{CFeeRate{afees + dfees - fee, asize + dsize - size}.GetFee(1)};
|
||||
// (fee/size are included in both, so subtracted to avoid double-counting)
|
||||
const CAmount tfpb{(afees + dfees - fee) / (asize + dsize - size)};
|
||||
|
||||
const CAmount fee_rate{std::max(std::min(dfpb, tfpb), std::min(fpb, afpb))};
|
||||
|
||||
|
@ -110,7 +110,7 @@ class MempoolFeeHistogramTest(BitcoinTestFramework):
|
||||
self.log.info(f"Test fee rate histogram when mempool contains 2 transactions (tx1: {tx1_info['feerate']} sat/vB, tx2: {tx2_info['feerate']} sat/vB)")
|
||||
info = node.getmempoolinfo([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
|
||||
|
||||
# Verify that both tx1 and tx2 are reported in 9 sat/vB fee rate group
|
||||
# Verify that both tx1 and tx2 are reported in 8 sat/vB fee rate group
|
||||
(non_empty_groups, empty_groups, total_fees) = self.histogram_stats(info['fee_histogram'])
|
||||
tx1p2_feerate = get_actual_fee_rate(tx1_info['fee'] + tx2_info['fee'], tx1_info['vsize'] + tx2_info['vsize'])
|
||||
assert_equal(1, non_empty_groups)
|
||||
|
Loading…
Reference in New Issue
Block a user