diff --git a/README.md b/README.md index fb05293..7a30531 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,10 @@ blocknotify=wget -q -O /dev/null http://datum-gateway-host-ip:7152/NOTIFY - By default, if the connection with the pool is lost and fails to reconnect, the Gateway will disconnect all stratum clients. This way miners can use their built-in failover and switch to non-DATUM mining, or an alternate/backup Gateway. - Accepted/rejected share counts on mining hardware may not perfectly match with the pool. The delta may vary depending on the Gateway's configuration. This is because shares are first accepted or rejected as valid for your local template based on your local node, and then again accepted or rejected based on the pool's requirements, latency to the pool (stale work), latency between your node and the network (stale work), etc. Stratum v1 has no mechanism to report back to the miner that previously accepted work is now rejected, and it doesn't make sense to wait for the pool before responding, either. + - **Share Statistics**: The "Shares Accepted" and "Shares Rejected" counters on the web dashboard prefer pool statistics when a pool is configured/active, and otherwise show local stratum client statistics: + - When a DATUM pool connection is active (or configured), the dashboard shows shares accepted/rejected by the pool (pool perspective) + - When no pool connection is active, the dashboard shows shares accepted/rejected from connected stratum miners (local perspective) + - In all modes, block templates are constructed from your own Bitcoin node **Most importantly**, please note that this is currently a public **BETA** release. While best efforts have been made to ensure this software is as stable and as useful as possible, you may still encounter issues. diff --git a/src/datum_api.c b/src/datum_api.c index 82620df..cca1b91 100644 --- a/src/datum_api.c +++ b/src/datum_api.c @@ -89,10 +89,16 @@ static void html_leading_zeros(char * const buffer, const size_t buffer_size, co } void datum_api_var_DATUM_SHARES_ACCEPTED(char *buffer, size_t buffer_size, const T_DATUM_API_DASH_VARS *vardata) { - snprintf(buffer, buffer_size, "%llu (%llu diff)", (unsigned long long)datum_accepted_share_count, (unsigned long long)datum_accepted_share_diff); + // Prefer pool stats when a pool is configured/active; otherwise show local stratum client stats + // Pool considered active if the DATUM protocol is active, or configured if pool host is set + // Dashboard always renders datum_* counters; when no pool is active, we mirror local stats into datum_* at submit time + (void)vardata; + snprintf(buffer, buffer_size, "%llu (%llu diff)", (unsigned long long)datum_accepted_share_count, (unsigned long long)datum_accepted_share_diff); } void datum_api_var_DATUM_SHARES_REJECTED(char *buffer, size_t buffer_size, const T_DATUM_API_DASH_VARS *vardata) { - snprintf(buffer, buffer_size, "%llu (%llu diff)", (unsigned long long)datum_rejected_share_count, (unsigned long long)datum_rejected_share_diff); + // Prefer pool stats when a pool is configured/active; otherwise show local stratum client stats + (void)vardata; + snprintf(buffer, buffer_size, "%llu (%llu diff)", (unsigned long long)datum_rejected_share_count, (unsigned long long)datum_rejected_share_diff); } void datum_api_var_DATUM_CONNECTION_STATUS(char *buffer, size_t buffer_size, const T_DATUM_API_DASH_VARS *vardata) { const char *colour = "lime"; diff --git a/src/datum_stratum.c b/src/datum_stratum.c index 3f7fec4..65974a5 100644 --- a/src/datum_stratum.c +++ b/src/datum_stratum.c @@ -1268,6 +1268,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_stale_block(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } @@ -1277,6 +1281,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_time_too_old(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } @@ -1284,6 +1292,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_time_too_new(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } @@ -1295,6 +1307,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_high_hash_error(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } } else { @@ -1304,6 +1320,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_high_hash_error(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } } @@ -1314,6 +1334,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_stale(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } @@ -1323,6 +1347,10 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj send_rejected_duplicate(c, id); m->share_count_rejected++; m->share_diff_rejected += job_diff; + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_rejected_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_rejected_share_diff, job_diff, __ATOMIC_RELAXED); + } return 0; } @@ -1342,6 +1370,12 @@ int client_mining_submit(T_DATUM_CLIENT_DATA *c, uint64_t id, json_t *params_obj m->share_diff_accepted += job_diff; m->share_count_accepted++; + // Mirror to pool counters when no pool is active + if (!(datum_protocol_is_active() || (datum_config.datum_pool_host[0] != '\0'))) { + __atomic_add_fetch(&datum_accepted_share_count, 1, __ATOMIC_RELAXED); + __atomic_add_fetch(&datum_accepted_share_diff, job_diff, __ATOMIC_RELAXED); + } + // update since-snap totals m->share_count_since_snap++; m->share_diff_since_snap += job_diff;