From 67e02cb498bd878ae302a63bcaff35840dc07035 Mon Sep 17 00:00:00 2001 From: "admin@arionum.com" Date: Wed, 18 Sep 2019 05:23:25 +0300 Subject: [PATCH 1/3] peer blacklist fix --- sanity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanity.php b/sanity.php index 2a033bf..6bd291d 100755 --- a/sanity.php +++ b/sanity.php @@ -822,7 +822,7 @@ if ($_config['masternode']==true&&!empty($_config['masternode_public_key'])&&!em if ($f) { $res=json_decode($f, true); $res=$res['data']; - if ($res['height']<$current['height']-360) { + if ($res['height']<$current['height']-360) { $blacklist=1; } echo "Masternode Height: ".$res['height']."\n"; @@ -878,4 +878,4 @@ if ($_config['masternode']==true&&!empty($_config['masternode_public_key'])&&!em _log("Finishing sanity"); -@unlink(SANITY_LOCK_PATH); +@unlink(SANITY_LOCK_PATH); \ No newline at end of file From 8adab781a1fd71f70601700f4c9521b5cd2384d4 Mon Sep 17 00:00:00 2001 From: "admin@arionum.com" Date: Wed, 18 Sep 2019 05:59:40 +0300 Subject: [PATCH 2/3] single new peer per sanity --- sanity.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sanity.php b/sanity.php index 6bd291d..9d0c79d 100755 --- a/sanity.php +++ b/sanity.php @@ -374,6 +374,8 @@ foreach ($r as $x) { if ($test !== false) { $total_peers++; 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 $data = peer_post($url."currentBlock", [], 5); 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; } // 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 $invalid = false; $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]); if ($data === false) { $invalid = true; break; } $ext = $block->get($i); - if ($i == $current['height'] - 30 && $ext['id'] != $data['id']) { + if ($i == $current['height'] - 100 && $ext['id'] != $data['id']) { $invalid = true; break; } @@ -617,7 +626,7 @@ if ($current['height'] < $largest_height && $largest_height > 1) { $to_remove=intval($argv[2]); } _log("Removing $to_remove blocks, the blockchain is stale."); - $block->pop(to_remove); + $block->pop($to_remove); $resyncing=true; } elseif ($current['date'] Date: Wed, 18 Sep 2019 06:22:11 +0300 Subject: [PATCH 3/3] default setting recheck blocks --- include/config-sample.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config-sample.inc.php b/include/config-sample.inc.php index f1d862d..37fd1c0 100755 --- a/include/config-sample.inc.php +++ b/include/config-sample.inc.php @@ -114,7 +114,7 @@ $_config['use_official_blacklist'] = true; */ // Recheck the last blocks on sanity -$_config['sanity_recheck_blocks'] = 10; +$_config['sanity_recheck_blocks'] = 30; // The interval to run the sanity in seconds $_config['sanity_interval'] = 900;