Fix bugged mempool block gradients
This commit is contained in:
parent
47d2a6d5c7
commit
fc0af50ab5
@ -35,16 +35,25 @@ export class Common {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getFeesInRange(transactions: TransactionExtended[], rangeLength: number) {
|
static getFeesInRange(transactions: TransactionExtended[], rangeLength: number) {
|
||||||
const arr = [transactions[transactions.length - 1].effectiveFeePerVsize];
|
const filtered: TransactionExtended[] = [];
|
||||||
|
let lastValidRate = Infinity;
|
||||||
|
// filter out anomalous fee rates to ensure monotonic range
|
||||||
|
for (const tx of transactions) {
|
||||||
|
if (tx.effectiveFeePerVsize <= lastValidRate) {
|
||||||
|
filtered.push(tx);
|
||||||
|
lastValidRate = tx.effectiveFeePerVsize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const arr = [filtered[filtered.length - 1].effectiveFeePerVsize];
|
||||||
const chunk = 1 / (rangeLength - 1);
|
const chunk = 1 / (rangeLength - 1);
|
||||||
let itemsToAdd = rangeLength - 2;
|
let itemsToAdd = rangeLength - 2;
|
||||||
|
|
||||||
while (itemsToAdd > 0) {
|
while (itemsToAdd > 0) {
|
||||||
arr.push(transactions[Math.floor(transactions.length * chunk * itemsToAdd)].effectiveFeePerVsize);
|
arr.push(filtered[Math.floor(filtered.length * chunk * itemsToAdd)].effectiveFeePerVsize);
|
||||||
itemsToAdd--;
|
itemsToAdd--;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr.push(transactions[0].effectiveFeePerVsize);
|
arr.push(filtered[0].effectiveFeePerVsize);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user