mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
Use actual block weight instead of assumed full block weight in median fee calculation
This commit is contained in:
parent
b6ac9ff974
commit
42bfa6f300
1 changed files with 5 additions and 3 deletions
|
|
@ -900,9 +900,11 @@ export class Common {
|
|||
let medianWeight = 0;
|
||||
|
||||
// calculate the "medianFee" as the average fee rate of the middle 0.25% weight units of transactions
|
||||
const halfWidth = config.MEMPOOL.BLOCK_WEIGHT_UNITS / 800;
|
||||
const leftBound = Math.floor((config.MEMPOOL.BLOCK_WEIGHT_UNITS / 2) - halfWidth);
|
||||
const rightBound = Math.ceil((config.MEMPOOL.BLOCK_WEIGHT_UNITS / 2) + halfWidth);
|
||||
// Also ensure we use actual block weight rather than assuming full block
|
||||
const effectiveBlockWeight = transactions.reduce((sum, tx) => sum + tx.weight, 0);
|
||||
const halfWidth = effectiveBlockWeight / 800;
|
||||
const leftBound = Math.floor((effectiveBlockWeight / 2) - halfWidth);
|
||||
const rightBound = Math.ceil((effectiveBlockWeight / 2) + halfWidth);
|
||||
for (let i = 0; i < sortedTxs.length && weightCount < rightBound; i++) {
|
||||
const left = weightCount;
|
||||
const right = weightCount + sortedTxs[i].weight;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue