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
This commit is contained in:
Tanguy Pruvot 2016-02-14 14:04:39 +01:00
parent cc364febfc
commit e2f982300c
2 changed files with 6 additions and 3 deletions

View file

@ -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;

View file

@ -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'];