mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
StratumServer: print current effort in status
This commit is contained in:
parent
891ee36e53
commit
4ac08ac10d
4 changed files with 11 additions and 0 deletions
|
@ -186,6 +186,8 @@ struct difficulty_type
|
|||
FORCEINLINE bool operator==(const difficulty_type& other) const { return (lo == other.lo) && (hi == other.hi); }
|
||||
FORCEINLINE bool operator!=(const difficulty_type& other) const { return (lo != other.lo) || (hi != other.hi); }
|
||||
|
||||
FORCEINLINE double to_double() const { return static_cast<double>(hi) * 18446744073709551616.0 + static_cast<double>(lo); }
|
||||
|
||||
// Finds a 64-bit target for mining (target = 2^64 / difficulty) and rounds up the result of division
|
||||
// Because of that, there's a very small chance that miners will find a hash that meets the target but is still wrong (hash * difficulty >= 2^256)
|
||||
// A proper difficulty check is in check_pow()
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
const std::vector<uint8_t>& consensus_id() const { return m_consensusId; }
|
||||
uint64_t chain_window_size() const { return m_chainWindowSize; }
|
||||
NetworkType network_type() const { return m_networkType; }
|
||||
const difficulty_type& difficulty() const { return m_curDifficulty; }
|
||||
|
||||
static bool split_reward(uint64_t reward, const std::vector<MinerShare>& shares, std::vector<uint64_t>& rewards);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "stratum_server.h"
|
||||
#include "block_template.h"
|
||||
#include "p2pool.h"
|
||||
#include "side_chain.h"
|
||||
#include "params.h"
|
||||
|
||||
static constexpr char log_category_prefix[] = "StratumServer ";
|
||||
|
@ -40,6 +41,7 @@ StratumServer::StratumServer(p2pool* pool)
|
|||
, m_rd{}
|
||||
, m_rng(m_rd())
|
||||
, m_cumulativeHashes(0)
|
||||
, m_cumulativeHashesAtLastShare(0)
|
||||
, m_hashrateDataHead(0)
|
||||
, m_hashrateDataTail_15m(0)
|
||||
, m_hashrateDataTail_1h(0)
|
||||
|
@ -349,10 +351,13 @@ void StratumServer::print_stratum_status() const
|
|||
uint64_t hashes_15m, hashes_1h, hashes_24h, total_hashes;
|
||||
int64_t dt_15m, dt_1h, dt_24h;
|
||||
|
||||
uint64_t hashes_since_last_share;
|
||||
|
||||
{
|
||||
ReadLock lock(m_hashrateDataLock);
|
||||
|
||||
total_hashes = m_cumulativeHashes;
|
||||
hashes_since_last_share = m_cumulativeHashes - m_cumulativeHashesAtLastShare;
|
||||
|
||||
const HashrateData* data = m_hashrateData;
|
||||
const HashrateData& head = data[m_hashrateDataHead];
|
||||
|
@ -379,6 +384,7 @@ void StratumServer::print_stratum_status() const
|
|||
"\nHashrate (1h est) = " << log::Hashrate(hashrate_1h) <<
|
||||
"\nHashrate (24h est) = " << log::Hashrate(hashrate_24h) <<
|
||||
"\nTotal hashes = " << total_hashes <<
|
||||
"\nCurrent effort = " << static_cast<double>(hashes_since_last_share) * 100.0 / m_pool->side_chain().difficulty().to_double() << '%' <<
|
||||
"\nConnections = " << m_numConnections << " (" << m_numIncomingConnections << " incoming)"
|
||||
);
|
||||
}
|
||||
|
@ -567,6 +573,7 @@ void StratumServer::on_share_found(uv_work_t* req)
|
|||
}
|
||||
|
||||
LOGINFO(0, log::Green() << "SHARE FOUND at mainchain height " << height);
|
||||
server->m_cumulativeHashesAtLastShare = server->m_cumulativeHashes;
|
||||
|
||||
if (mainchain_solution) {
|
||||
pool->submit_block_async(share->m_templateId, share->m_nonce, share->m_extraNonce);
|
||||
|
|
|
@ -142,6 +142,7 @@ private:
|
|||
|
||||
HashrateData m_hashrateData[131072];
|
||||
uint64_t m_cumulativeHashes;
|
||||
uint64_t m_cumulativeHashesAtLastShare;
|
||||
uint64_t m_hashrateDataHead;
|
||||
uint64_t m_hashrateDataTail_15m;
|
||||
uint64_t m_hashrateDataTail_1h;
|
||||
|
|
Loading…
Reference in a new issue