From f7ff6336f2fd739edb28aee0ab482ab4e07498f2 Mon Sep 17 00:00:00 2001 From: Bastien Date: Mon, 1 Feb 2021 15:54:27 +0100 Subject: [PATCH] Add CACHE_DIR var --- backend/mempool-config.sample.json | 3 ++- backend/src/api/disk-cache.ts | 5 +++-- backend/src/config.ts | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index c4cea1cbd..fe9122572 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -5,7 +5,8 @@ "HTTP_PORT": 8999, "SPAWN_CLUSTER_PROCS": 0, "API_URL_PREFIX": "/api/v1/", - "POLL_RATE_MS": 2000 + "POLL_RATE_MS": 2000, + "CACHE_DIR": "./" }, "CORE_RPC": { "HOST": "127.0.0.1", diff --git a/backend/src/api/disk-cache.ts b/backend/src/api/disk-cache.ts index 201391d84..98faf2a9b 100644 --- a/backend/src/api/disk-cache.ts +++ b/backend/src/api/disk-cache.ts @@ -5,10 +5,11 @@ import * as cluster from 'cluster'; import memPool from './mempool'; import blocks from './blocks'; import logger from '../logger'; +import config from '../config'; class DiskCache { - private static FILE_NAME = './cache.json'; - private static FILE_NAMES = './cache{number}.json'; + private static FILE_NAME = config.MEMPOOL.CACHE_DIR + 'cache.json'; + private static FILE_NAMES = config.MEMPOOL.CACHE_DIR + 'cache{number}.json'; private static CHUNK_SIZE = 10000; constructor() { if (!cluster.isMaster) { diff --git a/backend/src/config.ts b/backend/src/config.ts index d6546284a..314fcd7c3 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -8,6 +8,7 @@ interface IConfig { SPAWN_CLUSTER_PROCS: number; API_URL_PREFIX: string; POLL_RATE_MS: number; + CACHE_DIR: string; }; ESPLORA: { REST_API_URL: string; @@ -66,7 +67,8 @@ const defaults: IConfig = { 'HTTP_PORT': 8999, 'SPAWN_CLUSTER_PROCS': 0, 'API_URL_PREFIX': '/api/v1/', - 'POLL_RATE_MS': 2000 + 'POLL_RATE_MS': 2000, + 'CACHE_DIR': './' }, 'ESPLORA': { 'REST_API_URL': 'http://127.0.0.1:3000',