From e2f982300c6775224e3ba6608d757361aa69bef5 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 14 Feb 2016 14:04:39 +0100 Subject: [PATCH] decred: detect generated blocks + stratum fix backend: generated blocks were not auto detected (to double check) stratum: seen on a new setup, if dcrd doesnt have --miningaddr set stratum is not able to distribute jobs and was crashing --- stratum/job.cpp | 2 ++ web/yaamp/core/backend/blocks.php | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/stratum/job.cpp b/stratum/job.cpp index a7224b3..b8a4a47 100644 --- a/stratum/job.cpp +++ b/stratum/job.cpp @@ -140,6 +140,8 @@ static bool job_assign_client(YAAMP_JOB *job, YAAMP_CLIENT *client, double maxha void job_assign_clients(YAAMP_JOB *job, double maxhash) { + if (!job) return; + job->speed = 0; job->count = 0; diff --git a/web/yaamp/core/backend/blocks.php b/web/yaamp/core/backend/blocks.php index 0898271..a3f043d 100644 --- a/web/yaamp/core/backend/blocks.php +++ b/web/yaamp/core/backend/blocks.php @@ -168,15 +168,15 @@ function BackendBlockFind2() $remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport); $mostrecent = 0; - if($coin->lastblock == null) $coin->lastblock = ''; + if(empty($coin->lastblock)) $coin->lastblock = ''; $list = $remote->listsinceblock($coin->lastblock); if(!$list) continue; // debuglog("find2 $coin->symbol"); foreach($list['transactions'] as $transaction) { - if($transaction['time'] > time() - 5*60) continue; if(!isset($transaction['blockhash'])) continue; + if($transaction['time'] > time() - 5*60) continue; if($transaction['time'] > $mostrecent) { @@ -192,7 +192,8 @@ function BackendBlockFind2() $db_block = getdbosql('db_blocks', "blockhash='{$transaction['blockhash']}' OR height={$blockext['height']}"); if($db_block) continue; -// debuglog("adding lost block $coin->name {$blockext['height']}"); + if ($coin->symbol == 'DCR') + debuglog("{$coin->name} generated block {$blockext['height']} detected!"); $db_block = new db_blocks; $db_block->blockhash = $transaction['blockhash'];