Bugfix: Mempool and blocks disk cache not saved on exit when using cluster.

This commit is contained in:
softsimon 2020-09-29 23:13:22 +07:00
parent 03dedabf2a
commit 15e75034f9

View File

@ -7,7 +7,6 @@ class DiskCache {
static FILE_NAME = './cache.json';
constructor() {
if (cluster.isMaster) {
process.on('SIGINT', () => {
this.saveCacheToDisk();
process.exit(2);
@ -18,7 +17,6 @@ class DiskCache {
process.exit(2);
});
}
}
saveCacheToDisk() {
this.saveData(JSON.stringify({
@ -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);
}
}
}