mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 09:39:17 +01:00
await for mempool change handler after loading disk cache
This commit is contained in:
parent
ba4253da79
commit
f30cf70226
4 changed files with 6 additions and 6 deletions
|
@ -124,7 +124,7 @@ class DiskCache {
|
|||
}
|
||||
}
|
||||
|
||||
loadMempoolCache(): void {
|
||||
async loadMempoolCache(): Promise<void> {
|
||||
if (!fs.existsSync(DiskCache.FILE_NAME)) {
|
||||
return;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class DiskCache {
|
|||
}
|
||||
}
|
||||
|
||||
memPool.setMempool(data.mempool);
|
||||
await memPool.setMempool(data.mempool);
|
||||
blocks.setBlocks(data.blocks);
|
||||
blocks.setBlockSummaries(data.blockSummaries || []);
|
||||
} catch (e) {
|
||||
|
|
|
@ -205,7 +205,7 @@ class MempoolBlocks {
|
|||
public async updateBlockTemplates(newMempool: { [txid: string]: TransactionExtended }, added: TransactionExtended[], removed: string[], saveResults: boolean = false): Promise<void> {
|
||||
if (!this.txSelectionWorker) {
|
||||
// need to reset the worker
|
||||
this.makeBlockTemplates(newMempool, saveResults);
|
||||
await this.makeBlockTemplates(newMempool, saveResults);
|
||||
return;
|
||||
}
|
||||
// prepare a stripped down version of the mempool with only the minimum necessary data
|
||||
|
|
|
@ -80,13 +80,13 @@ class Mempool {
|
|||
return this.mempoolCache;
|
||||
}
|
||||
|
||||
public setMempool(mempoolData: { [txId: string]: TransactionExtended }) {
|
||||
public async setMempool(mempoolData: { [txId: string]: TransactionExtended }) {
|
||||
this.mempoolCache = mempoolData;
|
||||
if (this.mempoolChangedCallback) {
|
||||
this.mempoolChangedCallback(this.mempoolCache, [], []);
|
||||
}
|
||||
if (this.asyncMempoolChangedCallback) {
|
||||
this.asyncMempoolChangedCallback(this.mempoolCache, [], []);
|
||||
await this.asyncMempoolChangedCallback(this.mempoolCache, [], []);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class Server {
|
|||
await poolsUpdater.updatePoolsJson(); // Needs to be done before loading the disk cache because we sometimes wipe it
|
||||
await syncAssets.syncAssets$();
|
||||
if (config.MEMPOOL.ENABLED) {
|
||||
diskCache.loadMempoolCache();
|
||||
await diskCache.loadMempoolCache();
|
||||
}
|
||||
|
||||
if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED && cluster.isPrimary) {
|
||||
|
|
Loading…
Add table
Reference in a new issue