mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 06:47:52 +01:00
Merge pull request #4698 from mempool/mononaut/bg-goggles-indexing
Continue other indexing tasks while Goggles classification runs
This commit is contained in:
commit
18e412939d
2 changed files with 10 additions and 1 deletions
|
@ -40,6 +40,7 @@ class Blocks {
|
||||||
private quarterEpochBlockTime: number | null = null;
|
private quarterEpochBlockTime: number | null = null;
|
||||||
private newBlockCallbacks: ((block: BlockExtended, txIds: string[], transactions: TransactionExtended[]) => void)[] = [];
|
private newBlockCallbacks: ((block: BlockExtended, txIds: string[], transactions: TransactionExtended[]) => void)[] = [];
|
||||||
private newAsyncBlockCallbacks: ((block: BlockExtended, txIds: string[], transactions: MempoolTransactionExtended[]) => Promise<void>)[] = [];
|
private newAsyncBlockCallbacks: ((block: BlockExtended, txIds: string[], transactions: MempoolTransactionExtended[]) => Promise<void>)[] = [];
|
||||||
|
private classifyingBlocks: boolean = false;
|
||||||
|
|
||||||
private mainLoopTimeout: number = 120000;
|
private mainLoopTimeout: number = 120000;
|
||||||
|
|
||||||
|
@ -568,6 +569,11 @@ class Blocks {
|
||||||
* [INDEXING] Index transaction classification flags for Goggles
|
* [INDEXING] Index transaction classification flags for Goggles
|
||||||
*/
|
*/
|
||||||
public async $classifyBlocks(): Promise<void> {
|
public async $classifyBlocks(): Promise<void> {
|
||||||
|
if (this.classifyingBlocks) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.classifyingBlocks = true;
|
||||||
|
|
||||||
// classification requires an esplora backend
|
// classification requires an esplora backend
|
||||||
if (!Common.gogglesIndexingEnabled() || config.MEMPOOL.BACKEND !== 'esplora') {
|
if (!Common.gogglesIndexingEnabled() || config.MEMPOOL.BACKEND !== 'esplora') {
|
||||||
return;
|
return;
|
||||||
|
@ -679,6 +685,8 @@ class Blocks {
|
||||||
indexedThisRun = 0;
|
indexedThisRun = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.classifyingBlocks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -185,7 +185,8 @@ class Indexer {
|
||||||
await blocks.$generateCPFPDatabase();
|
await blocks.$generateCPFPDatabase();
|
||||||
await blocks.$generateAuditStats();
|
await blocks.$generateAuditStats();
|
||||||
await auditReplicator.$sync();
|
await auditReplicator.$sync();
|
||||||
await blocks.$classifyBlocks();
|
// do not wait for classify blocks to finish
|
||||||
|
blocks.$classifyBlocks();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.indexerRunning = false;
|
this.indexerRunning = false;
|
||||||
logger.err(`Indexer failed, trying again in 10 seconds. Reason: ` + (e instanceof Error ? e.message : e));
|
logger.err(`Indexer failed, trying again in 10 seconds. Reason: ` + (e instanceof Error ? e.message : e));
|
||||||
|
|
Loading…
Add table
Reference in a new issue