diff --git a/src/app/pages/transactions/transactions.component.html b/src/app/pages/transactions/transactions.component.html index 3d292c7..1e13695 100644 --- a/src/app/pages/transactions/transactions.component.html +++ b/src/app/pages/transactions/transactions.component.html @@ -273,6 +273,20 @@

Get coinbase tx sum

+ + + +

Flush a list of transaction IDs

@@ -280,14 +294,14 @@

Flush a list of transaction IDs

- - + rows="15" cols="15" [(ngModel)]="flushTxIdsJsonString" [ngModelOptions]="{ standalone: true }"> List of transaction IDs to flush in tx pool
@@ -297,35 +311,54 @@

Flush a list of transaction IDs

- + +
+ + + +
-

Flush a list of bad transaction IDs from cache

+

Flush bad transactions / blocks from the cache

-
+
+ + +
+ + +
+ Flush bad transactions +
+ -
- - - List of bad transaction IDs to flush from cache -
- +
+ + +
+ Flush bad blocks +
+
- +
diff --git a/src/app/pages/transactions/transactions.component.ts b/src/app/pages/transactions/transactions.component.ts index cdfe633..56ac7fb 100644 --- a/src/app/pages/transactions/transactions.component.ts +++ b/src/app/pages/transactions/transactions.component.ts @@ -165,12 +165,80 @@ export class TransactionsComponent extends BasePageComponent implements AfterVie await this.daemonService.relayTx(...txIds); } - public async onFlush(): Promise { + public flushing: boolean = false; + public flushSuccess: boolean = true; + public flushError: string = ''; + public flushTxIdsJsonString: string = ''; + public get validFlushTxIds(): boolean { + try { + const txIds: any[] = JSON.parse(this.flushTxIdsJsonString); + + if (!Array.isArray(txIds) || txIds.length == 0) { + return false; + } + + let valid: boolean = true; + + txIds.forEach((txId: string) => { + if (typeof txId != 'string' || txId == '') { + valid = false; + } + }); + + return valid; + } + catch { + return false; + } } - public async onFlushFromCache(): Promise { + private get flushTxIds(): string[] { + if (!this.validFlushTxIds) { + return []; + } + + const txIds: string[] = JSON.parse(this.flushTxIdsJsonString); + + return txIds; + } + + public async flush(): Promise { + this.flushing = true; + + try { + await this.daemonService.flushTxPool(...this.flushTxIds); + this.flushError = ''; + this.flushSuccess = true; + } + catch(error) { + this.flushSuccess = false; + this.flushError = `${error}`; + } + + this.flushing = false; + } + + public flushingCache: boolean = false; + public flushCacheBadTxs: boolean = false; + public flushCacheBadBlocks: boolean = false; + public flushCacheSuccess: boolean = false; + public flushCacheError: string = ''; + + public async flushCache(): Promise { + this.flushingCache = true; + + try { + await this.daemonService.flushCache(this.flushCacheBadTxs, this.flushCacheBadBlocks); + this.flushCacheError = ''; + this.flushCacheSuccess = true; + } + catch(error) { + this.flushCacheSuccess = false; + this.flushCacheError = `${error}`; + } + this.flushingCache = false; }