1.0.0-alpha.4
This commit is contained in:
@@ -96,9 +96,13 @@ class Block
|
|||||||
|
|
||||||
if ($height>=80458) {
|
if ($height>=80458) {
|
||||||
//reward the masternode
|
//reward the masternode
|
||||||
|
// do not reward blacklisted mns after 320000
|
||||||
|
$check_mn_votes="";
|
||||||
|
if ($height>320000) {
|
||||||
|
$check_mn_votes="and voted=0";
|
||||||
|
}
|
||||||
$mn_winner=$db->single(
|
$mn_winner=$db->single(
|
||||||
"SELECT public_key FROM masternode WHERE status=1 AND blacklist<:current AND height<:start ORDER by last_won ASC, public_key ASC LIMIT 1",
|
"SELECT public_key FROM masternode WHERE status=1 AND blacklist<:current AND height<:start $check_mn_votes ORDER by last_won ASC, public_key ASC LIMIT 1",
|
||||||
[":current"=>$height, ":start"=>$height-360]
|
[":current"=>$height, ":start"=>$height-360]
|
||||||
);
|
);
|
||||||
_log("MN Winner: $mn_winner", 2);
|
_log("MN Winner: $mn_winner", 2);
|
||||||
@@ -1032,8 +1036,14 @@ class Block
|
|||||||
if ($height>=80458) {
|
if ($height>=80458) {
|
||||||
//reward the masternode
|
//reward the masternode
|
||||||
|
|
||||||
|
// do not reward blacklisted mns after 320000
|
||||||
|
$check_mn_votes="";
|
||||||
|
if ($height>320000) {
|
||||||
|
$check_mn_votes="and voted=0";
|
||||||
|
}
|
||||||
|
|
||||||
$mn_winner=$db->single(
|
$mn_winner=$db->single(
|
||||||
"SELECT public_key FROM masternode WHERE status=1 AND blacklist<:current AND height<:start ORDER by last_won ASC, public_key ASC LIMIT 1",
|
"SELECT public_key FROM masternode WHERE status=1 AND blacklist<:current AND height<:start $check_mn_votes ORDER by last_won ASC, public_key ASC LIMIT 1",
|
||||||
[":current"=>$height, ":start"=>$height-360]
|
[":current"=>$height, ":start"=>$height-360]
|
||||||
);
|
);
|
||||||
_log("MN Winner: $mn_winner", 2);
|
_log("MN Winner: $mn_winner", 2);
|
||||||
|
|||||||
@@ -128,6 +128,10 @@ $_config['sanity_rebroadcast_locals'] = true;
|
|||||||
// Get more peers?
|
// Get more peers?
|
||||||
$_config['get_more_peers'] = true;
|
$_config['get_more_peers'] = true;
|
||||||
|
|
||||||
|
// Allow automated resyncs if the node is stuck. Enabled by default
|
||||||
|
|
||||||
|
$_config['auto_resync'] = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Logging Configuration
|
| Logging Configuration
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
// ARO version
|
// ARO version
|
||||||
define("VERSION", "1.0.0-alpha.2");
|
define("VERSION", "1.0.0-alpha.4");
|
||||||
// UTC timezone by default
|
// UTC timezone by default
|
||||||
date_default_timezone_set("UTC");
|
date_default_timezone_set("UTC");
|
||||||
|
|
||||||
|
|||||||
59
sanity.php
59
sanity.php
@@ -48,7 +48,7 @@ if (file_exists(SANITY_LOCK_PATH)) {
|
|||||||
$pid_time = filemtime(SANITY_LOCK_PATH);
|
$pid_time = filemtime(SANITY_LOCK_PATH);
|
||||||
|
|
||||||
// If the process died, restart after 10 times the sanity interval
|
// If the process died, restart after 10 times the sanity interval
|
||||||
if (time() - $pid_time > ($_config['sanity_interval'] ?? 900 * 10)) {
|
if (time() - $pid_time > ($_config['sanity_interval'] * 20 ?? 900 * 20)) {
|
||||||
@unlink(SANITY_LOCK_PATH);
|
@unlink(SANITY_LOCK_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,9 +384,9 @@ foreach ($r as $x) {
|
|||||||
// get the current block and check it's blockchain
|
// get the current block and check it's blockchain
|
||||||
$data = peer_post($url."currentBlock", [], 5);
|
$data = peer_post($url."currentBlock", [], 5);
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
_log("Peer $x[hostname] unresponsive");
|
_log("Peer $x[hostname] unresponsive");
|
||||||
// if the peer is unresponsive, mark it as failed and blacklist it for a while
|
// if the peer is unresponsive, mark it as failed and blacklist it for a while
|
||||||
$db->run(
|
$db->run(
|
||||||
"UPDATE peers SET fails=fails+1, blacklisted=UNIX_TIMESTAMP()+((fails+1)*3600) WHERE id=:id",
|
"UPDATE peers SET fails=fails+1, blacklisted=UNIX_TIMESTAMP()+((fails+1)*3600) WHERE id=:id",
|
||||||
[":id" => $x['id']]
|
[":id" => $x['id']]
|
||||||
);
|
);
|
||||||
@@ -620,14 +620,24 @@ if ($current['height'] < $largest_height && $largest_height > 1) {
|
|||||||
if ($block_parse_failed==true||$argv[1]=="resync") {
|
if ($block_parse_failed==true||$argv[1]=="resync") {
|
||||||
$last_resync=$db->single("SELECT val FROM config WHERE cfg='last_resync'");
|
$last_resync=$db->single("SELECT val FROM config WHERE cfg='last_resync'");
|
||||||
if ($last_resync<time()-(3600*24)||$argv[1]=="resync") {
|
if ($last_resync<time()-(3600*24)||$argv[1]=="resync") {
|
||||||
if ($current['date']<time()-(3600*72)||$argv[1]=="resync") {
|
if ((( ($current['date']<time()-(3600*72) ) && $_config['auto_resync'])!==false ) || $argv[1]=="resync" ) {
|
||||||
$to_remove=3000;
|
$db->run("SET foreign_key_checks=0;");
|
||||||
if (intval($argv[2])>0) {
|
$tables = ["accounts", "transactions", "mempool", "masternode","blocks"];
|
||||||
$to_remove=intval($argv[2]);
|
foreach ($tables as $table) {
|
||||||
|
$db->run("TRUNCATE TABLE {$table}");
|
||||||
}
|
}
|
||||||
|
|
||||||
_log("Removing $to_remove blocks, the blockchain is stale.");
|
_log("Removing $to_remove blocks, the blockchain is stale.");
|
||||||
//$block->pop($to_remove);
|
//$block->pop($to_remove);
|
||||||
|
$db->run("SET foreign_key_checks=1;");
|
||||||
|
|
||||||
$resyncing=true;
|
$resyncing=true;
|
||||||
|
$db->run("UPDATE config SET val=0 WHERE cfg='sanity_sync'", [":time" => $t]);
|
||||||
|
|
||||||
|
_log("Exiting sanity, next sanity will resync from scratch.");
|
||||||
|
|
||||||
|
@unlink(SANITY_LOCK_PATH);
|
||||||
|
exit;
|
||||||
} elseif ($current['date']<time()-(3600*24)) {
|
} elseif ($current['date']<time()-(3600*24)) {
|
||||||
_log("Removing 200 blocks, the blockchain is stale.");
|
_log("Removing 200 blocks, the blockchain is stale.");
|
||||||
//$block->pop(200);
|
//$block->pop(200);
|
||||||
@@ -746,19 +756,6 @@ foreach ($r as $x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//clean tmp files
|
|
||||||
_log("Cleaning tmp files");
|
|
||||||
$f = scandir("tmp/");
|
|
||||||
$time = time();
|
|
||||||
foreach ($f as $x) {
|
|
||||||
if (strlen($x) < 5 && substr($x, 0, 1) == ".") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$pid_time = filemtime("tmp/$x");
|
|
||||||
if ($time - $pid_time > 7200) {
|
|
||||||
@unlink("tmp/$x");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//recheck the last blocks
|
//recheck the last blocks
|
||||||
@@ -831,7 +828,7 @@ if ($_config['masternode']==true&&!empty($_config['masternode_public_key'])&&!em
|
|||||||
if ($f) {
|
if ($f) {
|
||||||
$res=json_decode($f, true);
|
$res=json_decode($f, true);
|
||||||
$res=$res['data'];
|
$res=$res['data'];
|
||||||
if ($res['height']<$current['height']-360) {
|
if ($res['height']<$current['height']-10080) {
|
||||||
$blacklist=1;
|
$blacklist=1;
|
||||||
}
|
}
|
||||||
echo "Masternode Height: ".$res['height']."\n";
|
echo "Masternode Height: ".$res['height']."\n";
|
||||||
@@ -885,6 +882,22 @@ if ($_config['masternode']==true&&!empty($_config['masternode_public_key'])&&!em
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//clean tmp files
|
||||||
|
_log("Cleaning tmp files");
|
||||||
|
$f = scandir("tmp/");
|
||||||
|
$time = time();
|
||||||
|
foreach ($f as $x) {
|
||||||
|
if (strlen($x) < 5 && substr($x, 0, 1) == ".") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$pid_time = filemtime("tmp/$x");
|
||||||
|
if ($time - $pid_time > 7200) {
|
||||||
|
@unlink("tmp/$x");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_log("Finishing sanity");
|
_log("Finishing sanity");
|
||||||
|
|
||||||
@unlink(SANITY_LOCK_PATH);
|
@unlink(SANITY_LOCK_PATH);
|
||||||
|
|||||||
Reference in New Issue
Block a user