Clear redis block cache on pool update
This commit is contained in:
parent
04559e7b98
commit
c54bc5a4bb
@ -7,6 +7,7 @@ import diskCache from './disk-cache';
|
|||||||
import mining from './mining/mining';
|
import mining from './mining/mining';
|
||||||
import transactionUtils from './transaction-utils';
|
import transactionUtils from './transaction-utils';
|
||||||
import BlocksRepository from '../repositories/BlocksRepository';
|
import BlocksRepository from '../repositories/BlocksRepository';
|
||||||
|
import redisCache from './redis-cache';
|
||||||
|
|
||||||
class PoolsParser {
|
class PoolsParser {
|
||||||
miningPools: any[] = [];
|
miningPools: any[] = [];
|
||||||
@ -45,6 +46,7 @@ class PoolsParser {
|
|||||||
// We also need to wipe the backend cache to make sure we don't serve blocks with
|
// We also need to wipe the backend cache to make sure we don't serve blocks with
|
||||||
// the wrong mining pool (usually happen with unknown blocks)
|
// the wrong mining pool (usually happen with unknown blocks)
|
||||||
diskCache.setIgnoreBlocksCache();
|
diskCache.setIgnoreBlocksCache();
|
||||||
|
redisCache.setIgnoreBlocksCache();
|
||||||
|
|
||||||
await this.$insertUnknownPool();
|
await this.$insertUnknownPool();
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class RedisCache {
|
|||||||
private rbfCacheQueue: { type: string, txid: string, value: any }[] = [];
|
private rbfCacheQueue: { type: string, txid: string, value: any }[] = [];
|
||||||
private rbfRemoveQueue: { type: string, txid: string }[] = [];
|
private rbfRemoveQueue: { type: string, txid: string }[] = [];
|
||||||
private txFlushLimit: number = 10000;
|
private txFlushLimit: number = 10000;
|
||||||
|
private ignoreBlocksCache = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (config.REDIS.ENABLED) {
|
if (config.REDIS.ENABLED) {
|
||||||
@ -341,9 +342,7 @@ class RedisCache {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.info('Restoring mempool and blocks data from Redis cache');
|
logger.info('Restoring mempool and blocks data from Redis cache');
|
||||||
// Load block data
|
|
||||||
const loadedBlocks = await this.$getBlocks();
|
|
||||||
const loadedBlockSummaries = await this.$getBlockSummaries();
|
|
||||||
// Load mempool
|
// Load mempool
|
||||||
const loadedMempool = await this.$getMempool();
|
const loadedMempool = await this.$getMempool();
|
||||||
this.inflateLoadedTxs(loadedMempool);
|
this.inflateLoadedTxs(loadedMempool);
|
||||||
@ -352,9 +351,14 @@ class RedisCache {
|
|||||||
const rbfTrees = await this.$getRbfEntries('tree');
|
const rbfTrees = await this.$getRbfEntries('tree');
|
||||||
const rbfExpirations = await this.$getRbfEntries('exp');
|
const rbfExpirations = await this.$getRbfEntries('exp');
|
||||||
|
|
||||||
// Set loaded data
|
// Load & set block data
|
||||||
blocks.setBlocks(loadedBlocks || []);
|
if (!this.ignoreBlocksCache) {
|
||||||
blocks.setBlockSummaries(loadedBlockSummaries || []);
|
const loadedBlocks = await this.$getBlocks();
|
||||||
|
const loadedBlockSummaries = await this.$getBlockSummaries();
|
||||||
|
blocks.setBlocks(loadedBlocks || []);
|
||||||
|
blocks.setBlockSummaries(loadedBlockSummaries || []);
|
||||||
|
}
|
||||||
|
// Set other data
|
||||||
await memPool.$setMempool(loadedMempool);
|
await memPool.$setMempool(loadedMempool);
|
||||||
await rbfCache.load({
|
await rbfCache.load({
|
||||||
txs: rbfTxs,
|
txs: rbfTxs,
|
||||||
@ -411,6 +415,10 @@ class RedisCache {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setIgnoreBlocksCache(): void {
|
||||||
|
this.ignoreBlocksCache = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new RedisCache();
|
export default new RedisCache();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user