From 816a29c5abe8a4c392e8400a04e27cac70995ca4 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sat, 16 Oct 2021 13:45:28 +0200 Subject: [PATCH] Added `--no-cache` command line parameter --- src/main.cpp | 1 + src/p2p_server.cpp | 2 +- src/params.cpp | 4 ++++ src/params.h | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 53f7134..0f61ec6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,7 @@ static void usage() "--config Name of the p2pool config file\n" "--data-api Path to the p2pool JSON data (use it in tandem with an external web-server)\n" "--stratum-api Enable /local/ path in api path for Stratum Server statistics\n" + "--no-cache Disable p2pool.cache\n" "--help Show this help message\n\n" "Example command line:\n\n" "%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n", diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index d401c0e..4987d02 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -42,7 +42,7 @@ namespace p2pool { P2PServer::P2PServer(p2pool* pool) : TCPServer(P2PClient::allocate) , m_pool(pool) - , m_cache(new BlockCache()) + , m_cache(pool->params().m_blockCache ? new BlockCache() : nullptr) , m_cacheLoaded(false) , m_initialPeerList(pool->params().m_p2pPeerList) , m_rd{} diff --git a/src/params.cpp b/src/params.cpp index ae8e71b..a017e14 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -73,6 +73,10 @@ Params::Params(int argc, char* argv[]) if (strcmp(argv[i], "--stratum-api") == 0) { m_localStats = true; } + + if (strcmp(argv[i], "--no-cache") == 0) { + m_blockCache = false; + } } if (m_stratumAddresses.empty()) { diff --git a/src/params.h b/src/params.h index afb7a98..ef60deb 100644 --- a/src/params.h +++ b/src/params.h @@ -38,6 +38,7 @@ struct Params std::string m_config; std::string m_apiPath; bool m_localStats = false; + bool m_blockCache = true; }; } // namespace p2pool