From 8a9715f3066eb671dbebace38d971ca890e46f2f Mon Sep 17 00:00:00 2001 From: "admin@arionum.com" Date: Fri, 15 Nov 2019 13:36:40 +0200 Subject: [PATCH] bugfix for mn voting at 320000 --- include/block.inc.php | 16 +++++++++++++--- include/init.inc.php | 2 +- sanity.php | 10 +++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/block.inc.php b/include/block.inc.php index 538c806..c11b127 100755 --- a/include/block.inc.php +++ b/include/block.inc.php @@ -96,9 +96,13 @@ class Block if ($height>=80458) { //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( - "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] ); _log("MN Winner: $mn_winner", 2); @@ -921,8 +925,14 @@ class Block if ($height>=80458) { //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( - "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] ); _log("MN Winner: $mn_winner", 2); diff --git a/include/init.inc.php b/include/init.inc.php index 67a9d54..8e41e5f 100755 --- a/include/init.inc.php +++ b/include/init.inc.php @@ -1,6 +1,6 @@ run( + _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']] ); @@ -620,7 +620,7 @@ if ($current['height'] < $largest_height && $largest_height > 1) { if ($block_parse_failed==true||$argv[1]=="resync") { $last_resync=$db->single("SELECT val FROM config WHERE cfg='last_resync'"); if ($last_resyncrun("SET foreign_key_checks=0;"); $tables = ["accounts", "transactions", "mempool", "masternode","blocks"]; foreach ($tables as $table) { @@ -825,7 +825,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']-10080) { + if ($res['height']<$current['height']-10080) { $blacklist=1; } echo "Masternode Height: ".$res['height']."\n";