Fix reorg to lower height on /monitoring status page

This commit is contained in:
Mononaut 2024-09-05 20:55:48 +00:00
parent 64223c4744
commit e513f05c09
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
2 changed files with 10 additions and 5 deletions

View File

@ -9,7 +9,7 @@
<ng-container *ngIf="(hosts$ | async) as hosts">
<div class="status-panel">
<table class="status-table table table-borderless table-striped" *ngIf="(tip$ | async) as tip">
<table class="status-table table table-borderless table-striped">
<tbody>
<tr>
<th class="rank"></th>
@ -27,7 +27,7 @@
<td class="updated">{{ getLastUpdateSeconds(host) }}</td>
<td class="rtt only-small">{{ (host.rtt / 1000) | number : '1.1-1' }} {{ host.rtt == null ? '' : 's'}} {{ !host.checked ? '⏳' : (host.unreachable ? '🔥' : '✅') }}</td>
<td class="rtt only-large">{{ host.rtt | number : '1.0-0' }} {{ host.rtt == null ? '' : 'ms'}} {{ !host.checked ? '⏳' : (host.unreachable ? '🔥' : '✅') }}</td>
<td class="height">{{ host.latestHeight }} {{ !host.checked ? '⏳' : (host.outOfSync ? '🚫' : (host.latestHeight && host.latestHeight < tip ? '🟧' : '')) }}</td>
<td class="height">{{ host.latestHeight }} {{ !host.checked ? '⏳' : (host.outOfSync ? '🚫' : (host.latestHeight && host.latestHeight < maxHeight ? '🟧' : '')) }}</td>
</tr>
</tbody>
</table>

View File

@ -1,6 +1,6 @@
import { Component, OnInit, ChangeDetectionStrategy, SecurityContext, ChangeDetectorRef } from '@angular/core';
import { WebsocketService } from '../../services/websocket.service';
import { Observable, Subject, map } from 'rxjs';
import { Observable, Subject, map, tap } from 'rxjs';
import { StateService } from '../../services/state.service';
import { HealthCheckHost } from '../../interfaces/websocket.interface';
import { DomSanitizer } from '@angular/platform-browser';
@ -13,7 +13,7 @@ import { DomSanitizer } from '@angular/platform-browser';
})
export class ServerHealthComponent implements OnInit {
hosts$: Observable<HealthCheckHost[]>;
tip$: Subject<number>;
maxHeight: number;
interval: number;
now: number = Date.now();
@ -44,9 +44,14 @@ export class ServerHealthComponent implements OnInit {
host.flag = this.parseFlag(host.host);
}
return hosts;
}),
tap(hosts => {
let newMaxHeight = 0;
for (const host of hosts) {
newMaxHeight = Math.max(newMaxHeight, host.latestHeight);
}
})
);
this.tip$ = this.stateService.chainTip$;
this.websocketService.want(['mempool-blocks', 'stats', 'blocks', 'tomahawk']);
this.interval = window.setInterval(() => {