More precise relative block times
This commit is contained in:
parent
7b01f54fc6
commit
850752e0ea
@ -53,7 +53,7 @@
|
|||||||
<ng-template #transactionsPlural let-i i18n="shared.transaction-count.plural">{{ i }} transactions</ng-template>
|
<ng-template #transactionsPlural let-i i18n="shared.transaction-count.plural">{{ i }} transactions</ng-template>
|
||||||
</div>
|
</div>
|
||||||
<div [attr.data-cy]="'bitcoin-block-' + offset + '-index-' + i + '-time'" class="time-difference">
|
<div [attr.data-cy]="'bitcoin-block-' + offset + '-index-' + i + '-time'" class="time-difference">
|
||||||
<app-time kind="since" [time]="block.timestamp" [fastRender]="true"></app-time></div>
|
<app-time kind="since" [time]="block.timestamp" [fastRender]="true" [precision]="1" minUnit="minute"></app-time></div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<div class="animated" [class]="showMiningInfo ? 'show' : 'hide'" *ngIf="block.extras?.pool != undefined">
|
<div class="animated" [class]="showMiningInfo ? 'show' : 'hide'" *ngIf="block.extras?.pool != undefined">
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div [attr.data-cy]="'mempool-block-' + i + '-time'" class="time-difference" *ngIf="projectedBlock.blockVSize <= stateService.blockVSize; else mergedBlock">
|
<div [attr.data-cy]="'mempool-block-' + i + '-time'" class="time-difference" *ngIf="projectedBlock.blockVSize <= stateService.blockVSize; else mergedBlock">
|
||||||
<ng-template [ngIf]="network === 'liquid' || network === 'liquidtestnet'" [ngIfElse]="timeDiffMainnet">
|
<ng-template [ngIf]="network === 'liquid' || network === 'liquidtestnet'" [ngIfElse]="timeDiffMainnet">
|
||||||
<app-time kind="until" [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true"></app-time>
|
<app-time kind="until" [time]="(1 * i) + now + 61000" [fastRender]="false" [fixedRender]="true" [precision]="1" minUnit="minute"></app-time>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #timeDiffMainnet>
|
<ng-template #timeDiffMainnet>
|
||||||
<app-time kind="until" [time]="da.timeAvg * (i + 1) + now + da.timeOffset" [fastRender]="false" [fixedRender]="true"></app-time>
|
<app-time kind="until" [time]="da.timeAvg * (i + 1) + now + da.timeOffset" [fastRender]="false" [fixedRender]="true" [precision]="1" minUnit="minute"></app-time>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #mergedBlock>
|
<ng-template #mergedBlock>
|
||||||
|
@ -29,6 +29,7 @@ export class TimeComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Input() fixedRender = false;
|
@Input() fixedRender = false;
|
||||||
@Input() relative = false;
|
@Input() relative = false;
|
||||||
@Input() precision: number = 0;
|
@Input() precision: number = 0;
|
||||||
|
@Input() minUnit: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' = 'second';
|
||||||
@Input() fractionDigits: number = 0;
|
@Input() fractionDigits: number = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -96,10 +97,13 @@ export class TimeComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
for (const [index, unit] of this.units.entries()) {
|
for (const [index, unit] of this.units.entries()) {
|
||||||
let precisionUnit = this.units[Math.min(this.units.length - 1, index + this.precision)];
|
let precisionUnit = this.units[Math.min(this.units.length - 1, index + this.precision)];
|
||||||
counter = Math.floor(seconds / this.intervals[unit]);
|
counter = Math.floor(seconds / this.intervals[unit]);
|
||||||
const precisionCounter = Math.floor(seconds / this.intervals[precisionUnit]);
|
const precisionCounter = Math.round(seconds / this.intervals[precisionUnit]);
|
||||||
if (precisionCounter > this.precisionThresholds[precisionUnit]) {
|
if (precisionCounter > this.precisionThresholds[precisionUnit]) {
|
||||||
precisionUnit = unit;
|
precisionUnit = unit;
|
||||||
}
|
}
|
||||||
|
if (this.units.indexOf(precisionUnit) === this.units.indexOf(this.minUnit)) {
|
||||||
|
counter = Math.max(1, counter);
|
||||||
|
}
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
let rounded = Math.round(seconds / this.intervals[precisionUnit]);
|
let rounded = Math.round(seconds / this.intervals[precisionUnit]);
|
||||||
if (this.fractionDigits) {
|
if (this.fractionDigits) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user