mirror of
https://github.com/mempool/mempool.git
synced 2025-01-17 18:52:34 +01:00
Bugfix: Mempool and blocks disk cache not saved on exit when using cluster.
This commit is contained in:
parent
7c6c330b02
commit
140fc0c5e1
@ -7,17 +7,15 @@ class DiskCache {
|
||||
static FILE_NAME = './cache.json';
|
||||
|
||||
constructor() {
|
||||
if (cluster.isMaster) {
|
||||
process.on('SIGINT', () => {
|
||||
this.saveCacheToDisk();
|
||||
process.exit(2);
|
||||
});
|
||||
process.on('SIGINT', () => {
|
||||
this.saveCacheToDisk();
|
||||
process.exit(2);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
this.saveCacheToDisk();
|
||||
process.exit(2);
|
||||
});
|
||||
}
|
||||
process.on('SIGTERM', () => {
|
||||
this.saveCacheToDisk();
|
||||
process.exit(2);
|
||||
});
|
||||
}
|
||||
|
||||
saveCacheToDisk() {
|
||||
@ -33,12 +31,8 @@ class DiskCache {
|
||||
if (cacheData) {
|
||||
console.log('Restoring mempool and blocks data from disk cache');
|
||||
const data = JSON.parse(cacheData);
|
||||
if (data.mempool) {
|
||||
memPool.setMempool(data.mempool);
|
||||
blocks.setBlocks(data.blocks);
|
||||
} else {
|
||||
memPool.setMempool(data);
|
||||
}
|
||||
memPool.setMempool(data.mempool);
|
||||
blocks.setBlocks(data.blocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user