Don't display fee rating when block medianFee is empty to fix "overpaid by infinity".

fixes #288
This commit is contained in:
softsimon 2021-02-02 00:10:57 +07:00
parent 2a5a4ddac0
commit 09f5f552bf
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -28,7 +28,7 @@ export class TxFeeRatingComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() { ngOnInit() {
this.blocksSubscription = this.stateService.blocks$.subscribe(([block]) => { this.blocksSubscription = this.stateService.blocks$.subscribe(([block]) => {
this.blocks.push(block); this.blocks.push(block);
if (this.tx.status.confirmed && this.tx.status.block_height === block.height) { if (this.tx.status.confirmed && this.tx.status.block_height === block.height && block.medianFee > 0) {
this.calculateRatings(block); this.calculateRatings(block);
this.cd.markForCheck(); this.cd.markForCheck();
} }
@ -42,7 +42,7 @@ export class TxFeeRatingComponent implements OnInit, OnChanges, OnDestroy {
} }
const foundBlock = this.blocks.find((b) => b.height === this.tx.status.block_height); const foundBlock = this.blocks.find((b) => b.height === this.tx.status.block_height);
if (foundBlock) { if (foundBlock && foundBlock.medianFee > 0) {
this.calculateRatings(foundBlock); this.calculateRatings(foundBlock);
} }
} }
@ -53,7 +53,7 @@ export class TxFeeRatingComponent implements OnInit, OnChanges, OnDestroy {
calculateRatings(block: Block) { calculateRatings(block: Block) {
const feePervByte = this.tx.fee / (this.tx.weight / 4); const feePervByte = this.tx.fee / (this.tx.weight / 4);
this.medianFeeNeeded = Math.round(block.feeRange[Math.round(block.feeRange.length * 0.5)]); this.medianFeeNeeded = block.medianFee;
// Block not filled // Block not filled
if (block.weight < 4000000 * 0.95) { if (block.weight < 4000000 * 0.95) {