Merge branch 'master' of github.com:ariochain/node
This commit is contained in:
@@ -114,7 +114,7 @@ $_config['use_official_blacklist'] = true;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Recheck the last blocks on sanity
|
// Recheck the last blocks on sanity
|
||||||
$_config['sanity_recheck_blocks'] = 10;
|
$_config['sanity_recheck_blocks'] = 30;
|
||||||
|
|
||||||
// The interval to run the sanity in seconds
|
// The interval to run the sanity in seconds
|
||||||
$_config['sanity_interval'] = 900;
|
$_config['sanity_interval'] = 900;
|
||||||
|
|||||||
19
sanity.php
19
sanity.php
@@ -374,6 +374,8 @@ foreach ($r as $x) {
|
|||||||
if ($test !== false) {
|
if ($test !== false) {
|
||||||
$total_peers++;
|
$total_peers++;
|
||||||
echo "Peered with: $peer[hostname]\n";
|
echo "Peered with: $peer[hostname]\n";
|
||||||
|
// a single new peer per sanity
|
||||||
|
$_config['get_more_peers']==false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,6 +384,13 @@ 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");
|
||||||
|
// if the peer is unresponsive, mark it as failed and blacklist it for a while
|
||||||
|
$db->run(
|
||||||
|
"UPDATE peers SET fails=fails+1, blacklisted=UNIX_TIMESTAMP()+((fails+1)*3600) WHERE id=:id",
|
||||||
|
[":id" => $x['id']]
|
||||||
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// peer was responsive, mark it as good
|
// peer was responsive, mark it as good
|
||||||
@@ -484,14 +493,14 @@ if ($current['height'] < $largest_height && $largest_height > 1) {
|
|||||||
//if we're not on the same blockchain and also it's not the most common, verify all the blocks on on this blockchain starting at current-30 until current
|
//if we're not on the same blockchain and also it's not the most common, verify all the blocks on on this blockchain starting at current-30 until current
|
||||||
$invalid = false;
|
$invalid = false;
|
||||||
$last_good = $current['height'];
|
$last_good = $current['height'];
|
||||||
for ($i = $current['height'] - 30; $i < $current['height']; $i++) {
|
for ($i = $current['height'] - 100; $i < $current['height']; $i++) {
|
||||||
$data = peer_post($url."getBlock", ["height" => $i]);
|
$data = peer_post($url."getBlock", ["height" => $i]);
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
$invalid = true;
|
$invalid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$ext = $block->get($i);
|
$ext = $block->get($i);
|
||||||
if ($i == $current['height'] - 30 && $ext['id'] != $data['id']) {
|
if ($i == $current['height'] - 100 && $ext['id'] != $data['id']) {
|
||||||
$invalid = true;
|
$invalid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -617,7 +626,7 @@ if ($current['height'] < $largest_height && $largest_height > 1) {
|
|||||||
$to_remove=intval($argv[2]);
|
$to_remove=intval($argv[2]);
|
||||||
}
|
}
|
||||||
_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);
|
||||||
$resyncing=true;
|
$resyncing=true;
|
||||||
} 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.");
|
||||||
@@ -822,7 +831,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']-360) {
|
||||||
$blacklist=1;
|
$blacklist=1;
|
||||||
}
|
}
|
||||||
echo "Masternode Height: ".$res['height']."\n";
|
echo "Masternode Height: ".$res['height']."\n";
|
||||||
@@ -878,4 +887,4 @@ if ($_config['masternode']==true&&!empty($_config['masternode_public_key'])&&!em
|
|||||||
|
|
||||||
_log("Finishing sanity");
|
_log("Finishing sanity");
|
||||||
|
|
||||||
@unlink(SANITY_LOCK_PATH);
|
@unlink(SANITY_LOCK_PATH);
|
||||||
Reference in New Issue
Block a user