From 8db4565b3017d06e89f4a625b675defa2bf4aeb2 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 6 Mar 2016 16:30:06 +0100 Subject: [PATCH] decred: blockconfirm enhancement with blocknotify(-dcr) + some getwork logs on submit errors (not seen yet) --- stratum/client.cpp | 2 +- stratum/coind_submit.cpp | 16 ++++++++++++++-- web/yaamp/core/backend/blocks.php | 12 +++++++----- web/yaamp/modules/site/SiteController.php | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/stratum/client.cpp b/stratum/client.cpp index 65ad141..c01afa2 100644 --- a/stratum/client.cpp +++ b/stratum/client.cpp @@ -276,7 +276,7 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params) coind->notreportingcounter = 0; if (!strcmp("DCR", coind->symbol)) { - usleep(500*YAAMP_MS); + usleep(300*YAAMP_MS); } block_confirm(coind->id, hash); diff --git a/stratum/coind_submit.cpp b/stratum/coind_submit.cpp index df85d10..f1f8b6f 100644 --- a/stratum/coind_submit.cpp +++ b/stratum/coind_submit.cpp @@ -6,13 +6,25 @@ bool coind_submitwork(YAAMP_COIND *coind, const char *block) int paramlen = strlen(block); char *params = (char *)malloc(paramlen+1024); - if(!params) return false; + if(!params) { + debuglog("%s: OOM!\n", __func__); + return false; + } sprintf(params, "[\"%s\"]", block); json_value *json = rpc_call(&coind->rpc, "getwork", params); + if(!json) { + debuglog("%s: retry\n", __func__); + usleep(500*YAAMP_MS); + json = rpc_call(&coind->rpc, "getwork", params); + } free(params); - if(!json) return false; + if(!json) { + debuglog("%s: error, no answer\n", __func__); + return false; + } + json_value *json_res = json_get_object(json, "result"); bool b = json_res && json_res->type == json_boolean && json_res->u.boolean; diff --git a/web/yaamp/core/backend/blocks.php b/web/yaamp/core/backend/blocks.php index b27170a..29acaba 100644 --- a/web/yaamp/core/backend/blocks.php +++ b/web/yaamp/core/backend/blocks.php @@ -71,15 +71,17 @@ function BackendBlockFind1() $coin = getdbo('db_coins', $db_block->coin_id); if(!$coin->enable) continue; - // noblocknofify: add a small delay before declaring it orphan - if($coin->symbol == 'DCR' && (time() - $db_block->time) < 240) - continue; - $db_block->category = 'orphan'; $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport); $block = $remote->getblock($db_block->blockhash); - if(!$block || !isset($block['tx']) || !isset($block['tx'][0])) + if($coin->symbol == 'DCR' && (time() - $db_block->time) < 300) { + // DCR generated blocks need some time to be accepted by the network + if (!$block) continue; + $tx = $remote->gettransaction($block['tx'][0]); + if (!$tx || !isset($tx['details'])) continue; + } + else if(!$block || !isset($block['tx']) || !isset($block['tx'][0])) { $db_block->amount = 0; $db_block->save(); diff --git a/web/yaamp/modules/site/SiteController.php b/web/yaamp/modules/site/SiteController.php index c3ff501..d1f782f 100644 --- a/web/yaamp/modules/site/SiteController.php +++ b/web/yaamp/modules/site/SiteController.php @@ -317,7 +317,7 @@ class SiteController extends CommonController return; } BackendUserCancelFailedPayment($user->id); - $this->render('payments'); + $this->redirect('payments'); } /////////////////////////////////////////////////