|
|
@@ -1216,6 +1216,19 @@ static
|
|
|
void pool_set_uri(struct pool * const pool, char * const uri)
|
|
|
{
|
|
|
pool->rpc_url = uri;
|
|
|
+ pool->pool_diff_effective_retroactively = uri_get_param_bool2(uri, "retrodiff");
|
|
|
+}
|
|
|
+
|
|
|
+static
|
|
|
+bool pool_diff_effective_retroactively(struct pool * const pool)
|
|
|
+{
|
|
|
+ if (pool->pool_diff_effective_retroactively != BTS_UNKNOWN) {
|
|
|
+ return pool->pool_diff_effective_retroactively;
|
|
|
+ }
|
|
|
+
|
|
|
+ // By default, we enable retrodiff for stratum pools since some servers implement mining.set_difficulty in this way
|
|
|
+ // Note that share_result will explicitly disable BTS_UNKNOWN -> BTS_FALSE if a retrodiff share is rejected specifically for its failure to meet the target.
|
|
|
+ return pool->stratum_active;
|
|
|
}
|
|
|
|
|
|
/* Pool variant of test and set */
|
|
|
@@ -5264,6 +5277,15 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
|
|
|
char reason[32];
|
|
|
put_in_parens(reason, sizeof(reason), extract_reject_reason(val, res, err, work));
|
|
|
applog(LOG_DEBUG, "Share above target rejected%s by pool %u as expected, ignoring", reason, pool->pool_no);
|
|
|
+
|
|
|
+ // Stratum error 23 is "low difficulty share", which suggests this pool tracks job difficulty correctly.
|
|
|
+ // Therefore, we disable retrodiff if it was enabled-by-default.
|
|
|
+ if (pool->pool_diff_effective_retroactively == BTS_UNKNOWN) {
|
|
|
+ json_t *errnum;
|
|
|
+ if (work->stratum && err && json_is_array(err) && json_array_size(err) >= 1 && (errnum = json_array_get(err, 0)) && json_is_number(errnum) && ((int)json_number_value(errnum)) == 23) {
|
|
|
+ pool->pool_diff_effective_retroactively = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
mutex_lock(&stats_lock);
|
|
|
cgpu->rejected++;
|
|
|
@@ -10599,7 +10621,7 @@ enum test_nonce2_result _test_nonce2(struct work *work, uint32_t nonce, bool che
|
|
|
{
|
|
|
bool high_hash = true;
|
|
|
struct pool * const pool = work->pool;
|
|
|
- if (pool->stratum_active)
|
|
|
+ if (pool_diff_effective_retroactively(pool))
|
|
|
{
|
|
|
// Some stratum pools are buggy and expect difficulty changes to be immediate retroactively, so if the target has changed, check and submit just in case
|
|
|
if (memcmp(pool->next_target, work->target, sizeof(work->target)))
|
|
|
@@ -10607,7 +10629,10 @@ enum test_nonce2_result _test_nonce2(struct work *work, uint32_t nonce, bool che
|
|
|
applog(LOG_DEBUG, "Stratum pool %u target has changed since work job issued, checking that too",
|
|
|
pool->pool_no);
|
|
|
if (hash_target_check_v(work->hash, pool->next_target))
|
|
|
+ {
|
|
|
high_hash = false;
|
|
|
+ work->work_difficulty = target_diff(pool->next_target);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (high_hash)
|