Implement SPORK_14_REQUIRE_SENTINEL (#1163)

This commit is contained in:
Tim Flynn 2016-11-23 10:30:36 -05:00 committed by UdjinM6
parent ec59862506
commit 3e8c0062a0
5 changed files with 28 additions and 5 deletions

View File

@ -620,7 +620,7 @@ bool CMasternodePaymentVote::IsValid(CNode* pnode, int nValidationHeight, std::s
return false;
}
int nRank = mnodeman.GetMasternodeRank(vinMasternode, nBlockHeight - 101, nMinRequiredProtocol);
int nRank = mnodeman.GetMasternodeRank(vinMasternode, nBlockHeight - 101, nMinRequiredProtocol, false);
if(nRank > MNPAYMENTS_SIGNATURES_TOTAL) {
// It's common to have masternodes mistakenly think they are in the top 10
@ -650,7 +650,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
// if we have not enough data about masternodes.
if(!masternodeSync.IsMasternodeListSynced()) return false;
int nRank = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight - 101, GetMinMasternodePaymentsProto());
int nRank = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight - 101, GetMinMasternodePaymentsProto(), false);
if (nRank == -1) {
LogPrint("mnpayments", "CMasternodePayments::ProcessBlock -- Unknown Masternode\n");

View File

@ -8,6 +8,7 @@
#include "key.h"
#include "main.h"
#include "net.h"
#include "spork.h"
#include "timedata.h"
class CMasternode;
@ -258,6 +259,19 @@ public:
bool IsWatchdogExpired() { return nActiveState == MASTERNODE_WATCHDOG_EXPIRED; }
bool IsValidForPayment()
{
if(nActiveState == MASTERNODE_ENABLED) {
return true;
}
if(!sporkManager.IsSporkActive(SPORK_14_REQUIRE_SENTINEL_FLAG) &&
(nActiveState == MASTERNODE_WATCHDOG_EXPIRED)) {
return true;
}
return false;
}
bool IsValidNetAddr();
void IncreasePoSeBanScore() { if(nPoSeBanScore < MASTERNODE_POSE_BAN_MAX_SCORE) nPoSeBanScore++; }

View File

@ -476,7 +476,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
BOOST_FOREACH(CMasternode &mn, vMasternodes)
{
mn.Check();
if(!mn.IsEnabled()) continue;
if(!mn.IsValidForPayment()) continue;
// //check protocol version
if(mn.nProtocolVersion < mnpayments.GetMinMasternodePaymentsProto()) continue;
@ -581,10 +581,13 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int nBlockHeight, int nM
// scan for winner
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < nMinProtocol) continue;
mn.Check();
if(fOnlyActive) {
mn.Check();
if(!mn.IsEnabled()) continue;
}
else {
if(!mn.IsValidForPayment()) continue;
}
int64_t nScore = mn.CalculateScore(blockHash).GetCompact(false);
vecMasternodeScores.push_back(std::make_pair(nScore, &mn));

View File

@ -112,6 +112,7 @@ bool CSporkManager::IsSporkActive(int nSporkID)
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: r = SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT; break;
case SPORK_12_RECONSIDER_BLOCKS: r = SPORK_12_RECONSIDER_BLOCKS_DEFAULT; break;
case SPORK_13_OLD_SUPERBLOCK_FLAG: r = SPORK_13_OLD_SUPERBLOCK_FLAG_DEFAULT; break;
case SPORK_14_REQUIRE_SENTINEL_FLAG: r = SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT; break;
default:
LogPrint("spork", "CSporkManager::IsSporkActive -- Unknown Spork ID %d\n", nSporkID);
r = 4070908800; // 2099-1-1 i.e. off by default
@ -137,6 +138,7 @@ int64_t CSporkManager::GetSporkValue(int nSporkID)
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT;
case SPORK_12_RECONSIDER_BLOCKS: return SPORK_12_RECONSIDER_BLOCKS_DEFAULT;
case SPORK_13_OLD_SUPERBLOCK_FLAG: return SPORK_13_OLD_SUPERBLOCK_FLAG_DEFAULT;
case SPORK_14_REQUIRE_SENTINEL_FLAG: return SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT;
default:
LogPrint("spork", "CSporkManager::GetSporkValue -- Unknown Spork ID %d\n", nSporkID);
return -1;
@ -154,6 +156,7 @@ int CSporkManager::GetSporkIDByName(std::string strName)
if (strName == "SPORK_10_MASTERNODE_PAY_UPDATED_NODES") return SPORK_10_MASTERNODE_PAY_UPDATED_NODES;
if (strName == "SPORK_12_RECONSIDER_BLOCKS") return SPORK_12_RECONSIDER_BLOCKS;
if (strName == "SPORK_13_OLD_SUPERBLOCK_FLAG") return SPORK_13_OLD_SUPERBLOCK_FLAG;
if (strName == "SPORK_14_REQUIRE_SENTINEL_FLAG") return SPORK_14_REQUIRE_SENTINEL_FLAG;
LogPrint("spork", "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
return -1;
@ -170,6 +173,7 @@ std::string CSporkManager::GetSporkNameByID(int nSporkID)
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return "SPORK_10_MASTERNODE_PAY_UPDATED_NODES";
case SPORK_12_RECONSIDER_BLOCKS: return "SPORK_12_RECONSIDER_BLOCKS";
case SPORK_13_OLD_SUPERBLOCK_FLAG: return "SPORK_13_OLD_SUPERBLOCK_FLAG";
case SPORK_14_REQUIRE_SENTINEL_FLAG: return "SPORK_14_REQUIRE_SENTINEL_FLAG";
default:
LogPrint("spork", "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
return "Unknown";

View File

@ -17,7 +17,7 @@ class CSporkManager;
- This would result in old clients getting confused about which spork is for what
*/
static const int SPORK_START = 10001;
static const int SPORK_END = 10012;
static const int SPORK_END = 10013;
static const int SPORK_2_INSTANTSEND_ENABLED = 10001;
static const int SPORK_3_INSTANTSEND_BLOCK_FILTERING = 10002;
@ -27,6 +27,7 @@ static const int SPORK_9_SUPERBLOCKS_ENABLED = 10008;
static const int SPORK_10_MASTERNODE_PAY_UPDATED_NODES = 10009;
static const int SPORK_12_RECONSIDER_BLOCKS = 10011;
static const int SPORK_13_OLD_SUPERBLOCK_FLAG = 10012;
static const int SPORK_14_REQUIRE_SENTINEL_FLAG = 10013;
static const int64_t SPORK_2_INSTANTSEND_ENABLED_DEFAULT = 0; // ON
static const int64_t SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT = 0; // ON
@ -36,6 +37,7 @@ static const int64_t SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT = 407090
static const int64_t SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT = 4070908800; // OFF
static const int64_t SPORK_12_RECONSIDER_BLOCKS_DEFAULT = 0; // 0 BLOCKS
static const int64_t SPORK_13_OLD_SUPERBLOCK_FLAG_DEFAULT = 4070908800; // OFF
static const int64_t SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT = 4070908800; // OFF
extern std::map<uint256, CSporkMessage> mapSporks;
extern CSporkManager sporkManager;