CPFP support (#395)

* CPFP support.

fixes #5
fixes #353
fixes #360

* Use effectiveFeePerVsize for mempool statistics.

* Renaming endpoint cpfp-info to just cpfp.

* Renaming decended to BestDescendant.

* Updating language file with new strings.
This commit is contained in:
softsimon
2021-03-18 23:47:40 +07:00
committed by GitHub
parent b2d08d69cf
commit d3c53c7406
19 changed files with 487 additions and 289 deletions

View File

@@ -91,10 +91,28 @@ export class TransactionComponent implements OnInit, OnDestroy {
this.getTransactionTime();
}
}
if (this.tx.status.confirmed) {
this.stateService.markBlock$.next({ blockHeight: tx.status.block_height });
} else {
this.stateService.markBlock$.next({ txFeePerVSize: tx.fee / (tx.weight / 4) });
if (tx.effectiveFeePerVsize) {
this.stateService.markBlock$.next({ txFeePerVSize: tx.effectiveFeePerVsize });
} else {
this.apiService.getCpfpinfo$(this.tx.txid)
.subscribe((cpfpInfo) => {
let totalWeight = tx.weight + cpfpInfo.ancestors.reduce((prev, val) => prev + val.weight, 0);
let totalFees = tx.fee + cpfpInfo.ancestors.reduce((prev, val) => prev + val.fee, 0);
if (cpfpInfo.bestDescendant) {
totalWeight += cpfpInfo.bestDescendant.weight;
totalFees += cpfpInfo.bestDescendant.fee;
}
const effectiveFeePerVsize = totalFees / (totalWeight / 4);
this.tx.effectiveFeePerVsize = effectiveFeePerVsize;
this.stateService.markBlock$.next({ txFeePerVSize: effectiveFeePerVsize });
});
}
}
},
(error) => {
@@ -139,7 +157,7 @@ export class TransactionComponent implements OnInit, OnDestroy {
return;
}
const txFeePerVSize = this.tx.fee / (this.tx.weight / 4);
const txFeePerVSize = this.tx.effectiveFeePerVsize || this.tx.fee / (this.tx.weight / 4);
for (const block of mempoolBlocks) {
for (let i = 0; i < block.feeRange.length - 1; i++) {