mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 08:17:55 +00:00
Show Monero node in status
This commit is contained in:
parent
c989bdb0ea
commit
25d083ef25
4 changed files with 21 additions and 6 deletions
|
@ -1321,7 +1321,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
{
|
{
|
||||||
case MessageId::HANDSHAKE_CHALLENGE:
|
case MessageId::HANDSHAKE_CHALLENGE:
|
||||||
if (m_handshakeComplete) {
|
if (m_handshakeComplete) {
|
||||||
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent an unexpected HANDSHAKE_CHALLENGE");
|
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an unexpected HANDSHAKE_CHALLENGE");
|
||||||
ban(DEFAULT_BAN_TIME);
|
ban(DEFAULT_BAN_TIME);
|
||||||
server->remove_peer_from_list(this);
|
server->remove_peer_from_list(this);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1342,7 +1342,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
|
|
||||||
case MessageId::HANDSHAKE_SOLUTION:
|
case MessageId::HANDSHAKE_SOLUTION:
|
||||||
if (m_handshakeComplete) {
|
if (m_handshakeComplete) {
|
||||||
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent an unexpected HANDSHAKE_SOLUTION");
|
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an unexpected HANDSHAKE_SOLUTION");
|
||||||
ban(DEFAULT_BAN_TIME);
|
ban(DEFAULT_BAN_TIME);
|
||||||
server->remove_peer_from_list(this);
|
server->remove_peer_from_list(this);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1383,7 +1383,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
case MessageId::BLOCK_REQUEST:
|
case MessageId::BLOCK_REQUEST:
|
||||||
++num_block_requests;
|
++num_block_requests;
|
||||||
if (num_block_requests > 100) {
|
if (num_block_requests > 100) {
|
||||||
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent too many BLOCK_REQUEST messages at once");
|
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent too many BLOCK_REQUEST messages at once");
|
||||||
ban(DEFAULT_BAN_TIME);
|
ban(DEFAULT_BAN_TIME);
|
||||||
server->remove_peer_from_list(this);
|
server->remove_peer_from_list(this);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1403,7 +1403,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
|
|
||||||
case MessageId::BLOCK_RESPONSE:
|
case MessageId::BLOCK_RESPONSE:
|
||||||
if (m_blockPendingRequests.empty()) {
|
if (m_blockPendingRequests.empty()) {
|
||||||
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent an unexpected BLOCK_RESPONSE");
|
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an unexpected BLOCK_RESPONSE");
|
||||||
ban(DEFAULT_BAN_TIME);
|
ban(DEFAULT_BAN_TIME);
|
||||||
server->remove_peer_from_list(this);
|
server->remove_peer_from_list(this);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1463,7 +1463,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
|
|
||||||
case MessageId::PEER_LIST_RESPONSE:
|
case MessageId::PEER_LIST_RESPONSE:
|
||||||
if (m_peerListPendingRequests <= 0) {
|
if (m_peerListPendingRequests <= 0) {
|
||||||
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent an unexpected PEER_LIST_RESPONSE");
|
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an unexpected PEER_LIST_RESPONSE");
|
||||||
ban(DEFAULT_BAN_TIME);
|
ban(DEFAULT_BAN_TIME);
|
||||||
server->remove_peer_from_list(this);
|
server->remove_peer_from_list(this);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1474,7 +1474,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
if (bytes_left >= 2) {
|
if (bytes_left >= 2) {
|
||||||
const uint32_t num_peers = buf[1];
|
const uint32_t num_peers = buf[1];
|
||||||
if (num_peers > PEER_LIST_RESPONSE_MAX_PEERS) {
|
if (num_peers > PEER_LIST_RESPONSE_MAX_PEERS) {
|
||||||
LOGWARN(5, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent too long peer list (" << num_peers << ')');
|
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " sent too long peer list (" << num_peers << ')');
|
||||||
ban(DEFAULT_BAN_TIME);
|
ban(DEFAULT_BAN_TIME);
|
||||||
server->remove_peer_from_list(this);
|
server->remove_peer_from_list(this);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -65,6 +65,8 @@ p2pool::p2pool(int argc, char* argv[])
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_hostStr = m_params->m_host;
|
||||||
|
|
||||||
if (m_params->m_socks5Proxy.empty()) {
|
if (m_params->m_socks5Proxy.empty()) {
|
||||||
if (m_params->m_dns) {
|
if (m_params->m_dns) {
|
||||||
bool is_v6;
|
bool is_v6;
|
||||||
|
@ -79,6 +81,16 @@ p2pool::p2pool(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const bool changed = (m_params->m_host != m_hostStr);
|
||||||
|
const std::string rpc_port = ':' + std::to_string(m_params->m_rpcPort);
|
||||||
|
const std::string zmq_port = ":ZMQ:" + std::to_string(m_params->m_zmqPort);
|
||||||
|
m_hostStr += rpc_port + zmq_port;
|
||||||
|
if (changed) {
|
||||||
|
m_hostStr += " (" + m_params->m_host + ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hash pub, sec, eph_public_key;
|
hash pub, sec, eph_public_key;
|
||||||
generate_keys(pub, sec);
|
generate_keys(pub, sec);
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
bool stopped() const { return m_stopped; }
|
bool stopped() const { return m_stopped; }
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
const std::string& host_str() const { return m_hostStr; }
|
||||||
const Params& params() const { return *m_params; }
|
const Params& params() const { return *m_params; }
|
||||||
BlockTemplate& block_template() { return *m_blockTemplate; }
|
BlockTemplate& block_template() { return *m_blockTemplate; }
|
||||||
SideChain& side_chain() { return *m_sideChain; }
|
SideChain& side_chain() { return *m_sideChain; }
|
||||||
|
@ -111,6 +112,7 @@ private:
|
||||||
|
|
||||||
std::atomic<bool> m_stopped;
|
std::atomic<bool> m_stopped;
|
||||||
|
|
||||||
|
std::string m_hostStr;
|
||||||
Params* m_params;
|
Params* m_params;
|
||||||
|
|
||||||
p2pool_api* m_api;
|
p2pool_api* m_api;
|
||||||
|
|
|
@ -981,6 +981,7 @@ void SideChain::print_status(bool obtain_sidechain_lock) const
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGINFO(0, "status" <<
|
LOGINFO(0, "status" <<
|
||||||
|
"\nMonero node = " << m_pool->host_str() <<
|
||||||
"\nMain chain height = " << m_pool->block_template().height() <<
|
"\nMain chain height = " << m_pool->block_template().height() <<
|
||||||
"\nMain chain hashrate = " << log::Hashrate(network_hashrate) <<
|
"\nMain chain hashrate = " << log::Hashrate(network_hashrate) <<
|
||||||
"\nSide chain ID = " << (is_default() ? "default" : (is_mini() ? "mini" : m_consensusIdDisplayStr.c_str())) <<
|
"\nSide chain ID = " << (is_default() ? "default" : (is_mini() ? "mini" : m_consensusIdDisplayStr.c_str())) <<
|
||||||
|
|
Loading…
Reference in a new issue