CI: cleanup build warnings

Tests: fixed "unused const variable" warning
CMakeLists.txt: fixed deprecation warnings
This commit is contained in:
SChernykh
2023-08-16 13:00:11 +02:00
parent 741bec9874
commit 76c4573c39
31 changed files with 89 additions and 64 deletions

View File

@@ -20,7 +20,7 @@
#include "pool_block.h"
#include "p2p_server.h"
static constexpr char log_category_prefix[] = "BlockCache ";
LOG_CATEGORY(BlockCache)
static constexpr uint32_t BLOCK_SIZE = 96 * 1024;
static constexpr uint32_t NUM_BLOCKS = 4608;

View File

@@ -32,7 +32,7 @@
#include <ctime>
#include <numeric>
static constexpr char log_category_prefix[] = "BlockTemplate ";
LOG_CATEGORY(BlockTemplate)
namespace p2pool {

View File

@@ -28,7 +28,7 @@
#include "p2pool_api.h"
#include "params.h"
static constexpr char log_category_prefix[] = "ConsoleCommands ";
LOG_CATEGORY(ConsoleCommands)
static constexpr int DEFAULT_BACKLOG = 1;
@@ -123,6 +123,11 @@ void ConsoleCommands::on_shutdown()
uv_close(reinterpret_cast<uv_handle_t*>(m_stdin_handle), nullptr);
}
const char* ConsoleCommands::get_log_category() const
{
return log_category_prefix;
}
typedef struct strconst {
const char *str;
size_t len;

View File

@@ -50,7 +50,7 @@ public:
void on_shutdown() override;
private:
const char* get_category() const override { return "ConsoleCommands "; }
const char* get_log_category() const override;
p2pool* m_pool;

View File

@@ -20,7 +20,7 @@
#include "json_rpc_request.h"
#include <curl/curl.h>
static constexpr char log_category_prefix[] = "JSONRPCRequest ";
LOG_CATEGORY(JSONRPCRequest)
namespace p2pool {
namespace JSONRPCRequest {

View File

@@ -27,7 +27,8 @@
#pragma warning(disable : 4996)
#endif
static constexpr char log_category_prefix[] = "Log ";
LOG_CATEGORY(Log)
static constexpr char log_file_name[] = "p2pool.log";
namespace p2pool {

View File

@@ -510,17 +510,19 @@ struct DummyStream
}
#endif
#define LOG_CATEGORY(category) static constexpr char log_category_prefix[] = #category " ";
#ifdef P2POOL_LOG_DISABLE
#define LOGINFO(level, ...) SIDE_EFFECT_CHECK(level, __VA_ARGS__)
#define LOGWARN(level, ...) SIDE_EFFECT_CHECK(level, __VA_ARGS__)
#define LOGERR(level, ...) SIDE_EFFECT_CHECK(level, __VA_ARGS__)
#define LOGINFO(level, ...) SIDE_EFFECT_CHECK(level, log_category_prefix << __VA_ARGS__)
#define LOGWARN(level, ...) SIDE_EFFECT_CHECK(level, log_category_prefix << __VA_ARGS__)
#define LOGERR(level, ...) SIDE_EFFECT_CHECK(level, log_category_prefix << __VA_ARGS__)
#else
#define LOG(level, severity, ...) \
do { \
SIDE_EFFECT_CHECK(level, __VA_ARGS__); \
SIDE_EFFECT_CHECK(level, log_category_prefix << __VA_ARGS__); \
if ((level) <= log::GLOBAL_LOG_LEVEL) { \
log::Writer CONCAT(log_wrapper_, __LINE__)(severity); \
CONCAT(log_wrapper_, __LINE__) << log::Gray() << log_category_prefix; \

View File

@@ -19,7 +19,7 @@
#include "mempool.h"
#include "util.h"
static constexpr char log_category_prefix[] = "Mempool ";
LOG_CATEGORY(Mempool)
namespace p2pool {

View File

@@ -28,7 +28,7 @@
#include "p2p_server.h"
#include <thread>
static constexpr char log_category_prefix[] = "Miner ";
LOG_CATEGORY(Miner)
using namespace std::chrono;

View File

@@ -31,7 +31,8 @@
#include <fstream>
#include <numeric>
static constexpr char log_category_prefix[] = "P2PServer ";
LOG_CATEGORY(P2PServer)
static constexpr char saved_peer_list_file_name[] = "p2pool_peers.txt";
static const char* seed_nodes[] = { "seeds.p2pool.io", ""};
static const char* seed_nodes_mini[] = { "seeds-mini.p2pool.io", "" };
@@ -1049,6 +1050,11 @@ const PoolBlock* P2PServer::find_block(const hash& id) const
return m_pool->side_chain().find_block(id);
}
const char* P2PServer::get_log_category() const
{
return log_category_prefix;
}
void P2PServer::on_timer()
{
if (m_pool->stopped()) {

View File

@@ -178,7 +178,7 @@ public:
const PoolBlock* find_block(const hash& id) const;
private:
const char* get_category() const override { return "P2PServer "; }
const char* get_log_category() const override;
p2pool* m_pool;
BlockCache* m_cache;

View File

@@ -40,7 +40,8 @@
#include <fstream>
#include <numeric>
constexpr char log_category_prefix[] = "P2Pool ";
LOG_CATEGORY(P2Pool)
constexpr int BLOCK_HEADERS_REQUIRED = 720;
constexpr uint64_t SEEDHASH_EPOCH_BLOCKS = 2048;

View File

@@ -24,7 +24,7 @@
#include <sys/stat.h>
#endif
static constexpr char log_category_prefix[] = "P2Pool API ";
LOG_CATEGORY(P2Pool API)
namespace p2pool {

View File

@@ -20,7 +20,7 @@
#include "stratum_server.h"
#include "p2p_server.h"
constexpr char log_category_prefix[] = "P2Pool ";
LOG_CATEGORY(Params)
void p2pool_usage();

View File

@@ -22,7 +22,7 @@
#include "pow_hash.h"
#include "crypto.h"
static constexpr char log_category_prefix[] = "PoolBlock ";
LOG_CATEGORY(PoolBlock)
#include "pool_block_parser.inl"

View File

@@ -29,7 +29,7 @@
#include <rapidjson/document.h>
#include <thread>
static constexpr char log_category_prefix[] = "RandomX_Hasher ";
LOG_CATEGORY(RandomX_Hasher)
namespace p2pool {

View File

@@ -40,7 +40,7 @@
#include <iterator>
#include <numeric>
static constexpr char log_category_prefix[] = "SideChain ";
LOG_CATEGORY(SideChain)
static constexpr uint64_t MIN_DIFFICULTY = 100000;
static constexpr size_t UNCLE_BLOCK_DEPTH = 3;

View File

@@ -23,7 +23,7 @@
#include "params.h"
#include "p2pool_api.h"
static constexpr char log_category_prefix[] = "StratumServer ";
LOG_CATEGORY(StratumServer)
static constexpr int DEFAULT_BACKLOG = 128;
static constexpr uint64_t DEFAULT_BAN_TIME = 600;
@@ -544,6 +544,11 @@ void StratumServer::reset_share_counters()
m_totalFailedShares = 0;
}
const char* StratumServer::get_log_category() const
{
return log_category_prefix;
}
void StratumServer::print_stratum_status() const
{
uint64_t hashes_15m, hashes_1h, hashes_24h, total_hashes;

View File

@@ -97,7 +97,7 @@ public:
void reset_share_counters();
private:
const char* get_category() const override { return "StratumServer "; }
const char* get_log_category() const override;
void print_stratum_status() const;
void update_auto_diff(StratumClient* client, const uint64_t timestamp, const uint64_t hashes);

View File

@@ -573,13 +573,18 @@ bool TCPServer::send_internal(Client* client, Callback<size_t, uint8_t*, size_t>
return true;
}
const char* TCPServer::get_log_category() const
{
return log_category_prefix;
}
void TCPServer::loop(void* data)
{
TCPServer* server = static_cast<TCPServer*>(data);
server->m_loopThreadRunning.exchange(true);
ON_SCOPE_LEAVE([server]() { server->m_loopThreadRunning.exchange(false); });
log_category_prefix = server->get_category();
log_category_prefix = server->get_log_category();
LOGINFO(1, "event loop started");
server_event_loop_thread = data;

View File

@@ -143,7 +143,7 @@ private:
std::vector<uv_tcp_t*> m_listenSockets;
protected:
virtual const char* get_category() const { return "TCPServer "; }
virtual const char* get_log_category() const;
std::vector<uint8_t> m_callbackBuf;
int m_defaultBacklog;

View File

@@ -40,7 +40,7 @@
#include <resolv.h>
#endif
static constexpr char log_category_prefix[] = "Util ";
LOG_CATEGORY(Util)
namespace p2pool {

View File

@@ -20,7 +20,7 @@
#include "json_parsers.h"
#include <rapidjson/document.h>
static constexpr char log_category_prefix[] = "ZMQReader ";
LOG_CATEGORY(ZMQReader)
namespace p2pool {