Adding logger wrapper.

Log backend messages to syslog.
fixes #135
This commit is contained in:
softsimon
2020-10-13 15:27:52 +07:00
parent cd710d1002
commit fae1347db2
15 changed files with 238 additions and 66 deletions

View File

@@ -3,6 +3,7 @@ import * as fs from 'fs';
import * as process from 'process';
import memPool from './mempool';
import blocks from './blocks';
import logger from '../logger';
class DiskCache {
static FILE_NAME = './cache.json';
@@ -26,13 +27,13 @@ class DiskCache {
mempool: memPool.getMempool(),
blocks: blocks.getBlocks(),
}));
console.log('Mempool and blocks data saved to disk cache');
logger.info('Mempool and blocks data saved to disk cache');
}
loadMempoolCache() {
const cacheData = this.loadData();
if (cacheData) {
console.log('Restoring mempool and blocks data from disk cache');
logger.info('Restoring mempool and blocks data from disk cache');
const data = JSON.parse(cacheData);
memPool.setMempool(data.mempool);
blocks.setBlocks(data.blocks);