From 8936af00f500b9a9e91fb24e7c0ac86fa2da19b7 Mon Sep 17 00:00:00 2001 From: Jethro Grassie Date: Mon, 11 Jan 2021 18:08:52 -0500 Subject: [PATCH] sss: check difficulty delta --- src/pool.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pool.c b/src/pool.c index 500282e..1065024 100644 --- a/src/pool.c +++ b/src/pool.c @@ -3072,8 +3072,16 @@ miner_on_block_template(json_object *message, client_t *client) if (dh > TEMLATE_HEIGHT_VARIANCE) { char m[64] = {0}; - snprintf(m, 64, "Bad height. " - "Differs to pool by %"PRIu64" blocks.", dh); + snprintf(m, 64, "Bad height delta: %"PRIu64, dh); + send_validation_error(client, m); + return; + } + + int64_t d = json_object_get_int64(difficulty); + if (d < (int64_t)pool_stats.network_difficulty) + { + char m[64] = {0}; + snprintf(m, 64, "Low difficulty: %"PRIu64, d); send_validation_error(client, m); return; } @@ -3102,8 +3110,8 @@ miner_on_block_template(json_object *message, client_t *client) job->miner_template = calloc(1, sizeof(block_template_t)); job->miner_template->blocktemplate_blob = strdup(btb); - job->miner_template->difficulty = json_object_get_int64(difficulty); - job->miner_template->height = json_object_get_int64(height); + job->miner_template->difficulty = d; + job->miner_template->height = h; strncpy(job->miner_template->prev_hash, json_object_get_string(prev_hash), 64);