diff --git a/stratum/client.cpp b/stratum/client.cpp index 844d23da9..c3787caf8 100644 --- a/stratum/client.cpp +++ b/stratum/client.cpp @@ -298,7 +298,9 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params) return false; } - YAAMP_COIND *coind = (YAAMP_COIND *)object_find(&g_list_coind, json_params->u.array.values[1]->u.integer, true); + int coinid = json_params->u.array.values[1]->u.integer; + if(!coinid) return false; + YAAMP_COIND *coind = (YAAMP_COIND *)object_find(&g_list_coind, coinid, true); if(!coind) return false; const char* hash = json_params->u.array.values[2]->u.string.ptr; @@ -307,6 +309,8 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params) debuglog("notify: new %s block %s\n", coind->symbol, hash); } + snprintf(coind->lastnotifyhash, 161, "%s", hash); + coind->newblock = true; coind->notreportingcounter = 0; diff --git a/stratum/client_submit.cpp b/stratum/client_submit.cpp index e1021f9eb..02227ecf4 100644 --- a/stratum/client_submit.cpp +++ b/stratum/client_submit.cpp @@ -277,10 +277,12 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL target_to_diff(coin_target), target_to_diff(hash_int), hash1, submitvalues->hash_be, templ->has_segwit_txs); - if(coind->noblocknotify) { - // DCR go wallet doesnt handle blocknotify= config (yet) - // required to store the user id and the user diff + if(!strcmp("DCR", coind->rpcencoding)) { + // delay between dcrd and dcrwallet sleep(1); + } + + if(!strcmp(coind->lastnotifyhash,submitvalues->hash_be)) { block_confirm(coind->id, submitvalues->hash_be); } diff --git a/stratum/coind.cpp b/stratum/coind.cpp index bfebc8f28..4ba9ab84f 100644 --- a/stratum/coind.cpp +++ b/stratum/coind.cpp @@ -165,7 +165,6 @@ void coind_init(YAAMP_COIND *coind) strcpy(account, coind->account); if(!strcmp(coind->rpcencoding, "DCR")) { coind->usegetwork = true; - //coind->noblocknotify = true; //sprintf(account, "default"); } diff --git a/stratum/coind.h b/stratum/coind.h index 5ea7fff89..d008a24e7 100644 --- a/stratum/coind.h +++ b/stratum/coind.h @@ -47,6 +47,7 @@ class YAAMP_COIND: public YAAMP_OBJECT bool enable; bool auto_ready; bool newblock; + char lastnotifyhash[192]; int height; double difficulty; @@ -66,7 +67,6 @@ class YAAMP_COIND: public YAAMP_OBJECT bool usememorypool; bool hasmasternodes; bool oldmasternodes; - bool noblocknotify; bool multialgos; // pow_hash field (or mined_hash) bool usesegwit; diff --git a/stratum/share.cpp b/stratum/share.cpp index c7106dafb..a8a4f8226 100644 --- a/stratum/share.cpp +++ b/stratum/share.cpp @@ -232,10 +232,10 @@ void block_add(int userid, int workerid, int coinid, int height, double diff, do } // called from blocknotify tool -void block_confirm(int coinid, const char *blockhash) +bool block_confirm(int coinid, const char *blockhash) { char hash[192]; - if(strlen(blockhash) < 64) return; + if(strlen(blockhash) < 64) return false; snprintf(hash, 161, "%s", blockhash); @@ -290,17 +290,18 @@ void block_confirm(int coinid, const char *blockhash) for(CLI li = g_list_block.first; li; li = li->next) { YAAMP_BLOCK *block = (YAAMP_BLOCK *)li->data; - if(block->coinid == coinid && !block->confirmed && !block->deleted) + if(block->coinid == coinid && !block->deleted) { if(strcmp(block->hash1, hash) && strcmp(block->hash2, hash)) continue; - debuglog("*** CONFIRMED %d : %s\n", block->height, block->hash2); - - strncpy(block->hash, blockhash, 65); - block->confirmed = true; - - return; + if (!block->confirmed) { + debuglog("*** CONFIRMED %d : %s\n", block->height, block->hash2); + strncpy(block->hash, blockhash, 65); + block->confirmed = true; + } + return true; } } + return false; } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/stratum/share.h b/stratum/share.h index 1decef96e..dd90eca47 100644 --- a/stratum/share.h +++ b/stratum/share.h @@ -100,7 +100,7 @@ inline void submit_delete(YAAMP_OBJECT *object) void block_prune(YAAMP_DB *db); void block_add(int userid, int workerid, int coinid, int height, double diff, double diff_user, const char *hash1, const char *h2, int segwit); -void block_confirm(int coinid, const char *hash); +bool block_confirm(int coinid, const char *hash); YAAMP_SUBMIT *submit_add(int remoteid, double difficulty); void submit_prune(YAAMP_DB *db);