General fixes

This commit is contained in:
everoddandeven 2024-10-13 20:47:25 +02:00
parent 8ed6bb7036
commit bbcea66905
12 changed files with 108 additions and 69 deletions

View file

@ -69,7 +69,7 @@ function createWindow(): BrowserWindow {
icon: wdwIcon icon: wdwIcon
}); });
win.webContents.openDevTools(); //win.webContents.openDevTools();
//win.setIcon() //win.setIcon()
if (serve) { if (serve) {
@ -365,6 +365,11 @@ try {
isQuitting = true; isQuitting = true;
}); });
ipcMain.handle('quit', (event) => {
isQuitting = true;
app.quit();
});
ipcMain.handle('start-monerod', (event, configFilePath: string[]) => { ipcMain.handle('start-monerod', (event, configFilePath: string[]) => {
startMoneroDaemon(configFilePath); startMoneroDaemon(configFilePath);
}) })

View file

@ -44,5 +44,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
}, },
gotOsType: (callback) => { gotOsType: (callback) => {
ipcRenderer.on('got-os-type', callback); ipcRenderer.on('got-os-type', callback);
},
quit: () => {
ipcRenderer.invoke('quit');
} }
}); });

View file

@ -1,6 +1,6 @@
import { EventEmitter, Injectable } 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, NetStats, NetStatsHistory, PeerInfo, PublicNode, SyncInfo, TxPool } from '../../../../common'; import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetStats, NetStatsHistory, PeerInfo, PublicNode, SyncInfo, TxBacklogEntry, TxPool } from '../../../../common';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -57,6 +57,9 @@ export class DaemonDataService {
private _peerList: PeerInfo[] = []; private _peerList: PeerInfo[] = [];
private _gettingPeerList: boolean = false; private _gettingPeerList: boolean = false;
private _txPoolBacklog: TxBacklogEntry[] = [];
private _gettingTxPoolBackLog: boolean = false;
public readonly syncStart: EventEmitter<void> = new EventEmitter<void>(); public readonly syncStart: EventEmitter<void> = new EventEmitter<void>();
public readonly syncEnd: EventEmitter<void> = new EventEmitter<void>(); public readonly syncEnd: EventEmitter<void> = new EventEmitter<void>();
public readonly syncError: EventEmitter<Error> = new EventEmitter<Error>(); public readonly syncError: EventEmitter<Error> = new EventEmitter<Error>();
@ -67,15 +70,19 @@ export class DaemonDataService {
public readonly netStatsRefreshStart: EventEmitter<void> = new EventEmitter<void>(); public readonly netStatsRefreshStart: EventEmitter<void> = new EventEmitter<void>();
public readonly netStatsRefreshEnd: EventEmitter<void> = new EventEmitter<void>(); public readonly netStatsRefreshEnd: EventEmitter<void> = new EventEmitter<void>();
constructor(private daemonService: DaemonService) { constructor(private daemonService: DaemonService, private ngZone: NgZone) {
this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => { this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
if (running) { this.ngZone.run(() => {
this.startLoop(); if (running) {
} this._daemonRunning = true;
else { this.startLoop();
this.stopLoop(); }
} else {
this.stopLoop();
}
});
}); });
} }
@ -215,6 +222,14 @@ export class DaemonDataService {
return this._gettingPeerList; return this._gettingPeerList;
} }
public get txPoolBacklog(): TxBacklogEntry[] {
return this._txPoolBacklog;
}
public get gettingTxPoolBacklog(): boolean {
return this._gettingTxPoolBackLog;
}
public setRefreshTimeout(ms: number = 5000): void { public setRefreshTimeout(ms: number = 5000): void {
this.refreshTimeoutMs = ms; this.refreshTimeoutMs = ms;
} }
@ -313,6 +328,7 @@ export class DaemonDataService {
this._firstRefresh = false; this._firstRefresh = false;
if (!this._daemonRunning) { if (!this._daemonRunning) {
this.stopLoop();
this.syncEnd.emit(); this.syncEnd.emit();
return; return;
} }

View file

@ -89,7 +89,14 @@ export class BansComponent implements AfterViewInit {
let _bans: Ban[] = []; let _bans: Ban[] = [];
try { try {
_bans = await this.daemonService.getBans(); const running = await this.daemonService.isRunning();
if (running) {
_bans = await this.daemonService.getBans();
}
else {
_bans = [];
}
} }
catch (error) { catch (error) {
console.error(error); console.error(error);

View file

@ -21,7 +21,10 @@ export class BlockchainComponent implements AfterViewInit {
return this.daemonData.stopping; return this.daemonData.stopping;
} }
public lastBlockHeader?: BlockHeader; public get lastBlockHeader(): BlockHeader | undefined {
return this.daemonData.lastBlockHeader;
}
public getLastBlockError: string = ''; public getLastBlockError: string = '';
public block?: Block; public block?: Block;
public getBlockByHash: boolean = false; public getBlockByHash: boolean = false;
@ -64,28 +67,8 @@ export class BlockchainComponent implements AfterViewInit {
]; ];
} }
ngAfterViewInit(): void { public ngAfterViewInit(): void {
this.navbarService.setLinks(this.navbarLinks); this.navbarService.setLinks(this.navbarLinks);
this.load().then().catch((error: any) => {
console.error(error);
});
}
public async load(): Promise<void> {
await this.getLastBlockHeader();
}
private async getLastBlockHeader(): Promise<void> {
this.gettingLastBlock = true;
try {
this.lastBlockHeader = await this.daemonService.getLastBlockHeader(true);
this.getLastBlockError = '';
}
catch(error: any) {
console.error(error);
this.getLastBlockError = `${error}`;
}
this.gettingLastBlock = false;
} }
public async getBlock(): Promise<void> { public async getBlock(): Promise<void> {

View file

@ -25,8 +25,8 @@ export class LogsService {
} }
public cleanLog(message: string): string { public cleanLog(message: string): string {
//return message.replace(/\u001b\[[0-9;]*m/g, '').replace(/[\r\n]+/g, '\n').trim(); return message.replace(/\u001b\[[0-9;]*m/g, '').replace(/[\r\n]+/g, '\n').trim();
return message.replace(/[\r\n]+/g, '\n').trim(); //return message.replace(/[\r\n]+/g, '\n').trim();
} }
public log(message: string): void { public log(message: string): void {

View file

@ -201,6 +201,27 @@
</div> </div>
<div class="tab-pane fade" id="pills-tx-pool-backlog" role="tabpanel" aria-labelledby="pills-tx-pool-backlog-tab" tabindex="0">
<h4 class="mb-3">All transactions pool backlog</h4>
<br>
<table
id="txPoolBacklogTable"
data-toggle="txPoolBacklogTable"
data-toolbar="#toolbar"
data-paged="true"
data-height="460"
>
<thead>
<tr>
<th data-field="height">Blob Size</th>
<th data-field="key">Fee</th>
<th data-field="mask">Time In Pool</th>
</tr>
</thead>
</table>
</div>
<div class="tab-pane fade" id="pills-coinbase-tx-sum" role="tabpanel" aria-labelledby="pills-coinbase-tx-sum-tab" tabindex="0"> <div class="tab-pane fade" id="pills-coinbase-tx-sum" role="tabpanel" aria-labelledby="pills-coinbase-tx-sum-tab" tabindex="0">
<div class="row g-5 p-2"> <div class="row g-5 p-2">
<div class="col-md-7 col-lg-12"> <div class="col-md-7 col-lg-12">

View file

@ -17,7 +17,11 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
public readonly navbarLinks: NavbarLink[]; public readonly navbarLinks: NavbarLink[];
public canRelay: boolean; public canRelay: boolean;
public txPoolBacklog: TxBacklogEntry[];
public get txPoolBacklog(): TxBacklogEntry[] {
return this.daemonData.txPoolBacklog;
}
public height: number; public height: number;
public count: number; public count: number;
@ -80,14 +84,13 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
new NavbarLink('pills-relay-tx-tab', '#pills-relay-tx', 'pills-relay-tx', false, 'Relay Tx'), new NavbarLink('pills-relay-tx-tab', '#pills-relay-tx', 'pills-relay-tx', false, 'Relay Tx'),
new NavbarLink('pills-send-raw-tx-tab', '#pills-send-raw-tx', 'pills-send-raw-tx', false, 'Send Raw Tx'), new NavbarLink('pills-send-raw-tx-tab', '#pills-send-raw-tx', 'pills-send-raw-tx', false, 'Send Raw Tx'),
new NavbarLink('pills-get-fee-estimate-tab', '#pills-get-fee-estimate', 'pills-get-fee-estimate', false, 'Get Fee Estimate'), new NavbarLink('pills-get-fee-estimate-tab', '#pills-get-fee-estimate', 'pills-get-fee-estimate', false, 'Get Fee Estimate'),
new NavbarLink('pills-tx-backlog-tab', '#pills-tx-backlog', 'pills-tx-backlog', false, 'Tx Backlog'), new NavbarLink('pills-tx-pool-backlog-tab', '#pills-tx-pool-backlog', 'pills-tx-pool-backlog', false, 'Tx Pool Backlog'),
new NavbarLink('pills-coinbase-tx-sum-tab', '#pills-coinbase-tx-sum', 'pills-coinbase-tx-sum', false, 'Coinbase Tx Sum'), new NavbarLink('pills-coinbase-tx-sum-tab', '#pills-coinbase-tx-sum', 'pills-coinbase-tx-sum', false, 'Coinbase Tx Sum'),
new NavbarLink('pills-flush-tx-pool-tab', '#pills-flush-tx-pool', 'pills-flush-tx-pool', false, 'Flush Tx Pool'), new NavbarLink('pills-flush-tx-pool-tab', '#pills-flush-tx-pool', 'pills-flush-tx-pool', false, 'Flush Tx Pool'),
new NavbarLink('pills-flush-cahe-tab', '#pills-flush-cache', 'pills-flush-cache', false, 'Flush Cache') new NavbarLink('pills-flush-cahe-tab', '#pills-flush-cache', 'pills-flush-cache', false, 'Flush Cache')
]; ];
this.height = 0; this.height = 0;
this.count = 0; this.count = 0;
this.txPoolBacklog = [];
this.canRelay = false; this.canRelay = false;
} }
@ -95,18 +98,11 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
public ngAfterViewInit(): void { public ngAfterViewInit(): void {
this.ngZone.run(() => { this.ngZone.run(() => {
this.navbarService.setLinks(this.navbarLinks); this.navbarService.setLinks(this.navbarLinks);
this.initTables(); this.initTables();
this.subscriptions.push(this.daemonData.syncEnd.subscribe(() => { this.subscriptions.push(this.daemonData.syncEnd.subscribe(() => {
this.refreshTables(); this.refreshTables();
})); }));
this.load().then(() => {
this.navbarService.enableLinks();
}).catch((error) => {
console.error(error);
this.navbarService.disableLinks();
});
}); });
} }
@ -130,6 +126,7 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
private initTables(): void { private initTables(): void {
this.initTable('spentKeyImagesTable'); this.initTable('spentKeyImagesTable');
this.initTable('transactionsTable'); this.initTable('transactionsTable');
this.initTable('txPoolBacklogTable');
} }
private loadTransactionsTable(): void { private loadTransactionsTable(): void {
@ -144,19 +141,16 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
$table.bootstrapTable('load', this.spentKeyImages); $table.bootstrapTable('load', this.spentKeyImages);
} }
private loadTxPoolBacklogTable(): void {
const $table = $('#txPoolBacklogTable');
$table.bootstrapTable('load', this.txPoolBacklog)
}
private refreshTables(): void { private refreshTables(): void {
this.loadSpentKeyImagesTable(); this.loadSpentKeyImagesTable();
this.loadTransactionsTable(); this.loadTransactionsTable();
} this.loadTxPoolBacklogTable();
private async load(): Promise<void> {
try {
this.txPoolBacklog = await this.daemonService.getTxPoolBacklog();
console.log(this.txPoolBacklog)
}
catch (error) {
console.error(error);
}
} }
public validTxIds(): boolean { public validTxIds(): boolean {

View file

@ -47,7 +47,9 @@ export class DaemonNotRunningComponent {
}).catch((error: any) => { }).catch((error: any) => {
console.error(error); console.error(error);
this.daemonConfigured = false; this.daemonConfigured = false;
}) });
this.daemonService.isRunning().then().catch((error: any) => console.error(error));
} }
public async startDaemon(): Promise<void> { public async startDaemon(): Promise<void> {

View file

@ -72,6 +72,12 @@ export class NavbarComponent {
} }
public async quit(): Promise<void> { public async quit(): Promise<void> {
const running: boolean = await this.daemonService.isRunning();
if (running) {
await this.stopDaemon();
}
window.electronAPI.quit();
} }
} }

