Merge branch 'master' of https://github.com/arionum/node into arionum-master
This commit is contained in:
81
sanity.php
81
sanity.php
@@ -95,60 +95,38 @@ $current = $block->current();
|
|||||||
// bootstrapping the initial sync
|
// bootstrapping the initial sync
|
||||||
if ($current['height']==1) {
|
if ($current['height']==1) {
|
||||||
echo "Bootstrapping!\n";
|
echo "Bootstrapping!\n";
|
||||||
$last=file_get_contents("http://dumps.arionum.com/last");
|
$db_name=substr($_config['db_connect'], strrpos($_config['db_connect'], "dbname=")+7);
|
||||||
$last=intval($last);
|
$db_host=substr($_config['db_connect'], strpos($_config['db_connect'], ":host=")+6);
|
||||||
$failed_sync=false;
|
$db_host=substr($db_host, 0, strpos($db_host, ";"));
|
||||||
for ($i=1000;$i<=$last;$i=$i+1000) {
|
|
||||||
echo "Download file $i\n";
|
echo "DB name: $db_name\n";
|
||||||
$res=trim(file_get_contents("http://dumps.arionum.com/aro.db.$i"));
|
echo "DB host: $db_host\n";
|
||||||
if ($res===false) {
|
echo "Downloading the blockchain dump from arionum.info\n";
|
||||||
echo "Could not download the bootstrap file $i. Syncing the old fashioned way.\n";
|
$arofile=__DIR__ . '/tmp/aro.sql';
|
||||||
|
if (file_exists("/usr/bin/curl")) {
|
||||||
|
system("/usr/bin/curl -o $arofile 'https://arionum.info/dump/aro.sql'", $ret);
|
||||||
|
} elseif (file_exists("/usr/bin/wget")) {
|
||||||
|
system("/usr/bin/wget -O $arofile 'https://arionum.info/dump/aro.sql'", $ret);
|
||||||
|
} else {
|
||||||
|
die("/usr/bin/curl and /usr/bin/wget not installed or inaccessible. Please install either of them.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo "Importing the blockchain dump\n";
|
||||||
|
system("mysql -h ".escapeshellarg($db_host)." -u ".escapeshellarg($_config['db_user'])." -p".escapeshellarg($_config['db_pass'])." ".escapeshellarg($db_name). " < ".$arofile);
|
||||||
|
echo "Bootstrapping completed. Waiting 2mins for the tables to be unlocked.\n";
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
sleep(120);
|
||||||
|
|
||||||
|
$res=$db->run("SHOW OPEN TABLES WHERE In_use > 0");
|
||||||
|
if (count($res==0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$data=json_decode($res, true);
|
echo "Tables still locked. Sleeping for another 2 min. \n";
|
||||||
|
|
||||||
if ($data===false||is_null($data)) {
|
|
||||||
echo "Could not parse the bootstrap file $i. Syncing the old fashioned way.\n";
|
|
||||||
echo json_last_error_msg();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
foreach ($data as $x) {
|
|
||||||
if (count($x['data'])>0) {
|
|
||||||
$transactions=[];
|
|
||||||
|
|
||||||
foreach ($x['data'] as $d) {
|
|
||||||
$trans = [
|
|
||||||
"id" => $d[0],
|
|
||||||
"dst" => $d[1],
|
|
||||||
"val" => $d[2],
|
|
||||||
"fee" => $d[3],
|
|
||||||
"signature" => $d[4],
|
|
||||||
"message" => $d[5],
|
|
||||||
"version" => $d[6],
|
|
||||||
"date" => $d[7],
|
|
||||||
"public_key" => $d[8],
|
|
||||||
];
|
|
||||||
ksort($trans);
|
|
||||||
$transactions[$d[0]] = $trans;
|
|
||||||
}
|
|
||||||
ksort($transactions);
|
|
||||||
$x['data']=$transactions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "-> Adding block $x[height]\n";
|
|
||||||
|
|
||||||
$res=$block->add($x['height'], $x['public_key'], $x['nonce'], $x['data'], $x['date'], $x['signature'], $x['difficulty'], $x['reward_signature'], $x['argon'], true);
|
|
||||||
if (!$res) {
|
|
||||||
echo "Error: Adding the block failed. Syncing the old way.\n";
|
|
||||||
$failed_sync=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($failed_sync) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$current = $block->current();
|
$current = $block->current();
|
||||||
}
|
}
|
||||||
@@ -683,7 +661,6 @@ if ($current['height'] < $largest_height && $largest_height > 1) {
|
|||||||
// $db->run("DELETE FROM masternode WHERE height>:h", [":h"=>$current['height']]);
|
// $db->run("DELETE FROM masternode WHERE height>:h", [":h"=>$current['height']]);
|
||||||
// $db->exec("UNLOCK TABLES");
|
// $db->exec("UNLOCK TABLES");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,12 +870,8 @@ echo "Masternode votes\n";
|
|||||||
$hash=escapeshellarg(san($hash));
|
$hash=escapeshellarg(san($hash));
|
||||||
system("php propagate.php transaction $hash > /dev/null 2>&1 &");
|
system("php propagate.php transaction $hash > /dev/null 2>&1 &");
|
||||||
echo "Blacklist Hash: $hash\n";
|
echo "Blacklist Hash: $hash\n";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user