Use decimal recommended fee in websocket and on dashboard

This commit is contained in:
natsoni 2024-08-23 16:08:05 +02:00
parent e3c06eb93b
commit 4fded37cda
No known key found for this signature in database
GPG Key ID: C65917583181743B
3 changed files with 21 additions and 8 deletions

View File

@ -95,7 +95,7 @@ class WebsocketHandler {
'backendInfo': backendInfo.getBackendInfo(),
'loadingIndicators': loadingIndicators.getLoadingIndicators(),
'da': da?.previousTime ? da : undefined,
'fees': feeApi.getRecommendedFee(),
'fees': feeApi.getRecommendedFee(true),
});
}
@ -567,7 +567,7 @@ class WebsocketHandler {
}
memPool.removeFromSpendMap(deletedTransactions);
memPool.addToSpendMap(newTransactions);
const recommendedFees = feeApi.getRecommendedFee();
const recommendedFees = feeApi.getRecommendedFee(true);
const latestTransactions = memPool.getLatestTransactions();
@ -1048,7 +1048,7 @@ class WebsocketHandler {
const mBlockDeltas = mempoolBlocks.getMempoolBlockDeltas();
const da = difficultyAdjustment.getDifficultyAdjustment();
const fees = feeApi.getRecommendedFee();
const fees = feeApi.getRecommendedFee(true);
const mempoolInfo = memPool.getMempoolInfo();
// pre-compute address transactions

View File

@ -13,23 +13,23 @@
<div class="fee-estimation-container">
<div class="item">
<div class="card-text">
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.economyFee" rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.economyFee * 140" ></app-fiat></span>
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.economyFee" rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.economyFee * 140" ></app-fiat></span>
</div>
</div>
<div class="band-separator"></div>
<div class="item">
<div class="card-text">
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.hourFee" rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.hourFee * 140" ></app-fiat></span>
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.hourFee" rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.hourFee * 140" ></app-fiat></span>
</div>
</div>
<div class="item">
<div class="card-text">
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.halfHourFee" rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.halfHourFee * 140" ></app-fiat></span>
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.halfHourFee" rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.halfHourFee * 140" ></app-fiat></span>
</div>
</div>
<div class="item">
<div class="card-text">
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.fastestFee" rounding="1.0-0"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.fastestFee * 140" ></app-fiat></span>
<div class="fee-text"><app-fee-rate [fee]="recommendedFees.fastestFee" rounding="1.0-1"></app-fee-rate></div> <span class="fiat"><app-fiat i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom" [value]="recommendedFees.fastestFee * 140" ></app-fiat></span>
</div>
</div>
</div>

View File

@ -36,7 +36,7 @@ export class FeesBoxComponent implements OnInit, OnDestroy {
this.recommendedFees$ = this.stateService.recommendedFees$
.pipe(
tap((fees) => {
this.fees = fees;
this.fees = this.roundFees(fees);
this.setFeeGradient();
}
)
@ -61,6 +61,19 @@ export class FeesBoxComponent implements OnInit, OnDestroy {
this.cd.markForCheck();
}
roundFees(fees: Recommendedfees): Recommendedfees {
fees.fastestFee = this.roundFeeValue(fees.fastestFee);
fees.halfHourFee = this.roundFeeValue(fees.halfHourFee);
fees.hourFee = this.roundFeeValue(fees.hourFee);
fees.economyFee = this.roundFeeValue(fees.economyFee);
fees.minimumFee = this.roundFeeValue(fees.minimumFee);
return fees;
}
roundFeeValue(fee: number): number {
return fee >= 10.0 ? Math.ceil(fee) : fee;
}
ngOnDestroy(): void {
this.themeSubscription.unsubscribe();
}