mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 08:17:55 +00:00
Show block share % in status
This commit is contained in:
parent
899d5a82dd
commit
25772abc0f
5 changed files with 23 additions and 12 deletions
|
@ -913,6 +913,11 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
void P2PServer::P2PClient::on_read_failed(int /*err*/)
|
void P2PServer::P2PClient::on_read_failed(int /*err*/)
|
||||||
|
{
|
||||||
|
on_disconnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void P2PServer::P2PClient::on_disconnected()
|
||||||
{
|
{
|
||||||
if (!m_handshakeComplete) {
|
if (!m_handshakeComplete) {
|
||||||
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " disconnected before finishing handshake");
|
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " disconnected before finishing handshake");
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
bool on_connect() override;
|
bool on_connect() override;
|
||||||
bool on_read(char* data, uint32_t size) override;
|
bool on_read(char* data, uint32_t size) override;
|
||||||
void on_read_failed(int err) override;
|
void on_read_failed(int err) override;
|
||||||
|
void on_disconnected() override;
|
||||||
|
|
||||||
// Both peers send handshake challenge immediately after a connection is established
|
// Both peers send handshake challenge immediately after a connection is established
|
||||||
// Both peers must have the same consensus ID for handshake to succeed
|
// Both peers must have the same consensus ID for handshake to succeed
|
||||||
|
|
|
@ -634,6 +634,9 @@ void SideChain::print_status()
|
||||||
uint64_t total_orphans = 0;
|
uint64_t total_orphans = 0;
|
||||||
uint64_t our_orphans = 0;
|
uint64_t our_orphans = 0;
|
||||||
|
|
||||||
|
uint64_t your_reward = 0;
|
||||||
|
uint64_t total_reward = 0;
|
||||||
|
|
||||||
if (m_chainTip) {
|
if (m_chainTip) {
|
||||||
std::sort(blocks_in_window.begin(), blocks_in_window.end());
|
std::sort(blocks_in_window.begin(), blocks_in_window.end());
|
||||||
for (uint64_t i = 0; (i < m_chainWindowSize) && (i <= tip_height); ++i) {
|
for (uint64_t i = 0; (i < m_chainWindowSize) && (i <= tip_height); ++i) {
|
||||||
|
@ -647,25 +650,23 @@ void SideChain::print_status()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const uint64_t block_reward = m_pool->block_template().final_reward();
|
|
||||||
|
|
||||||
uint64_t reward_share = 0;
|
|
||||||
if (m_chainTip) {
|
|
||||||
Wallet w = m_pool->params().m_wallet;
|
Wallet w = m_pool->params().m_wallet;
|
||||||
|
const std::vector<PoolBlock::TxOutput>& outs = m_chainTip->m_outputs;
|
||||||
|
|
||||||
hash eph_public_key;
|
hash eph_public_key;
|
||||||
for (size_t i = 0, n = m_chainTip->m_outputs.size(); i < n; ++i) {
|
for (size_t i = 0, n = outs.size(); i < n; ++i) {
|
||||||
if (w.get_eph_public_key(m_chainTip->m_txkeySec, i, eph_public_key) && (m_chainTip->m_outputs[i].m_ephPublicKey == eph_public_key)) {
|
if (w.get_eph_public_key(m_chainTip->m_txkeySec, i, eph_public_key) && (outs[i].m_ephPublicKey == eph_public_key)) {
|
||||||
reward_share = m_chainTip->m_outputs[i].m_reward;
|
your_reward = outs[i].m_reward;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
total_reward += outs[i].m_reward;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t product[2];
|
uint64_t product[2];
|
||||||
product[0] = umul128(pool_hashrate, reward_share, &product[1]);
|
product[0] = umul128(pool_hashrate, your_reward, &product[1]);
|
||||||
const uint64_t hashrate_est = udiv128(product[1], product[0], block_reward, &rem);
|
const uint64_t hashrate_est = total_reward ? udiv128(product[1], product[0], total_reward, &rem) : 0;
|
||||||
|
const double block_share = total_reward ? ((static_cast<double>(your_reward) * 100.0) / static_cast<double>(total_reward)) : 0.0;
|
||||||
|
|
||||||
LOGINFO(0, "status" <<
|
LOGINFO(0, "status" <<
|
||||||
"\nMain chain height = " << m_pool->block_template().height() <<
|
"\nMain chain height = " << m_pool->block_template().height() <<
|
||||||
|
@ -675,7 +676,7 @@ void SideChain::print_status()
|
||||||
(hashrate_est ? "\nYour hashrate (pool-side) = " : "") << (hashrate_est ? log::Hashrate(hashrate_est) : log::Hashrate()) <<
|
(hashrate_est ? "\nYour hashrate (pool-side) = " : "") << (hashrate_est ? log::Hashrate(hashrate_est) : log::Hashrate()) <<
|
||||||
"\nPPLNS window = " << total_blocks_in_window << " blocks (+" << total_uncles_in_window << " uncles, " << total_orphans << " orphans)"
|
"\nPPLNS window = " << total_blocks_in_window << " blocks (+" << total_uncles_in_window << " uncles, " << total_orphans << " orphans)"
|
||||||
"\nYour shares = " << our_blocks_in_window << " blocks (+" << our_uncles_in_window << " uncles, " << our_orphans << " orphans)"
|
"\nYour shares = " << our_blocks_in_window << " blocks (+" << our_uncles_in_window << " uncles, " << our_orphans << " orphans)"
|
||||||
"\nBlock reward share (est) = " << log::XMRAmount(reward_share)
|
"\nBlock reward share = " << block_share << "% (" << log::XMRAmount(your_reward) << ')'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ public:
|
||||||
virtual bool on_connect() = 0;
|
virtual bool on_connect() = 0;
|
||||||
virtual bool on_read(char* data, uint32_t size) = 0;
|
virtual bool on_read(char* data, uint32_t size) = 0;
|
||||||
virtual void on_read_failed(int /*err*/) {}
|
virtual void on_read_failed(int /*err*/) {}
|
||||||
|
virtual void on_disconnected() {}
|
||||||
|
|
||||||
static void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
|
static void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
|
||||||
static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
|
static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
|
||||||
|
|
|
@ -839,6 +839,9 @@ void TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::Client::on_read(uv_stream_t* stre
|
||||||
LOGWARN(5, "client " << static_cast<const char*>(pThis->m_addrString) << " failed to read response, err = " << uv_err_name(err));
|
LOGWARN(5, "client " << static_cast<const char*>(pThis->m_addrString) << " failed to read response, err = " << uv_err_name(err));
|
||||||
pThis->on_read_failed(err);
|
pThis->on_read_failed(err);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
pThis->on_disconnected();
|
||||||
|
}
|
||||||
pThis->close();
|
pThis->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue