cli: improve coin generated command for confirmed orphans

some unstable (or flooded) wallet chains like LUX may fork twice
This commit is contained in:
Tanguy Pruvot 2017-10-22 04:57:53 +02:00
parent f14ae825de
commit 3eb8c33fc3

View file

@ -296,9 +296,19 @@ class CoinCommand extends CConsoleCommand
$height = $cur_height - $tx['confirmations'] + 1;
if ($tx['confirmations'] < 3) continue; // let the backend detect them...
$block = getdbosql('db_blocks', "coin_id={$coin->id} AND height=$height");
if ($block)
$nbOk++;
else {
if ($block) {
if ($block->category == 'orphan') {
if ($start_height > 0 && $height >= $start_height) {
$block->category = 'new';
if ($block->save()) echo "Fixed orphan block id {$block->id}\n";
$nbOk++;
} else {
echo("warning: orphan block {$block->height} with confirmations!\n");
$nbMissed++;
}
} else
$nbOk++;
} else {
$time = round($tx['time'] / 900) * 900;
if ($time < time() - 2 * 24 * 3600) continue;
echo strftime("%Y-%m-%d %H:%M", $tx['time'])." $time missed block $height : ".json_encode($tx)."\n";