Write cache.json on startup if it doesn't exist.

Write mempool and block data to cache on every new block
fixes #146
This commit is contained in:
softsimon
2020-10-27 00:05:06 +07:00
parent cd3ffba248
commit 2365c9686d
2 changed files with 46 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ import logger from '../logger';
import memPool from './mempool';
import { Block, TransactionExtended, TransactionMinerInfo } from '../interfaces';
import { Common } from './common';
import diskCache from './disk-cache';
class Blocks {
private static INITIAL_BLOCK_AMOUNT = 8;
@@ -99,6 +100,7 @@ class Blocks {
if (this.newBlockCallbacks.length) {
this.newBlockCallbacks.forEach((cb) => cb(block, txIds, transactions));
}
diskCache.$saveCacheToDiskAsync();
}
}