When filtering out lower fee parents, compare with effective fee instead of base fee to include a CPFP chain of transactions.

This commit is contained in:
softsimon 2021-04-10 21:26:05 +04:00
parent c7c4895eab
commit 2d9b9b5c5d
No known key found for this signature in database
GPG key ID: 488D7DCFB5A430D7
2 changed files with 9 additions and 5 deletions

View file

@ -13,9 +13,13 @@ export class Common {
}
static percentile(numbers: number[], percentile: number) {
if (percentile === 50) return this.median(numbers);
if (percentile === 50) {
return this.median(numbers);
}
const index = Math.ceil(numbers.length * (100 - percentile) * 1e-2);
if (index < 0 || index > numbers.length - 1) return 0;
if (index < 0 || index > numbers.length - 1) {
return 0;
}
return numbers[index];
}
@ -71,7 +75,7 @@ export class Common {
}, ms);
});
}
static shuffleArray(array: any[]) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
@ -81,7 +85,7 @@ export class Common {
static setRelativesAndGetCpfpInfo(tx: TransactionExtended, memPool: { [txid: string]: TransactionExtended }): CpfpInfo {
const parents = this.findAllParents(tx, memPool);
const lowerFeeParents = parents.filter((parent) => parent.feePerVsize < tx.feePerVsize);
const lowerFeeParents = parents.filter((parent) => parent.feePerVsize < tx.effectiveFeePerVsize);
let totalWeight = tx.weight + lowerFeeParents.reduce((prev, val) => prev + val.weight, 0);
let totalFees = tx.fee + lowerFeeParents.reduce((prev, val) => prev + val.fee, 0);

View file

@ -53,7 +53,7 @@ class MempoolBlocks {
// Pass down size + fee to all unconfirmed children
let sizes = 0;
memPoolArray.forEach((tx, i) => {
sizes += tx.weight
sizes += tx.weight;
if (sizes > 4000000 * 8) {
return;
}