mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2024-12-22 11:39:25 +00:00
Optimize rpc traffic
This commit is contained in:
parent
6e47400426
commit
25656f5fba
6 changed files with 72 additions and 81 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { EventEmitter, Injectable, NgZone } from '@angular/core';
|
import { EventEmitter, Injectable, NgZone } from '@angular/core';
|
||||||
import { DaemonService } from './daemon.service';
|
import { DaemonService } from './daemon.service';
|
||||||
import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetHashRateHistory, NetStats, NetStatsHistory, PeerInfo, ProcessStats, PublicNode, SyncInfo, TimeUtils, TxBacklogEntry, TxPool, TxPoolStats } from '../../../../common';
|
import { BlockCount, BlockHeader, Chain, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetHashRateHistory, NetStats, NetStatsHistory, ProcessStats, SyncInfo, TimeUtils, TxBacklogEntry, TxPool, TxPoolStats } from '../../../../common';
|
||||||
import { ElectronService } from '../electron/electron.service';
|
import { ElectronService } from '../electron/electron.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
@ -13,7 +13,6 @@ export class DaemonDataService {
|
||||||
private _refreshing: boolean = false;
|
private _refreshing: boolean = false;
|
||||||
private _firstRefresh: boolean = true;
|
private _firstRefresh: boolean = true;
|
||||||
private _lastRefresh: number = Date.now();
|
private _lastRefresh: number = Date.now();
|
||||||
private _lastRefreshHeight: number = -1;
|
|
||||||
|
|
||||||
private _daemonRunning: boolean = false;
|
private _daemonRunning: boolean = false;
|
||||||
|
|
||||||
|
@ -51,18 +50,9 @@ export class DaemonDataService {
|
||||||
private _minerDataCoreBusyError: boolean = false;
|
private _minerDataCoreBusyError: boolean = false;
|
||||||
private _gettingMinerData: boolean = false;
|
private _gettingMinerData: boolean = false;
|
||||||
|
|
||||||
private _publicNodes: PublicNode[] = [];
|
|
||||||
private _gettingPublicNodes: boolean = false;
|
|
||||||
|
|
||||||
private _transactionPool?: TxPool;
|
private _transactionPool?: TxPool;
|
||||||
private _gettingTransactionPool: boolean = false;
|
private _gettingTransactionPool: boolean = false;
|
||||||
|
|
||||||
private _connections: Connection[] = [];
|
|
||||||
private _gettingConnections: boolean = false;
|
|
||||||
|
|
||||||
private _peerList: PeerInfo[] = [];
|
|
||||||
private _gettingPeerList: boolean = false;
|
|
||||||
|
|
||||||
private _txPoolBacklog: TxBacklogEntry[] = [];
|
private _txPoolBacklog: TxBacklogEntry[] = [];
|
||||||
private _gettingTxPoolBackLog: boolean = false;
|
private _gettingTxPoolBackLog: boolean = false;
|
||||||
|
|
||||||
|
@ -217,14 +207,6 @@ export class DaemonDataService {
|
||||||
return this._gettingMinerData;
|
return this._gettingMinerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get publicNodes(): PublicNode[] {
|
|
||||||
return this._publicNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get gettingPublicNodes(): boolean {
|
|
||||||
return this._gettingPublicNodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get transactionPool(): TxPool | undefined {
|
public get transactionPool(): TxPool | undefined {
|
||||||
return this._transactionPool;
|
return this._transactionPool;
|
||||||
}
|
}
|
||||||
|
@ -233,22 +215,6 @@ export class DaemonDataService {
|
||||||
return this._gettingTransactionPool;
|
return this._gettingTransactionPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get connections(): Connection[] {
|
|
||||||
return this._connections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get gettingConnections(): boolean {
|
|
||||||
return this._gettingConnections;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get peerList(): PeerInfo[] {
|
|
||||||
return this._peerList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get gettingPeerList(): boolean {
|
|
||||||
return this._gettingPeerList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get txPoolBacklog(): TxBacklogEntry[] {
|
public get txPoolBacklog(): TxBacklogEntry[] {
|
||||||
return this._txPoolBacklog;
|
return this._txPoolBacklog;
|
||||||
}
|
}
|
||||||
|
@ -512,14 +478,6 @@ export class DaemonDataService {
|
||||||
await this.refreshMinerData();
|
await this.refreshMinerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._gettingPeerList = true;
|
|
||||||
this._peerList = await this.daemonService.getPeerList();
|
|
||||||
this._gettingPeerList = false;
|
|
||||||
|
|
||||||
this._gettingPublicNodes = true;
|
|
||||||
this._publicNodes = await this.daemonService.getPublicNodes(true, true);
|
|
||||||
this._gettingPublicNodes = false;
|
|
||||||
|
|
||||||
if (this._daemonInfo.synchronized && this._daemonInfo.txPoolSize > 0) {
|
if (this._daemonInfo.synchronized && this._daemonInfo.txPoolSize > 0) {
|
||||||
this._gettingTransactionPool = true;
|
this._gettingTransactionPool = true;
|
||||||
this._transactionPool = await this.daemonService.getTransactionPool();
|
this._transactionPool = await this.daemonService.getTransactionPool();
|
||||||
|
@ -538,13 +496,6 @@ export class DaemonDataService {
|
||||||
this._txPoolStats = undefined;
|
this._txPoolStats = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.daemonService.settings.offline) {
|
|
||||||
this._gettingConnections = true;
|
|
||||||
this._connections = await this.daemonService.getConnections();
|
|
||||||
this._gettingConnections = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._lastRefreshHeight = this._daemonInfo.heightWithoutBootstrap;
|
|
||||||
this._lastRefresh = Date.now();
|
this._lastRefresh = Date.now();
|
||||||
} catch(error: any) {
|
} catch(error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -555,10 +506,7 @@ export class DaemonDataService {
|
||||||
this._gettingIsBlockchainPruned = false;
|
this._gettingIsBlockchainPruned = false;
|
||||||
this._gettingAltChains = false;
|
this._gettingAltChains = false;
|
||||||
this._gettingNetStats = false;
|
this._gettingNetStats = false;
|
||||||
this._gettingPublicNodes = false;
|
|
||||||
this._gettingTransactionPool = false;
|
this._gettingTransactionPool = false;
|
||||||
this._gettingConnections = false;
|
|
||||||
this._gettingPeerList = false;
|
|
||||||
this._gettingTxPoolStats = false;
|
this._gettingTxPoolStats = false;
|
||||||
|
|
||||||
this.syncError.emit(error);
|
this.syncError.emit(error);
|
||||||
|
|
|
@ -59,6 +59,13 @@
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<hr class="my-4">
|
||||||
|
|
||||||
|
<button *ngIf="!refreshingConnectionsTable" class="w-100 btn btn-primary btn-lg" type="button" (click)="refreshConnectionsTable()">Refresh Connections</button>
|
||||||
|
<button *ngIf="refreshingConnectionsTable" class="w-100 btn btn-primary btn-lg" type="button" disabled>Refreshing Connections ...</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane fade" id="pills-limit" role="tabpanel" aria-labelledby="pills-limit-tab" tabindex="0">
|
<div class="tab-pane fade" id="pills-limit" role="tabpanel" aria-labelledby="pills-limit-tab" tabindex="0">
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { NavbarService } from '../../shared/components/navbar/navbar.service';
|
||||||
import { DaemonDataService, DaemonService } from '../../core/services';
|
import { DaemonDataService, DaemonService } from '../../core/services';
|
||||||
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
||||||
import { Chart, ChartData } from 'chart.js/auto'
|
import { Chart, ChartData } from 'chart.js/auto'
|
||||||
import { NetStats, NetStatsHistoryEntry } from '../../../common';
|
import { Connection, NetStats, NetStatsHistoryEntry } from '../../../common';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { BasePageComponent } from '../base-page/base-page.component';
|
import { BasePageComponent } from '../base-page/base-page.component';
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import { BasePageComponent } from '../base-page/base-page.component';
|
||||||
})
|
})
|
||||||
export class NetworkComponent extends BasePageComponent implements AfterViewInit, OnDestroy {
|
export class NetworkComponent extends BasePageComponent implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
|
private connections?: Connection[];
|
||||||
private netStatsBytesInChart?: Chart;
|
private netStatsBytesInChart?: Chart;
|
||||||
private netStatsBytesOutChart?: Chart;
|
private netStatsBytesOutChart?: Chart;
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ export class NetworkComponent extends BasePageComponent implements AfterViewInit
|
||||||
public setLimitError: string = '';
|
public setLimitError: string = '';
|
||||||
|
|
||||||
public currentNetStats: NetStats;
|
public currentNetStats: NetStats;
|
||||||
|
public getConnectionsError: string = '';
|
||||||
|
public refreshingConnectionsTable: boolean = false;
|
||||||
|
|
||||||
constructor(navbarService: NavbarService, private daemonService: DaemonService, private daemonData: DaemonDataService) {
|
constructor(navbarService: NavbarService, private daemonService: DaemonService, private daemonData: DaemonDataService) {
|
||||||
super(navbarService);
|
super(navbarService);
|
||||||
|
@ -49,10 +52,6 @@ export class NetworkComponent extends BasePageComponent implements AfterViewInit
|
||||||
this.refreshNetStatsHistory();
|
this.refreshNetStatsHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
const syncEndSub: Subscription = this.daemonData.syncEnd.subscribe(() => {
|
|
||||||
this.loadConnectionsTable();
|
|
||||||
});
|
|
||||||
|
|
||||||
const daemonStatusSub: Subscription = this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
|
const daemonStatusSub: Subscription = this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
|
||||||
if (!running) {
|
if (!running) {
|
||||||
if (this.netStatsBytesInChart) {
|
if (this.netStatsBytesInChart) {
|
||||||
|
@ -72,16 +71,31 @@ export class NetworkComponent extends BasePageComponent implements AfterViewInit
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.subscriptions.push(netStatsRefreshStartSub, syncEndSub, daemonStatusSub);
|
this.subscriptions.push(netStatsRefreshStartSub, daemonStatusSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngAfterViewInit(): void {
|
public ngAfterViewInit(): void {
|
||||||
this.initNetStatsHistoryChart();
|
this.initNetStatsHistoryChart();
|
||||||
|
this.refreshConnectionsTable().then().catch((error: any) => console.error(error));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async refreshConnectionsTable(): Promise<void> {
|
||||||
|
this.refreshingConnectionsTable = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.connections = await this.daemonService.getConnections();
|
||||||
|
}
|
||||||
|
catch(error: any) {
|
||||||
|
console.error(error);
|
||||||
|
this.connections = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
this.loadConnectionsTable();
|
this.loadConnectionsTable();
|
||||||
|
this.refreshingConnectionsTable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadConnectionsTable(): void {
|
private loadConnectionsTable(): void {
|
||||||
this.loadTable('connectionsTable', this.daemonData.connections);
|
this.loadTable('connectionsTable', this.connections ? this.connections : [], this.connections === undefined && this.getConnectionsError == '');
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildChartBytesInData(): ChartData {
|
private buildChartBytesInData(): ChartData {
|
||||||
|
|
|
@ -68,6 +68,12 @@
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr class="my-4">
|
||||||
|
|
||||||
|
<button *ngIf="!refreshingPublicNodes" class="w-100 btn btn-primary btn-lg" type="button" (click)="refreshPublicNodesTable()">Refresh Public Nodes</button>
|
||||||
|
<button *ngIf="refreshingPublicNodes" class="w-100 btn btn-primary btn-lg" type="button" disabled>Refreshing Public Nodes ...</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="tab-pane fade" id="pills-in-peers" role="tabpanel" aria-labelledby="pills-in-peers-tab" tabindex="0">
|
<div class="tab-pane fade" id="pills-in-peers" role="tabpanel" aria-labelledby="pills-in-peers-tab" tabindex="0">
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
||||||
import { NavbarService } from '../../shared/components/navbar/navbar.service';
|
import { NavbarService } from '../../shared/components/navbar/navbar.service';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { BasePageComponent } from '../base-page/base-page.component';
|
import { BasePageComponent } from '../base-page/base-page.component';
|
||||||
|
import { PeerInfo, PublicNode } from '../../../common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-peers',
|
selector: 'app-peers',
|
||||||
|
@ -25,6 +26,10 @@ export class PeersComponent extends BasePageComponent implements AfterViewInit {
|
||||||
public limitOutPeersResult: number = 0;
|
public limitOutPeersResult: number = 0;
|
||||||
|
|
||||||
public refreshingPeerList: boolean = false;
|
public refreshingPeerList: boolean = false;
|
||||||
|
public refreshingPublicNodes: boolean = false;
|
||||||
|
|
||||||
|
public getPeerListError: string = '';
|
||||||
|
public getPublicNodesError: string = '';
|
||||||
|
|
||||||
public get daemonRunning(): boolean {
|
public get daemonRunning(): boolean {
|
||||||
return this.daemonData.running;
|
return this.daemonData.running;
|
||||||
|
@ -34,6 +39,9 @@ export class PeersComponent extends BasePageComponent implements AfterViewInit {
|
||||||
return this.daemonData.stopping;
|
return this.daemonData.stopping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private peerList?: PeerInfo[];
|
||||||
|
private publicNodes?: PublicNode[];
|
||||||
|
|
||||||
constructor(private daemonService: DaemonService, private daemonData: DaemonDataService, navbarService: NavbarService, private ngZone: NgZone) {
|
constructor(private daemonService: DaemonService, private daemonData: DaemonDataService, navbarService: NavbarService, private ngZone: NgZone) {
|
||||||
super(navbarService);
|
super(navbarService);
|
||||||
this.setLinks([
|
this.setLinks([
|
||||||
|
@ -48,16 +56,15 @@ export class PeersComponent extends BasePageComponent implements AfterViewInit {
|
||||||
this.ngZone.run(() => {
|
this.ngZone.run(() => {
|
||||||
this.loadTables();
|
this.loadTables();
|
||||||
|
|
||||||
const sub: Subscription = this.daemonData.syncEnd.subscribe(() => {
|
this.refreshPeerListTable().then().catch((error: any) => console.error(error));
|
||||||
this.loadPublicNodesTable();
|
this.refreshPublicNodesTable().then().catch((error: any) => console.error(error));
|
||||||
});
|
|
||||||
|
|
||||||
const statusSub: Subscription = this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
|
const statusSub: Subscription = this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
|
||||||
if (running) this.loadTables();
|
if (running) this.loadTables();
|
||||||
else this.destroyTables();
|
else this.destroyTables();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.subscriptions.push(sub, statusSub);
|
this.subscriptions.push(statusSub);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,38 +74,47 @@ export class PeersComponent extends BasePageComponent implements AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadPeerListTable(): void {
|
private loadPeerListTable(): void {
|
||||||
this.loadTable('peerListTable', this.daemonData.peerList);
|
const loading = this.peerList === undefined;
|
||||||
|
|
||||||
|
this.loadTable('peerListTable', this.peerList ? this.peerList : [], loading);
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadPublicNodesTable(): void {
|
private loadPublicNodesTable(): void {
|
||||||
this.loadTable('publicNodesTable', this.daemonData.publicNodes);
|
this.loadTable('publicNodesTable', this.publicNodes ? this.publicNodes : [], this.publicNodes === undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async refreshPeerListTable(): Promise<void> {
|
public async refreshPeerListTable(): Promise<void> {
|
||||||
this.refreshingPeerList = true;
|
this.refreshingPeerList = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await new Promise<void>((resolve, reject) => {
|
this.peerList = await this.daemonService.getPeerList();
|
||||||
setTimeout(() => {
|
|
||||||
this.ngZone.run(() => {
|
|
||||||
try {
|
|
||||||
this.loadPeerListTable();
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
catch(error: any) {
|
|
||||||
reject(new Error(`${error}`));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
this.getPeerListError = `${error}`;
|
||||||
|
this.peerList = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.loadPeerListTable();
|
||||||
this.refreshingPeerList = false;
|
this.refreshingPeerList = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async refreshPublicNodesTable(): Promise<void> {
|
||||||
|
this.refreshingPublicNodes = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.publicNodes = await this.daemonService.getPublicNodes();
|
||||||
|
}
|
||||||
|
catch(error: any) {
|
||||||
|
console.error(error);
|
||||||
|
this.publicNodes = undefined;
|
||||||
|
this.getPublicNodesError = `${error}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadPublicNodesTable();
|
||||||
|
this.refreshingPublicNodes = false;
|
||||||
|
}
|
||||||
|
|
||||||
public async inPeers(): Promise<void> {
|
public async inPeers(): Promise<void> {
|
||||||
this.limitingInPeers = true;
|
this.limitingInPeers = true;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ export class DaemonStatusService {
|
||||||
|
|
||||||
public get daemonConfigured(): boolean {
|
public get daemonConfigured(): boolean {
|
||||||
return this.settings ? this.settings.monerodPath != '' : true;
|
return this.settings ? this.settings.monerodPath != '' : true;
|
||||||
};
|
}
|
||||||
|
|
||||||
public get disablingSync(): boolean {
|
public get disablingSync(): boolean {
|
||||||
return this.daemonService.disablingSync;
|
return this.daemonService.disablingSync;
|
||||||
|
|
Loading…
Reference in a new issue