mirror of
https://github.com/mempool/mempool.git
synced 2025-01-18 05:12:35 +01:00
Removing unnused config MINED_BLOCKS_CACHE.
This commit is contained in:
parent
200e68f15a
commit
b21016efef
@ -2,7 +2,6 @@
|
|||||||
"MEMPOOL": {
|
"MEMPOOL": {
|
||||||
"NETWORK": "mainnet",
|
"NETWORK": "mainnet",
|
||||||
"HTTP_PORT": 8999,
|
"HTTP_PORT": 8999,
|
||||||
"MINED_BLOCKS_CACHE": 144,
|
|
||||||
"SPAWN_CLUSTER_PROCS": 0,
|
"SPAWN_CLUSTER_PROCS": 0,
|
||||||
"API_URL_PREFIX": "/api/v1/",
|
"API_URL_PREFIX": "/api/v1/",
|
||||||
"WEBSOCKET_REFRESH_RATE_MS": 2000
|
"WEBSOCKET_REFRESH_RATE_MS": 2000
|
||||||
|
@ -6,8 +6,7 @@ import { Common } from './common';
|
|||||||
import diskCache from './disk-cache';
|
import diskCache from './disk-cache';
|
||||||
|
|
||||||
class Blocks {
|
class Blocks {
|
||||||
private static INITIAL_BLOCK_AMOUNT = 8;
|
private static KEEP_BLOCK_AMOUNT = 8;
|
||||||
private static KEEP_BLOCK_AMOUNT = 24;
|
|
||||||
private blocks: Block[] = [];
|
private blocks: Block[] = [];
|
||||||
private currentBlockHeight = 0;
|
private currentBlockHeight = 0;
|
||||||
private lastDifficultyAdjustmentTime = 0;
|
private lastDifficultyAdjustmentTime = 0;
|
||||||
@ -31,14 +30,14 @@ class Blocks {
|
|||||||
const blockHeightTip = await bitcoinApi.getBlockHeightTip();
|
const blockHeightTip = await bitcoinApi.getBlockHeightTip();
|
||||||
|
|
||||||
if (this.blocks.length === 0) {
|
if (this.blocks.length === 0) {
|
||||||
this.currentBlockHeight = blockHeightTip - Blocks.INITIAL_BLOCK_AMOUNT;
|
this.currentBlockHeight = blockHeightTip - Blocks.KEEP_BLOCK_AMOUNT;
|
||||||
} else {
|
} else {
|
||||||
this.currentBlockHeight = this.blocks[this.blocks.length - 1].height;
|
this.currentBlockHeight = this.blocks[this.blocks.length - 1].height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockHeightTip - this.currentBlockHeight > Blocks.INITIAL_BLOCK_AMOUNT * 2) {
|
if (blockHeightTip - this.currentBlockHeight > Blocks.KEEP_BLOCK_AMOUNT * 2) {
|
||||||
logger.info(`${blockHeightTip - this.currentBlockHeight} blocks since tip. Fast forwarding to the ${Blocks.INITIAL_BLOCK_AMOUNT} recent blocks`);
|
logger.info(`${blockHeightTip - this.currentBlockHeight} blocks since tip. Fast forwarding to the ${Blocks.KEEP_BLOCK_AMOUNT} recent blocks`);
|
||||||
this.currentBlockHeight = blockHeightTip - Blocks.INITIAL_BLOCK_AMOUNT;
|
this.currentBlockHeight = blockHeightTip - Blocks.KEEP_BLOCK_AMOUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.lastDifficultyAdjustmentTime) {
|
if (!this.lastDifficultyAdjustmentTime) {
|
||||||
|
@ -9,7 +9,6 @@ import fiatConversion from './fiat-conversion';
|
|||||||
import { Common } from './common';
|
import { Common } from './common';
|
||||||
|
|
||||||
class WebsocketHandler {
|
class WebsocketHandler {
|
||||||
private static INITIAL_BLOCK_AMOUNT = 8;
|
|
||||||
private wss: WebSocket.Server | undefined;
|
private wss: WebSocket.Server | undefined;
|
||||||
private nativeAssetId = '6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
|
private nativeAssetId = '6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d';
|
||||||
private extraInitProperties = {};
|
private extraInitProperties = {};
|
||||||
@ -85,7 +84,7 @@ class WebsocketHandler {
|
|||||||
'mempoolInfo': memPool.getMempoolInfo(),
|
'mempoolInfo': memPool.getMempoolInfo(),
|
||||||
'vBytesPerSecond': memPool.getVBytesPerSecond(),
|
'vBytesPerSecond': memPool.getVBytesPerSecond(),
|
||||||
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
|
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
|
||||||
'blocks': _blocks.slice(Math.max(_blocks.length - WebsocketHandler.INITIAL_BLOCK_AMOUNT, 0)),
|
'blocks': _blocks,
|
||||||
'conversions': fiatConversion.getTickers()['BTCUSD'],
|
'conversions': fiatConversion.getTickers()['BTCUSD'],
|
||||||
'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
|
'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
|
||||||
'transactions': memPool.getLatestTransactions(),
|
'transactions': memPool.getLatestTransactions(),
|
||||||
|
@ -4,7 +4,6 @@ interface IConfig {
|
|||||||
MEMPOOL: {
|
MEMPOOL: {
|
||||||
NETWORK: 'mainnet' | 'testnet' | 'liquid';
|
NETWORK: 'mainnet' | 'testnet' | 'liquid';
|
||||||
HTTP_PORT: number;
|
HTTP_PORT: number;
|
||||||
MINED_BLOCKS_CACHE: number;
|
|
||||||
SPAWN_CLUSTER_PROCS: number;
|
SPAWN_CLUSTER_PROCS: number;
|
||||||
API_URL_PREFIX: string;
|
API_URL_PREFIX: string;
|
||||||
WEBSOCKET_REFRESH_RATE_MS: number;
|
WEBSOCKET_REFRESH_RATE_MS: number;
|
||||||
@ -46,7 +45,6 @@ const defaults: IConfig = {
|
|||||||
'MEMPOOL': {
|
'MEMPOOL': {
|
||||||
'NETWORK': 'mainnet',
|
'NETWORK': 'mainnet',
|
||||||
'HTTP_PORT': 8999,
|
'HTTP_PORT': 8999,
|
||||||
'MINED_BLOCKS_CACHE': 144,
|
|
||||||
'SPAWN_CLUSTER_PROCS': 0,
|
'SPAWN_CLUSTER_PROCS': 0,
|
||||||
'API_URL_PREFIX': '/api/v1/',
|
'API_URL_PREFIX': '/api/v1/',
|
||||||
'WEBSOCKET_REFRESH_RATE_MS': 2000
|
'WEBSOCKET_REFRESH_RATE_MS': 2000
|
||||||
|
Loading…
Reference in New Issue
Block a user