remove redundant fields from CPFP interfaces

This commit is contained in:
Mononaut 2023-01-09 10:25:56 -06:00
parent 01c96f80f9
commit fcd047f302
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
3 changed files with 9 additions and 20 deletions

View File

@ -83,7 +83,6 @@ class TransactionRepository {
return { return {
descendants, descendants,
ancestors, ancestors,
effectiveFeePerVsize: cpfp.fee_rate
}; };
} }
} }

View File

@ -131,26 +131,17 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
this.cpfpInfo = null; this.cpfpInfo = null;
return; return;
} }
if (cpfpInfo.effectiveFeePerVsize) {
this.tx.effectiveFeePerVsize = cpfpInfo.effectiveFeePerVsize; const relatives = [...cpfpInfo.ancestors, ...cpfpInfo.descendants || [cpfpInfo.bestDescendant]];
} else {
const lowerFeeParents = cpfpInfo.ancestors.filter(
(parent) => parent.fee / (parent.weight / 4) < this.tx.feePerVsize
);
let totalWeight = let totalWeight =
this.tx.weight + this.tx.weight +
lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); relatives.reduce((prev, val) => prev + val.weight, 0);
let totalFees = let totalFees =
this.tx.fee + this.tx.fee +
lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); relatives.reduce((prev, val) => prev + val.fee, 0);
if (cpfpInfo?.bestDescendant) {
totalWeight += cpfpInfo?.bestDescendant.weight;
totalFees += cpfpInfo?.bestDescendant.fee;
}
this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4);
}
if (!this.tx.status.confirmed) { if (!this.tx.status.confirmed) {
this.stateService.markBlock$.next({ this.stateService.markBlock$.next({
txFeePerVSize: this.tx.effectiveFeePerVsize, txFeePerVSize: this.tx.effectiveFeePerVsize,

View File

@ -24,7 +24,6 @@ export interface CpfpInfo {
ancestors: Ancestor[]; ancestors: Ancestor[];
descendants?: Ancestor[]; descendants?: Ancestor[];
bestDescendant?: BestDescendant | null; bestDescendant?: BestDescendant | null;
effectiveFeePerVsize?: number;
} }
export interface DifficultyAdjustment { export interface DifficultyAdjustment {