Write cache to disk on SIGTERM as with SIGINT.

This commit is contained in:
softsimon 2020-03-01 23:09:33 +07:00
parent 4d2ebcede9
commit 2382aa44e1

View file

@ -7,13 +7,22 @@ class DiskCache {
constructor() {
process.on('SIGINT', () => {
this.saveData(JSON.stringify({
mempool: memPool.getMempool(),
blocks: blocks.getBlocks(),
}));
console.log('Mempool and blocks data saved to disk cache');
this.saveCacheToDisk();
process.exit(2);
});
process.on('SIGTERM', () => {
this.saveCacheToDisk();
process.exit(2);
});
}
saveCacheToDisk() {
this.saveData(JSON.stringify({
mempool: memPool.getMempool(),
blocks: blocks.getBlocks(),
}));
console.log('Mempool and blocks data saved to disk cache');
}
loadMempoolCache() {