mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-22 02:14:30 +00:00
Show actual worker difficulty in workers
command
This commit is contained in:
parent
dfa27016fd
commit
975679ef87
3 changed files with 34 additions and 16 deletions
|
@ -182,7 +182,7 @@ static void do_showpeers(p2pool* m_pool, const char* /* args */)
|
|||
static void do_showworkers(p2pool* m_pool, const char* /* args */)
|
||||
{
|
||||
if (m_pool->stratum_server()) {
|
||||
m_pool->stratum_server()->show_workers();
|
||||
m_pool->stratum_server()->show_workers_async();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,14 +73,13 @@ StratumServer::StratumServer(p2pool* pool)
|
|||
m_submittedSharesPool[i] = new SubmittedShare{};
|
||||
}
|
||||
|
||||
const int err = uv_async_init(&m_loop, &m_blobsAsync, on_blobs_ready);
|
||||
if (err) {
|
||||
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
||||
PANIC_STOP();
|
||||
}
|
||||
uv_async_init_checked(&m_loop, &m_blobsAsync, on_blobs_ready);
|
||||
m_blobsAsync.data = this;
|
||||
m_blobsQueue.reserve(2);
|
||||
|
||||
uv_async_init_checked(&m_loop, &m_showWorkersAsync, on_show_workers);
|
||||
m_showWorkersAsync.data = this;
|
||||
|
||||
start_listening(pool->params().m_stratumAddresses);
|
||||
}
|
||||
|
||||
|
@ -278,6 +277,7 @@ bool StratumServer::on_login(StratumClient* client, uint32_t id, const char* log
|
|||
saved_job.template_id = template_id;
|
||||
saved_job.target = target;
|
||||
}
|
||||
client->m_lastJobTarget = target;
|
||||
|
||||
const bool result = send(client,
|
||||
[client, id, &hashing_blob, job_id, blob_size, target, height, &seed_hash](void* buf, size_t buf_size)
|
||||
|
@ -475,6 +475,13 @@ void StratumServer::print_status()
|
|||
print_stratum_status();
|
||||
}
|
||||
|
||||
void StratumServer::show_workers_async()
|
||||
{
|
||||
if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(&m_showWorkersAsync))) {
|
||||
uv_async_send(&m_showWorkersAsync);
|
||||
}
|
||||
}
|
||||
|
||||
void StratumServer::show_workers()
|
||||
{
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
@ -497,15 +504,14 @@ void StratumServer::show_workers()
|
|||
);
|
||||
|
||||
for (const StratumClient* c = static_cast<StratumClient*>(m_connectedClientsList->m_next); c != m_connectedClientsList; c = static_cast<StratumClient*>(c->m_next)) {
|
||||
difficulty_type diff;
|
||||
if (c->m_customDiff != 0) {
|
||||
diff = c->m_customDiff;
|
||||
}
|
||||
else if (m_autoDiff && (c->m_autoDiff != 0)) {
|
||||
diff = c->m_autoDiff;
|
||||
}
|
||||
else {
|
||||
diff = pool_diff;
|
||||
difficulty_type diff = pool_diff;
|
||||
if (c->m_lastJobTarget > 1) {
|
||||
uint64_t r;
|
||||
diff.lo = udiv128(1, 0, c->m_lastJobTarget, &r);
|
||||
diff.hi = 0;
|
||||
if (r) {
|
||||
++diff.lo;
|
||||
}
|
||||
}
|
||||
LOGINFO(0, log::pad_right(static_cast<const char*>(c->m_addrString), addr_len + 8)
|
||||
<< log::pad_right(log::Duration(cur_time - c->m_connectedTime), 20)
|
||||
|
@ -756,6 +762,7 @@ void StratumServer::on_blobs_ready()
|
|||
saved_job.template_id = data->m_templateId;
|
||||
saved_job.target = target;
|
||||
}
|
||||
client->m_lastJobTarget = target;
|
||||
|
||||
const bool result = send(client,
|
||||
[data, target, hashing_blob, job_id](void* buf, size_t buf_size)
|
||||
|
@ -985,6 +992,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
|||
void StratumServer::on_shutdown()
|
||||
{
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_blobsAsync), nullptr);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_showWorkersAsync), nullptr);
|
||||
}
|
||||
|
||||
StratumServer::StratumClient::StratumClient()
|
||||
|
@ -998,6 +1006,7 @@ StratumServer::StratumClient::StratumClient()
|
|||
, m_customDiff{}
|
||||
, m_autoDiff{}
|
||||
, m_customUser{}
|
||||
, m_lastJobTarget(0)
|
||||
, m_score(0)
|
||||
{
|
||||
}
|
||||
|
@ -1019,6 +1028,8 @@ void StratumServer::StratumClient::reset()
|
|||
m_autoDiff = {};
|
||||
m_customUser[0] = '\0';
|
||||
|
||||
m_lastJobTarget = 0;
|
||||
|
||||
m_score = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,8 @@ public:
|
|||
difficulty_type m_autoDiff;
|
||||
char m_customUser[32];
|
||||
|
||||
uint64_t m_lastJobTarget;
|
||||
|
||||
int32_t m_score;
|
||||
};
|
||||
|
||||
|
@ -87,7 +89,7 @@ public:
|
|||
uint32_t get_random32();
|
||||
|
||||
void print_status() override;
|
||||
void show_workers();
|
||||
void show_workers_async();
|
||||
|
||||
void reset_share_counters();
|
||||
|
||||
|
@ -120,6 +122,11 @@ private:
|
|||
static void on_blobs_ready(uv_async_t* handle) { reinterpret_cast<StratumServer*>(handle->data)->on_blobs_ready(); }
|
||||
void on_blobs_ready();
|
||||
|
||||
uv_async_t m_showWorkersAsync;
|
||||
|
||||
static void on_show_workers(uv_async_t* handle) { reinterpret_cast<StratumServer*>(handle->data)->show_workers(); }
|
||||
void show_workers();
|
||||
|
||||
std::atomic<uint32_t> m_extraNonce;
|
||||
|
||||
uv_mutex_t m_rngLock;
|
||||
|
|
Loading…
Reference in a new issue