Closed ghost closed 4 years ago
If retarget_ratio was just a value between 0.0 and 1.0 (i.e. a percentage), wouldn't this be simpler?
e.g.
diff --git a/src/pool.c b/src/pool.c
index f52ead9..ac566f3 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -855,15 +855,11 @@ client_target(client_t *client, job_t *job)
duration * retarget_time, config.pool_start_diff), bd);
return target;
}
+
static bool
retarget_required(client_t *client, job_t *job)
{
- uint64_t target = client_target(client, job);
- double ratio = (double)target / job->target;
- if (ratio * config.retarget_ratio >= 1 && ratio <= config.retarget_ratio)
- return false;
- else
- return true;
+ return (job->target / (double)client_target(client, job) < config.retarget_ratio);
}
So I'm thinking these changes: https://paste.debian.net/hidden/e746e4bf/
Thank you
Adjust client's target faster to prevent DDOS when hashrate is unknown at the beginning and start difficulty is low or hashrate changed significantly later. Add option retarget-ratio to control safe boundaries for client hashrate.