mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-23 03:49:23 +00:00
Added sidechain height to SHARE FOUND log
This commit is contained in:
parent
b9a9be2795
commit
2e747beda6
6 changed files with 19 additions and 14 deletions
|
@ -931,12 +931,13 @@ void BlockTemplate::calc_merkle_tree_main_branch()
|
|||
}
|
||||
}
|
||||
|
||||
bool BlockTemplate::get_difficulties(const uint32_t template_id, uint64_t& height, difficulty_type& mainchain_difficulty, difficulty_type& sidechain_difficulty) const
|
||||
bool BlockTemplate::get_difficulties(const uint32_t template_id, uint64_t& height, uint64_t& sidechain_height, difficulty_type& mainchain_difficulty, difficulty_type& sidechain_difficulty) const
|
||||
{
|
||||
ReadLock lock(m_lock);
|
||||
|
||||
if (template_id == m_templateId) {
|
||||
height = m_height;
|
||||
sidechain_height = m_poolBlockTemplate->m_sidechainHeight;
|
||||
mainchain_difficulty = m_difficulty;
|
||||
sidechain_difficulty = m_poolBlockTemplate->m_difficulty;
|
||||
return true;
|
||||
|
@ -945,7 +946,7 @@ bool BlockTemplate::get_difficulties(const uint32_t template_id, uint64_t& heigh
|
|||
const BlockTemplate* old = m_oldTemplates[template_id % array_size(&BlockTemplate::m_oldTemplates)];
|
||||
|
||||
if (old && (template_id == old->m_templateId)) {
|
||||
return old->get_difficulties(template_id, height, mainchain_difficulty, sidechain_difficulty);
|
||||
return old->get_difficulties(template_id, height, sidechain_height, mainchain_difficulty, sidechain_difficulty);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -974,11 +975,12 @@ uint32_t BlockTemplate::get_hashing_blob(const uint32_t template_id, uint32_t ex
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t BlockTemplate::get_hashing_blob(uint32_t extra_nonce, uint8_t (&blob)[128], uint64_t& height, difficulty_type& difficulty, difficulty_type& sidechain_difficulty, hash& seed_hash, size_t& nonce_offset, uint32_t& template_id) const
|
||||
uint32_t BlockTemplate::get_hashing_blob(uint32_t extra_nonce, uint8_t (&blob)[128], uint64_t& height, uint64_t& sidechain_height, difficulty_type& difficulty, difficulty_type& sidechain_difficulty, hash& seed_hash, size_t& nonce_offset, uint32_t& template_id) const
|
||||
{
|
||||
ReadLock lock(m_lock);
|
||||
|
||||
height = m_height;
|
||||
sidechain_height = m_poolBlockTemplate->m_sidechainHeight;
|
||||
difficulty = m_difficulty;
|
||||
sidechain_difficulty = m_poolBlockTemplate->m_difficulty;
|
||||
seed_hash = m_seedHash;
|
||||
|
|
|
@ -41,10 +41,10 @@ public:
|
|||
void update(const MinerData& data, const Mempool& mempool, Wallet* miner_wallet);
|
||||
uint64_t last_updated() const { return m_lastUpdated.load(); }
|
||||
|
||||
bool get_difficulties(const uint32_t template_id, uint64_t& height, difficulty_type& mainchain_difficulty, difficulty_type& sidechain_difficulty) const;
|
||||
bool get_difficulties(const uint32_t template_id, uint64_t& height, uint64_t& sidechain_height, difficulty_type& mainchain_difficulty, difficulty_type& sidechain_difficulty) const;
|
||||
uint32_t get_hashing_blob(const uint32_t template_id, uint32_t extra_nonce, uint8_t (&blob)[128], uint64_t& height, difficulty_type& difficulty, difficulty_type& sidechain_difficulty, hash& seed_hash, size_t& nonce_offset) const;
|
||||
|
||||
uint32_t get_hashing_blob(uint32_t extra_nonce, uint8_t (&blob)[128], uint64_t& height, difficulty_type& difficulty, difficulty_type& sidechain_difficulty, hash& seed_hash, size_t& nonce_offset, uint32_t& template_id) const;
|
||||
uint32_t get_hashing_blob(uint32_t extra_nonce, uint8_t (&blob)[128], uint64_t& height, uint64_t& sidechain_height, difficulty_type& difficulty, difficulty_type& sidechain_difficulty, hash& seed_hash, size_t& nonce_offset, uint32_t& template_id) const;
|
||||
uint32_t get_hashing_blobs(uint32_t extra_nonce_start, uint32_t count, std::vector<uint8_t>& blobs, uint64_t& height, difficulty_type& difficulty, difficulty_type& sidechain_difficulty, hash& seed_hash, size_t& nonce_offset, uint32_t& template_id) const;
|
||||
|
||||
std::vector<uint8_t> get_block_template_blob(uint32_t template_id, size_t& nonce_offset, size_t& extra_nonce_offset) const;
|
||||
|
|
|
@ -92,7 +92,7 @@ void Miner::on_block(const BlockTemplate& block)
|
|||
const uint32_t next_index = m_jobIndex ^ 1;
|
||||
Job& j = m_job[next_index];
|
||||
hash seed;
|
||||
j.m_blobSize = block.get_hashing_blob(m_extraNonce, j.m_blob, j.m_height, j.m_diff, j.m_sidechainDiff, seed, j.m_nonceOffset, j.m_templateId);
|
||||
j.m_blobSize = block.get_hashing_blob(m_extraNonce, j.m_blob, j.m_height, j.m_sidechainHeight, j.m_diff, j.m_sidechainDiff, seed, j.m_nonceOffset, j.m_templateId);
|
||||
|
||||
const uint32_t hash_count = 0 - m_nonce.exchange(0);
|
||||
m_jobIndex = next_index;
|
||||
|
@ -204,12 +204,12 @@ void Miner::run(WorkerData* data)
|
|||
randomx_calculate_hash_next(vm, job[index].m_blob, job[index].m_blobSize, &h);
|
||||
|
||||
if (j.m_diff.check_pow(h)) {
|
||||
LOGINFO(0, log::Green() << "worker thread " << data->m_index << '/' << data->m_count << " found a mainchain block, submitting it");
|
||||
LOGINFO(0, log::Green() << "worker thread " << data->m_index << '/' << data->m_count << " found a mainchain block at height " << j.m_height << ", submitting it");
|
||||
m_pool->submit_block_async(j.m_templateId, j.m_nonce, j.m_extraNonce);
|
||||
}
|
||||
|
||||
if (j.m_sidechainDiff.check_pow(h)) {
|
||||
LOGINFO(0, log::Green() << "SHARE FOUND: mainchain height " << j.m_height << ", diff " << j.m_sidechainDiff << ", worker thread " << data->m_index << '/' << data->m_count);
|
||||
LOGINFO(0, log::Green() << "SHARE FOUND: mainchain height " << j.m_height << ", sidechain height " << j.m_sidechainHeight << ", diff " << j.m_sidechainDiff << ", worker thread " << data->m_index << '/' << data->m_count);
|
||||
m_pool->submit_sidechain_block(j.m_templateId, j.m_nonce, j.m_extraNonce);
|
||||
++m_sharesFound;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
difficulty_type m_diff = {};
|
||||
difficulty_type m_sidechainDiff = {};
|
||||
uint64_t m_height = 0;
|
||||
uint64_t m_sidechainHeight = 0;
|
||||
size_t m_nonceOffset = 0;
|
||||
uint32_t m_nonce = 0;
|
||||
uint32_t m_extraNonce = 0;
|
||||
|
|
|
@ -242,14 +242,14 @@ bool StratumServer::on_login(StratumClient* client, uint32_t id, const char* log
|
|||
const uint32_t extra_nonce = m_extraNonce.fetch_add(1);
|
||||
|
||||
uint8_t hashing_blob[128];
|
||||
uint64_t height;
|
||||
uint64_t height, sidechain_height;
|
||||
difficulty_type difficulty;
|
||||
difficulty_type sidechain_difficulty;
|
||||
hash seed_hash;
|
||||
size_t nonce_offset;
|
||||
uint32_t template_id;
|
||||
|
||||
const size_t blob_size = m_pool->block_template().get_hashing_blob(extra_nonce, hashing_blob, height, difficulty, sidechain_difficulty, seed_hash, nonce_offset, template_id);
|
||||
const size_t blob_size = m_pool->block_template().get_hashing_blob(extra_nonce, hashing_blob, height, sidechain_height, difficulty, sidechain_difficulty, seed_hash, nonce_offset, template_id);
|
||||
|
||||
uint64_t target = std::max(difficulty.target(), sidechain_difficulty.target());
|
||||
|
||||
|
@ -363,10 +363,10 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
|
|||
|
||||
if (found) {
|
||||
BlockTemplate& block = m_pool->block_template();
|
||||
uint64_t height;
|
||||
uint64_t height, sidechain_height;
|
||||
difficulty_type mainchain_diff, sidechain_diff;
|
||||
|
||||
if (!block.get_difficulties(template_id, height, mainchain_diff, sidechain_diff)) {
|
||||
if (!block.get_difficulties(template_id, height, sidechain_height, mainchain_diff, sidechain_diff)) {
|
||||
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " got a stale share");
|
||||
return send(client,
|
||||
[id](void* buf, size_t buf_size)
|
||||
|
@ -379,7 +379,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
|
|||
|
||||
if (mainchain_diff.check_pow(resultHash)) {
|
||||
const char* s = client->m_customUser;
|
||||
LOGINFO(0, log::Green() << "client " << static_cast<char*>(client->m_addrString) << (*s ? " user " : "") << s << " found a mainchain block, submitting it");
|
||||
LOGINFO(0, log::Green() << "client " << static_cast<char*>(client->m_addrString) << (*s ? " user " : "") << s << " found a mainchain block at height " << height << ", submitting it");
|
||||
m_pool->submit_block_async(template_id, nonce, extra_nonce);
|
||||
}
|
||||
|
||||
|
@ -412,6 +412,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
|
|||
share->m_resultHash = resultHash;
|
||||
share->m_sidechainDifficulty = sidechain_diff;
|
||||
share->m_mainchainHeight = height;
|
||||
share->m_sidechainHeight = sidechain_height;
|
||||
share->m_effort = -1.0;
|
||||
share->m_timestamp = seconds_since_epoch();
|
||||
|
||||
|
@ -890,7 +891,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
|||
|
||||
if (share->m_highEnoughDifficulty) {
|
||||
const char* s = client->m_customUser;
|
||||
LOGINFO(0, log::Green() << "SHARE FOUND: mainchain height " << share->m_mainchainHeight << ", diff " << share->m_sidechainDifficulty << ", client " << static_cast<char*>(client->m_addrString) << (*s ? " user " : "") << s << ", effort " << share->m_effort << '%');
|
||||
LOGINFO(0, log::Green() << "SHARE FOUND: mainchain height " << share->m_mainchainHeight << ", sidechain height " << share->m_sidechainHeight << ", diff " << share->m_sidechainDifficulty << ", client " << static_cast<char*>(client->m_addrString) << (*s ? " user " : "") << s << ", effort " << share->m_effort << '%');
|
||||
BACKGROUND_JOB_STOP(StratumServer::on_share_found);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ private:
|
|||
hash m_resultHash;
|
||||
difficulty_type m_sidechainDifficulty;
|
||||
uint64_t m_mainchainHeight;
|
||||
uint64_t m_sidechainHeight;
|
||||
double m_effort;
|
||||
uint64_t m_timestamp;
|
||||
uint64_t m_hashes;
|
||||
|
|
Loading…
Reference in a new issue