Default log level 3

Also refactored default port numbers
pull/27/head
SChernykh 3 years ago
parent b4ea125a8a
commit 5c92920619

@ -27,7 +27,7 @@ namespace p2pool {
namespace log {
int GLOBAL_LOG_LEVEL = 4;
int GLOBAL_LOG_LEVEL = 3;
#ifndef P2POOL_LOG_DISABLE

@ -17,6 +17,8 @@
#include "common.h"
#include "p2pool.h"
#include "stratum_server.h"
#include "p2p_server.h"
static void usage()
{
@ -35,12 +37,14 @@ static void usage()
"--data-api Path to the p2pool JSON data (use it in tandem with an external web-server)\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 [::]:3333,0.0.0.0:3333 --p2p [::]:37889,0.0.0.0:37889\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",
#ifdef _WIN32
"p2pool.exe"
#else
"./p2pool"
#endif
, p2pool::DEFAULT_STRATUM_PORT
, p2pool::DEFAULT_P2P_PORT
);
}

@ -34,7 +34,6 @@ static const char* seed_nodes[] = {
static constexpr int DEFAULT_BACKLOG = 16;
static constexpr uint64_t DEFAULT_BAN_TIME = 600;
static constexpr int DEFAULT_LISTEN_PORT = 37889;
#include "tcp_server.inl"
@ -334,6 +333,8 @@ void P2PServer::load_peer_list()
// Load peers from seed nodes if we're on the default sidechain
if (m_pool->side_chain().is_default()) {
const int p2p_port = DEFAULT_P2P_PORT;
for (size_t i = 0; i < array_size(seed_nodes); ++i) {
LOGINFO(4, "loading peers from " << seed_nodes[i]);
@ -355,13 +356,13 @@ void P2PServer::load_peer_list()
if (r->ai_family == AF_INET6) {
addr_str = inet_ntop(AF_INET6, &reinterpret_cast<sockaddr_in6*>(r->ai_addr)->sin6_addr, addr_str_buf, sizeof(addr_str_buf));
if (addr_str) {
s << '[' << addr_str << "]:" << DEFAULT_LISTEN_PORT << '\0';
s << '[' << addr_str << "]:" << p2p_port << '\0';
}
}
else {
addr_str = inet_ntop(AF_INET, &reinterpret_cast<sockaddr_in*>(r->ai_addr)->sin_addr, addr_str_buf, sizeof(addr_str_buf));
if (addr_str) {
s << addr_str << ':' << DEFAULT_LISTEN_PORT << '\0';
s << addr_str << ':' << p2p_port << '\0';
}
}
@ -376,7 +377,7 @@ void P2PServer::load_peer_list()
freeaddrinfo(result);
}
else {
LOGWARN(4, "getaddrinfo failed for " << seed_nodes[i] << ": " << gai_strerror(err));
LOGWARN(3, "getaddrinfo failed for " << seed_nodes[i] << ": " << gai_strerror(err));
}
}
}
@ -497,12 +498,12 @@ void P2PServer::remove_peer_from_list(const raw_ip& ip)
void P2PServer::broadcast(const PoolBlock& block)
{
if (block.m_txinGenHeight + 2 < m_pool->miner_data().height) {
LOGWARN(4, "Trying to broadcast a stale block " << block.m_sidechainId << " (mainchain height " << block.m_txinGenHeight << ", current height is " << m_pool->miner_data().height << ')');
LOGWARN(3, "Trying to broadcast a stale block " << block.m_sidechainId << " (mainchain height " << block.m_txinGenHeight << ", current height is " << m_pool->miner_data().height << ')');
return;
}
if (block.m_txinGenHeight > m_pool->miner_data().height + 2) {
LOGWARN(4, "Trying to broadcast a block " << block.m_sidechainId << " ahead on mainchain (mainchain height " << block.m_txinGenHeight << ", current height is " << m_pool->miner_data().height << ')');
LOGWARN(3, "Trying to broadcast a block " << block.m_sidechainId << " ahead on mainchain (mainchain height " << block.m_txinGenHeight << ", current height is " << m_pool->miner_data().height << ')');
return;
}
@ -1436,7 +1437,8 @@ bool P2PServer::P2PClient::on_block_broadcast(const uint8_t* buf, uint32_t size)
}
else if (peer_height > our_height) {
if (peer_height >= our_height + 2) {
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " is ahead on mainchain (height " << peer_height << ", your height " << our_height << "). Is your monerod stuck or lagging?");
const int level = (peer_height >= our_height + 3) ? 3 : 4;
LOGWARN(level , "peer " << static_cast<char*>(m_addrString) << " is ahead on mainchain (height " << peer_height << ", your height " << our_height << "). Is your monerod stuck or lagging?");
}
}
else {

@ -29,6 +29,7 @@ class BlockCache;
static constexpr size_t P2P_BUF_SIZE = 128 * 1024;
static constexpr size_t PEER_LIST_RESPONSE_MAX_PEERS = 16;
static constexpr int DEFAULT_P2P_PORT = 37889;
class P2PServer : public TCPServer<P2P_BUF_SIZE, P2P_BUF_SIZE>
{

@ -418,7 +418,7 @@ void p2pool::submit_block() const
}
if (is_external) {
LOGWARN(4, "submit_block (external blob): daemon returned error: " << (error_msg ? error_msg : "unknown error"));
LOGWARN(3, "submit_block (external blob): daemon returned error: " << (error_msg ? error_msg : "unknown error"));
}
else {
LOGERR(0, "submit_block: daemon returned error: '" << (error_msg ? error_msg : "unknown error") << "', template id = " << template_id << ", nonce = " << nonce << ", extra_nonce = " << extra_nonce);
@ -442,7 +442,7 @@ void p2pool::submit_block() const
{
if (size > 0) {
if (is_external) {
LOGWARN(4, "submit_block (external blob): RPC request failed, error " << log::const_buf(data, size));
LOGWARN(3, "submit_block (external blob): RPC request failed, error " << log::const_buf(data, size));
}
else {
LOGERR(0, "submit_block (external blob): RPC request failed, error " << log::const_buf(data, size));
@ -1036,11 +1036,12 @@ void p2pool::api_update_stats_mod()
}
const uint64_t round_hashes = total_hashes.lo - last_block_total_hashes.lo;
const int stratum_port = DEFAULT_STRATUM_PORT;
m_api->set(p2pool_api::Category::GLOBAL, "stats_mod",
[&mainnet_tip, last_block_found_time, &last_block_found_buf, last_block_found_height, miners, hashrate, round_hashes](log::Stream& s)
[&mainnet_tip, last_block_found_time, &last_block_found_buf, last_block_found_height, miners, hashrate, round_hashes, stratum_port](log::Stream& s)
{
s << "{\"config\":{\"ports\":[{\"port\":3333,\"tls\":false}],\"fee\":0,\"minPaymentThreshold\":400000000},\"network\":{\"height\":"
s << "{\"config\":{\"ports\":[{\"port\":" << stratum_port << ",\"tls\":false}],\"fee\":0,\"minPaymentThreshold\":400000000},\"network\":{\"height\":"
<< mainnet_tip.height << "},\"pool\":{\"stats\":{\"lastBlockFound\":\""
<< last_block_found_time << "000\"},\"blocks\":[\""
<< static_cast<char*>(last_block_found_buf) << static_cast<char*>(last_block_found_buf) + HASH_SIZE * 2 - 4 << ':'

@ -17,6 +17,8 @@
#include "common.h"
#include "params.h"
#include "stratum_server.h"
#include "p2p_server.h"
namespace p2pool {
@ -68,6 +70,26 @@ Params::Params(int argc, char* argv[])
m_apiPath = argv[++i];
}
}
if (m_stratumAddresses.empty()) {
const int stratum_port = DEFAULT_STRATUM_PORT;
char buf[log::Stream::BUF_SIZE + 1];
log::Stream s(buf);
s << "[::]:" << stratum_port << ",0.0.0.0:" << stratum_port << '\0';
m_stratumAddresses = buf;
}
if (m_p2pAddresses.empty()) {
const int p2p_port = DEFAULT_P2P_PORT;
char buf[log::Stream::BUF_SIZE + 1];
log::Stream s(buf);
s << "[::]:" << p2p_port << ",0.0.0.0:" << p2p_port << '\0';
m_p2pAddresses = buf;
}
}
bool Params::ok() const

@ -32,8 +32,8 @@ struct Params
uint32_t m_zmqPort = 18083;
bool m_lightMode = false;
Wallet m_wallet{ nullptr };
std::string m_stratumAddresses{ "[::]:3333,0.0.0.0:3333" };
std::string m_p2pAddresses{ "[::]:37889,0.0.0.0:37889" };
std::string m_stratumAddresses;
std::string m_p2pAddresses;
std::string m_p2pPeerList;
std::string m_config;
std::string m_apiPath;

@ -51,6 +51,10 @@ static_assert(1 <= UNCLE_BLOCK_DEPTH && UNCLE_BLOCK_DEPTH <= 10, "Invalid UNCLE_
namespace p2pool {
static constexpr uint8_t default_consensus_id[HASH_SIZE] = {
34,175,126,231,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24
};
SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name)
: m_pool(pool)
, m_networkType(type)
@ -91,9 +95,9 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name)
constexpr char default_config[] = "mainnet\0" "default\0" "\0" "10\0" "100000\0" "2160\0" "20\0";
// Hardcoded default consensus ID
if (memcmp(buf, default_config, sizeof(default_config) - 1) == 0) {
// Hardcoded default consensus ID
m_consensusId.assign({ 34,175,126,231,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 });
m_consensusId.assign(default_consensus_id, default_consensus_id + HASH_SIZE);
}
else {
const randomx_flags flags = randomx_get_flags();
@ -270,8 +274,8 @@ bool SideChain::get_shares(PoolBlock* tip, std::vector<MinerShare>& shares) cons
for (const hash& uncle_id : cur->m_uncles) {
auto it = m_blocksById.find(uncle_id);
if (it == m_blocksById.end()) {
LOGWARN(4, "get_shares: can't find uncle block at height = " << cur->m_sidechainHeight << ", id = " << uncle_id);
LOGWARN(4, "get_shares: can't calculate shares for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
LOGWARN(3, "get_shares: can't find uncle block at height = " << cur->m_sidechainHeight << ", id = " << uncle_id);
LOGWARN(3, "get_shares: can't calculate shares for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
return false;
}
@ -307,8 +311,8 @@ bool SideChain::get_shares(PoolBlock* tip, std::vector<MinerShare>& shares) cons
auto it = m_blocksById.find(cur->m_parent);
if (it == m_blocksById.end()) {
LOGWARN(4, "get_shares: can't find parent block at height = " << cur->m_sidechainHeight - 1 << ", id = " << cur->m_parent);
LOGWARN(4, "get_shares: can't calculate shares for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
LOGWARN(3, "get_shares: can't find parent block at height = " << cur->m_sidechainHeight - 1 << ", id = " << cur->m_parent);
LOGWARN(3, "get_shares: can't calculate shares for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
return false;
}
@ -746,10 +750,6 @@ time_t SideChain::last_updated() const
bool SideChain::is_default() const
{
constexpr uint8_t default_consensus_id[HASH_SIZE] = {
34,175,126,231,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24
};
return (memcmp(m_consensusId.data(), default_consensus_id, HASH_SIZE) == 0);
}
@ -806,8 +806,8 @@ bool SideChain::get_difficulty(PoolBlock* tip, std::vector<DifficultyData>& diff
for (const hash& uncle_id : cur->m_uncles) {
auto it = m_blocksById.find(uncle_id);
if (it == m_blocksById.end()) {
LOGWARN(4, "get_difficulty: can't find uncle block at height = " << cur->m_sidechainHeight << ", id = " << uncle_id);
LOGWARN(4, "get_difficulty: can't calculate diff for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
LOGWARN(3, "get_difficulty: can't find uncle block at height = " << cur->m_sidechainHeight << ", id = " << uncle_id);
LOGWARN(3, "get_difficulty: can't calculate diff for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
return false;
}
@ -830,8 +830,8 @@ bool SideChain::get_difficulty(PoolBlock* tip, std::vector<DifficultyData>& diff
auto it = m_blocksById.find(cur->m_parent);
if (it == m_blocksById.end()) {
LOGWARN(4, "get_difficulty: can't find parent block at height = " << cur->m_sidechainHeight - 1 << ", id = " << cur->m_parent);
LOGWARN(4, "get_difficulty: can't calculate diff for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
LOGWARN(3, "get_difficulty: can't find parent block at height = " << cur->m_sidechainHeight - 1 << ", id = " << cur->m_parent);
LOGWARN(3, "get_difficulty: can't calculate diff for block at height = " << tip->m_sidechainHeight << ", id = " << tip->m_sidechainId << ", mainchain height = " << tip->m_txinGenHeight);
return false;
}

@ -606,7 +606,7 @@ void StratumServer::on_share_found(uv_work_t* req)
hash pow_hash;
if (!pool->calculate_hash(blob, blob_size, seed_hash, pow_hash)) {
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " couldn't check share PoW");
LOGWARN(3, "client " << static_cast<char*>(client->m_addrString) << " couldn't check share PoW");
share->m_result = SubmittedShare::Result::COULDNT_CHECK_POW;
return;
}

@ -27,6 +27,7 @@ class p2pool;
class BlockTemplate;
static constexpr size_t STRATUM_BUF_SIZE = log::Stream::BUF_SIZE + 1;
static constexpr int DEFAULT_STRATUM_PORT = 3333;
class StratumServer : public TCPServer<STRATUM_BUF_SIZE, STRATUM_BUF_SIZE>
{

@ -356,7 +356,7 @@ bool resolve_host(std::string& host, bool& is_v6)
freeaddrinfo(r);
}
else {
LOGWARN(4, "getaddrinfo failed for " << host << ": " << gai_strerror(err));
LOGWARN(3, "getaddrinfo failed for " << host << ": " << gai_strerror(err));
return false;
}

@ -257,7 +257,7 @@ void ZMQReader::parse(char* data, size_t size)
}
}
else {
LOGWARN(4, "json-full-chain_main outputs not found");
LOGWARN(1, "json-full-chain_main outputs not found");
}
auto inputs = inputs_it->value.GetArray();

Loading…
Cancel
Save