decred: blockconfirm enhancement with blocknotify(-dcr)

+ some getwork logs on submit errors (not seen yet)
This commit is contained in:
Tanguy Pruvot 2016-03-06 16:30:06 +01:00
parent 284cbcdae7
commit 8db4565b30
4 changed files with 23 additions and 9 deletions

View file

@ -276,7 +276,7 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params)
coind->notreportingcounter = 0; coind->notreportingcounter = 0;
if (!strcmp("DCR", coind->symbol)) { if (!strcmp("DCR", coind->symbol)) {
usleep(500*YAAMP_MS); usleep(300*YAAMP_MS);
} }
block_confirm(coind->id, hash); block_confirm(coind->id, hash);

View file

@ -6,13 +6,25 @@ bool coind_submitwork(YAAMP_COIND *coind, const char *block)
int paramlen = strlen(block); int paramlen = strlen(block);
char *params = (char *)malloc(paramlen+1024); char *params = (char *)malloc(paramlen+1024);
if(!params) return false; if(!params) {
debuglog("%s: OOM!\n", __func__);
return false;
}
sprintf(params, "[\"%s\"]", block); sprintf(params, "[\"%s\"]", block);
json_value *json = rpc_call(&coind->rpc, "getwork", params); 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); 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"); json_value *json_res = json_get_object(json, "result");
bool b = json_res && json_res->type == json_boolean && json_res->u.boolean; bool b = json_res && json_res->type == json_boolean && json_res->u.boolean;

View file

@ -71,15 +71,17 @@ function BackendBlockFind1()
$coin = getdbo('db_coins', $db_block->coin_id); $coin = getdbo('db_coins', $db_block->coin_id);
if(!$coin->enable) continue; 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'; $db_block->category = 'orphan';
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport); $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
$block = $remote->getblock($db_block->blockhash); $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->amount = 0;
$db_block->save(); $db_block->save();

View file

@ -317,7 +317,7 @@ class SiteController extends CommonController
return; return;
} }
BackendUserCancelFailedPayment($user->id); BackendUserCancelFailedPayment($user->id);
$this->render('payments'); $this->redirect('payments');
} }
///////////////////////////////////////////////// /////////////////////////////////////////////////