From fa515402bfffb77aea8da06772e5d40fac948043 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sun, 27 Nov 2022 13:46:54 +0900 Subject: [PATCH] display indexed cpfp info on non-mempool txs --- .../transaction/transaction.component.html | 21 ++++++++-- .../transaction/transaction.component.ts | 41 +++++++++++-------- .../src/app/interfaces/node-api.interface.ts | 4 +- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index d478da053..b6ed2868f 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -156,7 +156,20 @@ - + + + Descendant + + {{ cpfpTx.txid | shortenString : 8 }} + {{ cpfpTx.txid }} + + + + {{ cpfpTx.fee / (cpfpTx.weight / 4) | feeRounding }} sat/vB + + + + Descendant @@ -170,7 +183,7 @@ - + Ancestor @@ -468,11 +481,11 @@ {{ tx.feePerVsize | feeRounding }} sat/vB   - + - + Effective fee rate
diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 1c20be732..3e04b0ad9 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -117,25 +117,31 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { if (!this.tx) { return; } - const lowerFeeParents = cpfpInfo.ancestors.filter( - (parent) => parent.fee / (parent.weight / 4) < this.tx.feePerVsize - ); - let totalWeight = - this.tx.weight + - lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); - let totalFees = - this.tx.fee + - lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); + if (cpfpInfo.effectiveFeePerVsize) { + this.tx.effectiveFeePerVsize = cpfpInfo.effectiveFeePerVsize; + } else { + const lowerFeeParents = cpfpInfo.ancestors.filter( + (parent) => parent.fee / (parent.weight / 4) < this.tx.feePerVsize + ); + let totalWeight = + this.tx.weight + + lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); + let totalFees = + this.tx.fee + + lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); - if (cpfpInfo.bestDescendant) { - totalWeight += cpfpInfo.bestDescendant.weight; - totalFees += cpfpInfo.bestDescendant.fee; + if (cpfpInfo?.bestDescendant) { + totalWeight += cpfpInfo?.bestDescendant.weight; + totalFees += cpfpInfo?.bestDescendant.fee; + } + + this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); + } + if (!this.tx.status.confirmed) { + this.stateService.markBlock$.next({ + txFeePerVSize: this.tx.effectiveFeePerVsize, + }); } - - this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); - this.stateService.markBlock$.next({ - txFeePerVSize: this.tx.effectiveFeePerVsize, - }); this.cpfpInfo = cpfpInfo; }); @@ -239,6 +245,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.stateService.markBlock$.next({ blockHeight: tx.status.block_height, }); + this.fetchCpfp$.next(this.tx.txid); } else { if (tx.cpfpChecked) { this.stateService.markBlock$.next({ diff --git a/frontend/src/app/interfaces/node-api.interface.ts b/frontend/src/app/interfaces/node-api.interface.ts index 5df095432..d32e641f7 100644 --- a/frontend/src/app/interfaces/node-api.interface.ts +++ b/frontend/src/app/interfaces/node-api.interface.ts @@ -22,7 +22,9 @@ interface BestDescendant { export interface CpfpInfo { ancestors: Ancestor[]; - bestDescendant: BestDescendant | null; + descendants?: Ancestor[]; + bestDescendant?: BestDescendant | null; + effectiveFeePerVsize?: number; } export interface DifficultyAdjustment {