mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-03-12 09:29:51 +00:00
Track shares that failed to be added
This commit is contained in:
parent
b346b93285
commit
ccc5117172
8 changed files with 47 additions and 17 deletions
|
@ -1115,7 +1115,7 @@ std::vector<uint8_t> BlockTemplate::get_block_template_blob(uint32_t template_id
|
|||
return m_blockTemplateBlob;
|
||||
}
|
||||
|
||||
void BlockTemplate::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
|
||||
bool BlockTemplate::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
|
||||
{
|
||||
WriteLock lock(m_lock);
|
||||
|
||||
|
@ -1154,17 +1154,26 @@ void BlockTemplate::submit_sidechain_block(uint32_t template_id, uint32_t nonce,
|
|||
m_poolBlockTemplate->m_verified = true;
|
||||
if (!m_sidechain->block_seen(*m_poolBlockTemplate)) {
|
||||
m_poolBlockTemplate->m_wantBroadcast = true;
|
||||
m_sidechain->add_block(*m_poolBlockTemplate);
|
||||
const bool result = m_sidechain->add_block(*m_poolBlockTemplate);
|
||||
if (!result) {
|
||||
LOGWARN(3, "failed to submit a share: add_block failed for template id " << template_id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return;
|
||||
|
||||
const PoolBlock* b = m_poolBlockTemplate;
|
||||
LOGWARN(3, "failed to submit a share: template id " << template_id << ", block " << b->m_sidechainId << ", nonce = " << b->m_nonce << ", extra_nonce = " << b->m_extraNonce << " was already added before");
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockTemplate* old = m_oldTemplates[template_id % array_size(&BlockTemplate::m_oldTemplates)];
|
||||
|
||||
if (old && (template_id == old->m_templateId)) {
|
||||
old->submit_sidechain_block(template_id, nonce, extra_nonce);
|
||||
return;
|
||||
return old->submit_sidechain_block(template_id, nonce, extra_nonce);
|
||||
}
|
||||
|
||||
LOGWARN(3, "failed to submit a share: template id " << template_id << " is too old/out of range, current template id is " << m_templateId);
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
FORCEINLINE uint64_t height() const { return m_height; }
|
||||
FORCEINLINE difficulty_type difficulty() const { return m_difficulty; }
|
||||
|
||||
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||
bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||
|
||||
FORCEINLINE const std::vector<MinerShare>& shares() const { return m_shares; }
|
||||
FORCEINLINE const PoolBlock* pool_block_template() const { return m_poolBlockTemplate; }
|
||||
|
|
|
@ -619,10 +619,10 @@ void p2pool::submit_block() const
|
|||
});
|
||||
}
|
||||
|
||||
void p2pool::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
|
||||
bool p2pool::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
|
||||
{
|
||||
LOGINFO(3, "submit_sidechain_block: template id = " << template_id << ", nonce = " << nonce << ", extra_nonce = " << extra_nonce);
|
||||
m_blockTemplate->submit_sidechain_block(template_id, nonce, extra_nonce);
|
||||
return m_blockTemplate->submit_sidechain_block(template_id, nonce, extra_nonce);
|
||||
}
|
||||
|
||||
void p2pool::update_block_template_async(bool is_alternative_block)
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
void submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||
void submit_block_async(std::vector<uint8_t>&& blob);
|
||||
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||
bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||
|
||||
void update_block_template_async(bool is_alternative_block = false);
|
||||
void update_block_template();
|
||||
|
|
|
@ -586,7 +586,7 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
|
|||
return true;
|
||||
}
|
||||
|
||||
void SideChain::add_block(const PoolBlock& block)
|
||||
bool SideChain::add_block(const PoolBlock& block)
|
||||
{
|
||||
LOGINFO(3, "add_block: height = " << block.m_sidechainHeight <<
|
||||
", id = " << block.m_sidechainId <<
|
||||
|
@ -620,7 +620,7 @@ void SideChain::add_block(const PoolBlock& block)
|
|||
);
|
||||
|
||||
delete new_block;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_blocksByHeight[new_block->m_sidechainHeight].push_back(new_block);
|
||||
|
@ -643,6 +643,8 @@ void SideChain::add_block(const PoolBlock& block)
|
|||
else {
|
||||
verify_loop(new_block);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PoolBlock* SideChain::find_block(const hash& id) const
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
bool block_seen(const PoolBlock& block);
|
||||
void unsee_block(const PoolBlock& block);
|
||||
bool add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks);
|
||||
void add_block(const PoolBlock& block);
|
||||
bool add_block(const PoolBlock& block);
|
||||
void get_missing_blocks(std::vector<hash>& missing_blocks) const;
|
||||
|
||||
PoolBlock* find_block(const hash& id) const;
|
||||
|
|
|
@ -54,6 +54,7 @@ StratumServer::StratumServer(p2pool* pool)
|
|||
, m_hashrateDataTail_24h(0)
|
||||
, m_cumulativeFoundSharesDiff(0.0)
|
||||
, m_totalFoundShares(0)
|
||||
, m_totalFailedShares(0)
|
||||
, m_apiLastUpdateTime(0)
|
||||
{
|
||||
// Diffuse the initial state in case it has low quality
|
||||
|
@ -526,6 +527,7 @@ void StratumServer::reset_share_counters()
|
|||
m_cumulativeHashesAtLastShare = 0;
|
||||
m_cumulativeFoundSharesDiff = 0.0;
|
||||
m_totalFoundShares = 0;
|
||||
m_totalFailedShares = 0;
|
||||
}
|
||||
|
||||
void StratumServer::print_stratum_status() const
|
||||
|
@ -535,7 +537,7 @@ void StratumServer::print_stratum_status() const
|
|||
|
||||
uint64_t hashes_since_last_share;
|
||||
double average_effort;
|
||||
int shares_found;
|
||||
uint32_t shares_found, shares_failed;
|
||||
|
||||
{
|
||||
ReadLock lock(m_hashrateDataLock);
|
||||
|
@ -565,18 +567,25 @@ void StratumServer::print_stratum_status() const
|
|||
}
|
||||
|
||||
shares_found = m_totalFoundShares;
|
||||
shares_failed = m_totalFailedShares;
|
||||
}
|
||||
|
||||
const uint64_t hashrate_15m = (dt_15m > 0) ? (hashes_15m / dt_15m) : 0;
|
||||
const uint64_t hashrate_1h = (dt_1h > 0) ? (hashes_1h / dt_1h ) : 0;
|
||||
const uint64_t hashrate_24h = (dt_24h > 0) ? (hashes_24h / dt_24h) : 0;
|
||||
|
||||
char shares_failed_buf[64] = {};
|
||||
log::Stream s(shares_failed_buf);
|
||||
if (shares_failed) {
|
||||
s << log::Yellow() << "\nShares failed = " << shares_failed << log::NoColor();
|
||||
}
|
||||
|
||||
LOGINFO(0, "status" <<
|
||||
"\nHashrate (15m est) = " << log::Hashrate(hashrate_15m) <<
|
||||
"\nHashrate (1h est) = " << log::Hashrate(hashrate_1h) <<
|
||||
"\nHashrate (24h est) = " << log::Hashrate(hashrate_24h) <<
|
||||
"\nTotal hashes = " << total_hashes <<
|
||||
"\nShares found = " << shares_found <<
|
||||
"\nShares found = " << shares_found << shares_failed_buf <<
|
||||
"\nAverage effort = " << average_effort << '%' <<
|
||||
"\nCurrent effort = " << static_cast<double>(hashes_since_last_share) * 100.0 / m_pool->side_chain().difficulty().to_double() << '%' <<
|
||||
"\nConnections = " << m_numConnections.load() << " (" << m_numIncomingConnections.load() << " incoming)"
|
||||
|
@ -882,7 +891,14 @@ void StratumServer::on_share_found(uv_work_t* req)
|
|||
++server->m_totalFoundShares;
|
||||
}
|
||||
|
||||
pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce);
|
||||
if (!pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
|
||||
WriteLock lock(server->m_hashrateDataLock);
|
||||
|
||||
if (server->m_totalFoundShares > 0) {
|
||||
--server->m_totalFoundShares;
|
||||
++server->m_totalFailedShares;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send the response to miner
|
||||
|
@ -1203,7 +1219,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
|
|||
|
||||
uint64_t hashes_since_last_share;
|
||||
double average_effort;
|
||||
int shares_found;
|
||||
uint32_t shares_found, shares_failed;
|
||||
|
||||
{
|
||||
ReadLock lock(m_hashrateDataLock);
|
||||
|
@ -1233,6 +1249,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
|
|||
}
|
||||
|
||||
shares_found = m_totalFoundShares;
|
||||
shares_failed = m_totalFailedShares;
|
||||
}
|
||||
|
||||
const uint64_t hashrate_15m = (dt_15m > 0) ? (hashes_15m / dt_15m) : 0;
|
||||
|
@ -1245,13 +1262,14 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
|
|||
int incoming_connections = m_numIncomingConnections;
|
||||
|
||||
m_pool->api()->set(p2pool_api::Category::LOCAL, "stats",
|
||||
[hashrate_15m, hashrate_1h, hashrate_24h, total_hashes, shares_found, average_effort, current_effort, connections, incoming_connections](log::Stream& s)
|
||||
[hashrate_15m, hashrate_1h, hashrate_24h, total_hashes, shares_found, shares_failed, average_effort, current_effort, connections, incoming_connections](log::Stream& s)
|
||||
{
|
||||
s << "{\"hashrate_15m\":" << hashrate_15m
|
||||
<< ",\"hashrate_1h\":" << hashrate_1h
|
||||
<< ",\"hashrate_24h\":" << hashrate_24h
|
||||
<< ",\"total_hashes\":" << total_hashes
|
||||
<< ",\"shares_found\":" << shares_found
|
||||
<< ",\"shares_failed\":" << shares_failed
|
||||
<< ",\"average_effort\":" << average_effort
|
||||
<< ",\"current_effort\":" << current_effort
|
||||
<< ",\"connections\":" << connections
|
||||
|
|
|
@ -176,6 +176,7 @@ private:
|
|||
|
||||
double m_cumulativeFoundSharesDiff;
|
||||
uint32_t m_totalFoundShares;
|
||||
uint32_t m_totalFailedShares;
|
||||
|
||||
uint64_t m_apiLastUpdateTime;
|
||||
|
||||
|
|
Loading…
Reference in a new issue