View file

@ -1,16 +1,16 @@
export class TxBacklogEntry { export class TxBacklogEntry {
public readonly blobSize: number; public readonly blobSize: number;
public readonly fee: number; public readonly fee: number;
public readonly timeInPool: number; public readonly timeInPool: number;
constructor(blobSize: number, fee: number, timeInPool: number) { constructor(blobSize: number, fee: number, timeInPool: number) {
this.blobSize = blobSize; this.blobSize = blobSize;
this.fee = fee; this.fee = fee;
this.timeInPool = timeInPool; this.timeInPool = timeInPool;
} }
public static fromBinary(binary: string): TxBacklogEntry[] { public static fromBinary(binary: string): TxBacklogEntry[] {
console.debug(binary); console.debug(binary);
throw new Error("TxBacklogEntry.fromBinary(): not implemented"); throw new Error("TxBacklogEntry.fromBinary(): not implemented");
} }
} }

View file

@ -58,8 +58,10 @@ import 'bootstrap-table';
declare global { declare global {
interface Window { interface Window {
electronAPI: { electronAPI: {
startMonerod: (args: string[]) => void;
getOsType: () => void; getOsType: () => void;
gotOsType: (callback: (event: any, osType: { platform: string, arch: string }) => void) => void; gotOsType: (callback: (event: any, osType: { platform: string, arch: string }) => void) => void;
quit: () => void;
}; };
} }
} }