mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
Added --data-dir
command line option
Some checks are pending
C/C++ CI / build-ubuntu (map[c:gcc-8 cpp:g++-8 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-static-libs (map[flags:-fuse-linker-plugin -ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:aarch64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline -mfix-cortex-a53-835769 -mfix-cortex-a53-843419]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:riscv64 branch:edge flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:x86_64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-11 cpp:g++-11 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-12 cpp:g++-12 flags: os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:clang cxx:clang++ flags:-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:gcc cxx:g++ flags:-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:OFF upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
Sync test / sync-test-macos (map[flags: os:macos-13]) (push) Waiting to run
Sync test / sync-test-macos (map[flags:-target arm64-apple-macos-11 os:macos-14]) (push) Waiting to run
Sync test / sync-test-windows-debug-asan (push) Waiting to run
Sync test / sync-test-windows-leaks (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2022 rx:ON tls:ON upnp:ON vs:Visual Studio 17 2022 vspath:C:\Program Files\Microsoft Visual Studio\2022\Enterprise]) (push) Waiting to run
C/C++ CI / build-macos (push) Waiting to run
C/C++ CI / build-macos-aarch64 (push) Waiting to run
C/C++ CI / build-freebsd (map[architecture:x86-64 host:ubuntu-latest name:freebsd version:13.3]) (push) Waiting to run
C/C++ CI / build-openbsd (map[architecture:x86-64 host:ubuntu-latest name:openbsd version:7.4]) (push) Waiting to run
clang-tidy / clang-tidy (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
cppcheck / cppcheck-ubuntu (push) Waiting to run
cppcheck / cppcheck-windows (push) Waiting to run
Microsoft C++ Code Analysis / Analyze (push) Waiting to run
source-snapshot / source-snapshot (push) Waiting to run
Sync test / sync-test-ubuntu-tsan (push) Waiting to run
Sync test / sync-test-ubuntu-msan (push) Waiting to run
Sync test / sync-test-ubuntu-ubsan (push) Waiting to run
Sync test / sync-test-ubuntu-asan (push) Waiting to run
Some checks are pending
C/C++ CI / build-ubuntu (map[c:gcc-8 cpp:g++-8 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-static-libs (map[flags:-fuse-linker-plugin -ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:aarch64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline -mfix-cortex-a53-835769 -mfix-cortex-a53-843419]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:riscv64 branch:edge flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:x86_64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-11 cpp:g++-11 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-12 cpp:g++-12 flags: os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:clang cxx:clang++ flags:-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:gcc cxx:g++ flags:-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:OFF upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
Sync test / sync-test-macos (map[flags: os:macos-13]) (push) Waiting to run
Sync test / sync-test-macos (map[flags:-target arm64-apple-macos-11 os:macos-14]) (push) Waiting to run
Sync test / sync-test-windows-debug-asan (push) Waiting to run
Sync test / sync-test-windows-leaks (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2022 rx:ON tls:ON upnp:ON vs:Visual Studio 17 2022 vspath:C:\Program Files\Microsoft Visual Studio\2022\Enterprise]) (push) Waiting to run
C/C++ CI / build-macos (push) Waiting to run
C/C++ CI / build-macos-aarch64 (push) Waiting to run
C/C++ CI / build-freebsd (map[architecture:x86-64 host:ubuntu-latest name:freebsd version:13.3]) (push) Waiting to run
C/C++ CI / build-openbsd (map[architecture:x86-64 host:ubuntu-latest name:openbsd version:7.4]) (push) Waiting to run
clang-tidy / clang-tidy (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
cppcheck / cppcheck-ubuntu (push) Waiting to run
cppcheck / cppcheck-windows (push) Waiting to run
Microsoft C++ Code Analysis / Analyze (push) Waiting to run
source-snapshot / source-snapshot (push) Waiting to run
Sync test / sync-test-ubuntu-tsan (push) Waiting to run
Sync test / sync-test-ubuntu-msan (push) Waiting to run
Sync test / sync-test-ubuntu-ubsan (push) Waiting to run
Sync test / sync-test-ubuntu-asan (push) Waiting to run
This commit is contained in:
parent
fb8e2a71e0
commit
921611ff4d
10 changed files with 61 additions and 21 deletions
|
@ -10,8 +10,9 @@
|
|||
--addpeers Comma-separated list of IP:port of other p2pool nodes to connect to
|
||||
--light-mode Don't allocate RandomX dataset, saves 2GB of RAM
|
||||
--loglevel Verbosity of the log, integer number between 0 and 6
|
||||
--data-dir Path to store general p2pool files (log, cache, peer data, etc.), default is current directory
|
||||
--config Name of p2pool sidechain's config file (don't use it unless you want to mine to a different p2pool chain)
|
||||
--data-api Path to the p2pool JSON data (use it in tandem with an external web-server)
|
||||
--data-api Path to the p2pool JSON data (use it in tandem with an external web-server). Not affected by --data-dir setting!
|
||||
--local-api Enable /local/ path in api path for Stratum Server and built-in miner statistics
|
||||
--stratum-api An alias for --local-api
|
||||
--no-cache Disable p2pool.cache
|
||||
|
|
|
@ -36,9 +36,11 @@ struct BlockCache::Impl : public nocopy_nomove
|
|||
|
||||
Impl()
|
||||
{
|
||||
m_fd = open(cache_name, O_RDWR | O_CREAT, static_cast<mode_t>(0600));
|
||||
const std::string cache_path = DATA_DIR + cache_name;
|
||||
|
||||
m_fd = open(cache_path.c_str(), O_RDWR | O_CREAT, static_cast<mode_t>(0600));
|
||||
if (m_fd == -1) {
|
||||
LOGERR(1, "couldn't open/create " << cache_name);
|
||||
LOGERR(1, "couldn't open/create " << cache_path << ": error " << errno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,11 +89,12 @@ struct BlockCache::Impl : public nocopy_nomove
|
|||
#elif defined(_WIN32)
|
||||
|
||||
Impl()
|
||||
: m_file(CreateFile(cache_name, GENERIC_ALL, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL))
|
||||
: m_cachePath(DATA_DIR + cache_name)
|
||||
, m_file(CreateFile(m_cachePath.c_str(), GENERIC_ALL, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL))
|
||||
, m_map(0)
|
||||
{
|
||||
if (m_file == INVALID_HANDLE_VALUE) {
|
||||
LOGERR(1, "couldn't open " << cache_name << ", error " << static_cast<uint32_t>(GetLastError()));
|
||||
LOGERR(1, "couldn't open " << m_cachePath << ": error " << static_cast<uint32_t>(GetLastError()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -142,6 +145,7 @@ struct BlockCache::Impl : public nocopy_nomove
|
|||
}
|
||||
}
|
||||
|
||||
std::string m_cachePath;
|
||||
HANDLE m_file;
|
||||
HANDLE m_map;
|
||||
|
||||
|
|
22
src/log.cpp
22
src/log.cpp
|
@ -127,7 +127,12 @@ public:
|
|||
|
||||
std::setlocale(LC_ALL, "en_001");
|
||||
|
||||
m_logFile.open(log_file_name, std::ios::app | std::ios::binary);
|
||||
m_logFilePath = DATA_DIR + log_file_name;
|
||||
m_logFile.open(m_logFilePath, std::ios::app | std::ios::binary);
|
||||
|
||||
if (!m_logFile.is_open()) {
|
||||
fprintf(stderr, "failed to open %s: error %d\n", m_logFilePath.c_str(), errno);
|
||||
}
|
||||
|
||||
m_buf.resize(BUF_SIZE);
|
||||
|
||||
|
@ -148,10 +153,6 @@ public:
|
|||
CONSOLE_COLORS = false;
|
||||
}
|
||||
|
||||
if (!m_logFile.is_open()) {
|
||||
fprintf(stderr, "failed to open %s\n", log_file_name);
|
||||
}
|
||||
|
||||
init_uv_threadpool();
|
||||
|
||||
const int err = uv_thread_create(&m_worker, run_wrapper, this);
|
||||
|
@ -216,6 +217,8 @@ public:
|
|||
uv_cond_signal(&m_cond);
|
||||
}
|
||||
|
||||
const std::string& log_file_path() const { return m_logFilePath; }
|
||||
|
||||
private:
|
||||
static void init_uv_threadpool()
|
||||
{
|
||||
|
@ -324,9 +327,9 @@ private:
|
|||
|
||||
// Reopen the log file if it's been moved (logrotate support)
|
||||
struct stat buf;
|
||||
if (stat(log_file_name, &buf) != 0) {
|
||||
if (stat(m_logFilePath.c_str(), &buf) != 0) {
|
||||
m_logFile.close();
|
||||
m_logFile.open(log_file_name, std::ios::app | std::ios::binary);
|
||||
m_logFile.open(m_logFilePath, std::ios::app | std::ios::binary);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,6 +376,7 @@ private:
|
|||
bool m_stopped;
|
||||
|
||||
std::ofstream m_logFile;
|
||||
std::string m_logFilePath;
|
||||
};
|
||||
|
||||
static Worker* worker = nullptr;
|
||||
|
@ -438,7 +442,9 @@ void start()
|
|||
void reopen()
|
||||
{
|
||||
// This will trigger the worker thread which will then reopen log file if it's been moved
|
||||
LOGINFO(0, "reopening " << log_file_name);
|
||||
#ifndef P2POOL_LOG_DISABLE
|
||||
LOGINFO(0, "reopening " << worker->log_file_path());
|
||||
#endif
|
||||
}
|
||||
|
||||
void stop()
|
||||
|
|
17
src/main.cpp
17
src/main.cpp
|
@ -47,8 +47,9 @@ void p2pool_usage()
|
|||
"--addpeers Comma-separated list of IP:port of other p2pool nodes to connect to\n"
|
||||
"--light-mode Don't allocate RandomX dataset, saves 2GB of RAM\n"
|
||||
"--loglevel Verbosity of the log, integer number between 0 and %d\n"
|
||||
"--data-dir Path to store general p2pool files (log, cache, peer data, etc.), default is current directory\n"
|
||||
"--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"
|
||||
"--data-api Path to the p2pool JSON data (use it in tandem with an external web-server). Not affected by --data-dir setting!\n"
|
||||
"--local-api Enable /local/ path in api path for Stratum Server and built-in miner statistics\n"
|
||||
"--stratum-api An alias for --local-api\n"
|
||||
"--no-cache Disable p2pool.cache\n"
|
||||
|
@ -194,6 +195,20 @@ int main(int argc, char* argv[])
|
|||
if (!strcmp(argv[i], "--test")) {
|
||||
return p2pool_test();
|
||||
}
|
||||
|
||||
if ((strcmp(argv[i], "--data-dir") == 0) && (i + 1 < argc)) {
|
||||
std::string path = argv[++i];
|
||||
|
||||
if (!path.empty() && (path.back() != '/')
|
||||
#ifdef _WIN32
|
||||
&& (path.back() != '\\')
|
||||
#endif
|
||||
) {
|
||||
path.append(1, '/');
|
||||
}
|
||||
|
||||
p2pool::DATA_DIR = std::move(path);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER) && !defined(NDEBUG)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "mempool.h"
|
||||
#include "util.h"
|
||||
|
||||
LOG_CATEGORY(Mempool)
|
||||
|
||||
|
|
|
@ -447,10 +447,12 @@ void P2PServer::save_peer_list_async()
|
|||
|
||||
void P2PServer::save_peer_list()
|
||||
{
|
||||
std::ofstream f(saved_peer_list_file_name, std::ios::binary);
|
||||
const std::string path = DATA_DIR + saved_peer_list_file_name;
|
||||
|
||||
std::ofstream f(path, std::ios::binary);
|
||||
|
||||
if (!f.is_open()) {
|
||||
LOGERR(1, "failed to save peer list " << saved_peer_list_file_name << ", error " << errno);
|
||||
LOGERR(1, "failed to save peer list " << path << ": error " << errno);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -579,7 +581,9 @@ void P2PServer::load_peer_list()
|
|||
}
|
||||
|
||||
// Finally load peers from p2pool_peers.txt
|
||||
std::ifstream f(saved_peer_list_file_name);
|
||||
const std::string path = DATA_DIR + saved_peer_list_file_name;
|
||||
|
||||
std::ifstream f(path);
|
||||
if (f.is_open()) {
|
||||
std::string address;
|
||||
while (f.good()) {
|
||||
|
|
|
@ -1188,7 +1188,7 @@ void p2pool::load_found_blocks()
|
|||
return;
|
||||
}
|
||||
|
||||
std::ifstream f(FOUND_BLOCKS_FILE);
|
||||
std::ifstream f(DATA_DIR + FOUND_BLOCKS_FILE);
|
||||
if (!f.is_open()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1721,14 +1721,15 @@ void p2pool::api_update_block_found(const ChainMain* data, const PoolBlock* bloc
|
|||
difficulty_type diff;
|
||||
|
||||
if (data && get_difficulty_at_height(data->height, diff)) {
|
||||
std::ofstream f(FOUND_BLOCKS_FILE, std::ios::app);
|
||||
const std::string path = DATA_DIR + FOUND_BLOCKS_FILE;
|
||||
std::ofstream f(path, std::ios::app);
|
||||
if (f.is_open()) {
|
||||
f << cur_time << ' ' << data->height << ' ' << data->id << ' ' << diff << ' ' << total_hashes << '\n';
|
||||
f.flush();
|
||||
f.close();
|
||||
}
|
||||
else {
|
||||
LOGERR(1, "Failed to update " << FOUND_BLOCKS_FILE << ", error " << errno);
|
||||
LOGERR(1, "Failed to update " << path << ": error " << errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,12 @@ Params::Params(int argc, char* const argv[])
|
|||
ok = true;
|
||||
}
|
||||
|
||||
if ((strcmp(argv[i], "--data-dir") == 0) && (i + 1 < argc)) {
|
||||
// Processed in main.cpp
|
||||
++i;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((strcmp(argv[i], "--config") == 0) && (i + 1 < argc)) {
|
||||
m_config = argv[++i];
|
||||
ok = true;
|
||||
|
|
|
@ -60,6 +60,8 @@ const char* VERSION = "v" STR2(P2POOL_VERSION_MAJOR) "." STR2(P2POOL_VERSION_MIN
|
|||
#endif
|
||||
" on " __DATE__ ")";
|
||||
|
||||
std::string DATA_DIR;
|
||||
|
||||
SoftwareID get_software_id(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
|
|
|
@ -42,6 +42,8 @@ constexpr uint32_t P2POOL_VERSION = (P2POOL_VERSION_MAJOR << 16) | (P2POOL_VERSI
|
|||
|
||||
extern const char* VERSION;
|
||||
|
||||
extern std::string DATA_DIR;
|
||||
|
||||
enum class SoftwareID : uint32_t {
|
||||
P2Pool = 0,
|
||||
GoObserver = 0x624F6F47UL,
|
||||
|
|
Loading…
Reference in a new issue