Removed PoSe due to consensus issues

- With nodes coming and going on the network, the network could come to different opinions about who should get paid next in line due to some nodes being flagged as failing a PoSe check. This will have to be fixed by introducing a blockchain based PoSe system, but that's out of the scope of this release. To fix the issues in the interrim, I'm removing PoSe checks for the time being.
This commit is contained in:
Evan Duffield 2015-06-23 16:44:31 -07:00
parent 4afaa1d8cf
commit f1b868f098
11 changed files with 43 additions and 465 deletions

View File

@ -3,7 +3,7 @@
######################################################################
TEMPLATE = app
TARGET =
TARGET =
DEPENDPATH += . \
src \
src/compat \
@ -89,7 +89,6 @@ HEADERS += src/activemasternode.h \
src/limitedmap.h \
src/main.h \
src/masternode-payments.h \
src/masternode-pos.h \
src/masternode.h \
src/masternodeconfig.h \
src/masternodeman.h \
@ -385,7 +384,6 @@ SOURCES += src/activemasternode.cpp \
src/leveldbwrapper.cpp \
src/main.cpp \
src/masternode-payments.cpp \
src/masternode-pos.cpp \
src/masternode.cpp \
src/masternodeconfig.cpp \
src/masternodeman.cpp \

View File

@ -109,7 +109,6 @@ BITCOIN_CORE_H = \
main.h \
masternode.h \
masternode-payments.h \
masternode-pos.h \
masternode-budget.h \
masternodeman.h \
masternodeconfig.h \
@ -286,7 +285,6 @@ libbitcoin_common_a_SOURCES = \
masternode.cpp \
masternode-budget.cpp \
masternode-payments.cpp \
masternode-pos.cpp \
masternodeman.cpp \
masternodeconfig.cpp \
instantx.cpp \

View File

@ -187,7 +187,6 @@ void CCoinbasePayee::BuildIndex()
CBlock block;
if (ReadBlockFromDisk(block, pindexPrev)) {
printf("scan block\n");
ProcessBlockCoinbaseTX(block.vtx[0], block.nTime);
}

View File

@ -463,12 +463,6 @@ void CleanTransactionLocksList()
fFound = true;
}
}
if(!fFound){
//increment a scanning error
CMasternodeScanningError mnse(pmn->vin, SCANNING_ERROR_IX_NO_RESPONSE, it->second.nBlockHeight);
pmn->ApplyScanningError(mnse);
}
}
if(mapTxLockReq.count(it->second.txHash)){

View File

@ -755,7 +755,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
/**
* Check transaction inputs to mitigate two
* potential denial-of-service attacks:
*
*
* 1. scriptSigs with extra data stuffed into them,
* not consumed by scriptPubKey (or P2SH script)
* 2. P2SH scripts with a crazy number of expensive
@ -2304,7 +2304,7 @@ static int64_t nTimeFlush = 0;
static int64_t nTimeChainState = 0;
static int64_t nTimePostConnect = 0;
/**
/**
* Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
* corresponding to pindexNew, to bypass loading it again from disk.
*/
@ -2940,7 +2940,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
{
if(!IsBlockPayeeValid(block.vtx[0], pindexPrev->nHeight+1))
{
if(Params().NetworkID() != CBaseChainParams::REGTEST)
if(Params().NetworkID() != CBaseChainParams::REGTEST)
return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
}
@ -3017,7 +3017,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
return state.DoS(100, error("%s : forked chain older than last checkpoint (height %d)", __func__, nHeight));
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
if (block.nVersion < 2 &&
if (block.nVersion < 2 &&
CBlockIndex::IsSuperMajority(2, pindexPrev, Params().RejectBlockOutdatedMajority()))
{
return state.Invalid(error("%s : rejected nVersion=1 block", __func__),
@ -3046,7 +3046,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
// if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
if (block.nVersion >= 2 &&
if (block.nVersion >= 2 &&
CBlockIndex::IsSuperMajority(2, pindexPrev, Params().EnforceBlockUpgradeMajority()))
{
CScript expect = CScript() << nHeight;
@ -3242,7 +3242,6 @@ bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDis
coinbasePayee.ProcessBlockCoinbaseTX(pblock->vtx[0], pblock->nTime);
darkSendPool.NewBlock();
masternodePayments.ProcessBlock(GetHeight()+10);
mnscan.DoMasternodePOSChecks();
budget.NewBlock();
}
}
@ -3265,9 +3264,9 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
return false;
if (!CheckBlock(block, state, fCheckPOW, fCheckMerkleRoot))
return false;
return false;
if (!ContextualCheckBlock(block, state, pindexPrev))
return false;
return false;
if (!ConnectBlock(block, state, &indexDummy, viewNew, true))
return false;
assert(state.IsValid());
@ -3943,8 +3942,6 @@ bool static AlreadyHave(const CInv& inv)
return mapSporks.count(inv.hash);
case MSG_MASTERNODE_WINNER:
return mapMasternodePayeeVotes.count(inv.hash);
case MSG_MASTERNODE_SCANNING_ERROR:
return mapMasternodeScanningErrors.count(inv.hash);
case MSG_BUDGET_VOTE:
return mapSeenMasternodeBudgetVotes.count(inv.hash);
case MSG_BUDGET_PROPOSAL:
@ -4116,16 +4113,6 @@ void static ProcessGetData(CNode* pfrom)
pushed = true;
}
}
if (!pushed && inv.type == MSG_MASTERNODE_SCANNING_ERROR) {
if(mapMasternodeScanningErrors.count(inv.hash)){
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(1000);
ss << mapMasternodeScanningErrors[inv.hash];
pfrom->PushMessage("mnse", ss);
pushed = true;
}
}
if (!pushed && inv.type == MSG_BUDGET_VOTE) {
if(mapSeenMasternodeBudgetVotes.count(inv.hash)){
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
@ -4145,7 +4132,7 @@ void static ProcessGetData(CNode* pfrom)
pushed = true;
}
}
if (!pushed && inv.type == MSG_BUDGET_FINALIZED_VOTE) {
if(mapSeenFinalizedBudgetVotes.count(inv.hash)){
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
@ -4830,8 +4817,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// This asymmetric behavior for inbound and outbound connections was introduced
// to prevent a fingerprinting attack: an attacker can send specific fake addresses
// to users' AddrMan and later request them by sending getaddr messages.
// Making users (which are behind NAT and can only make outgoing connections) ignore
// to users' AddrMan and later request them by sending getaddr messages.
// Making users (which are behind NAT and can only make outgoing connections) ignore
// getaddr message mitigates the attack.
else if ((strCommand == "getaddr") && (pfrom->fInbound))
{
@ -5057,7 +5044,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
masternodePayments.ProcessMessageMasternodePayments(pfrom, strCommand, vRecv);
ProcessMessageInstantX(pfrom, strCommand, vRecv);
ProcessSpork(pfrom, strCommand, vRecv);
ProcessMessageMasternodePOS(pfrom, strCommand, vRecv);
}

View File

@ -12,7 +12,6 @@
#include "util.h"
#include "base58.h"
#include "masternode.h"
#include "masternode-pos.h"
//#include "timedata.h"
using namespace std;
@ -80,7 +79,7 @@ public:
// keep track of the scanning errors I've seen
map<uint256, CBudgetProposal> mapProposals;
map<uint256, CFinalizedBudget> mapFinalizedBudgets;
CBudgetManager() {
mapProposals.clear();
mapFinalizedBudgets.clear();
@ -96,7 +95,7 @@ public:
CFinalizedBudget *FindFinalizedBudget(uint256 nHash);
std::pair<std::string, std::string> GetVotes(std::string strProposalName);
void CleanUp();
int64_t GetTotalBudget(int nHeight);
@ -179,7 +178,7 @@ public:
std::vector<CTxBudgetPayment> vecProposals;
map<uint256, CFinalizedBudgetVote> mapVotes;
CFinalizedBudget();
CFinalizedBudget();
CFinalizedBudget(const CFinalizedBudget& other);
void Sync(CNode* node);
@ -227,19 +226,19 @@ public:
string GetStatus();
uint256 GetHash(){
/*
/*
vin is not included on purpose
- Any masternode can make a proposal and the hashes should match regardless of who made it.
- Someone could hyjack a new proposal by changing the vin and the signature check will fail.
However, the network will still propagate the correct version and the incorrect one will be rejected.
- Any masternode can make a proposal and the hashes should match regardless of who made it.
- Someone could hyjack a new proposal by changing the vin and the signature check will fail.
However, the network will still propagate the correct version and the incorrect one will be rejected.
*/
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << strBudgetName;
ss << nBlockStart;
ss << vecProposals;
uint256 h1 = ss.GetHash();
uint256 h1 = ss.GetHash();
return h1;
}
@ -262,7 +261,7 @@ class CFinalizedBudgetBroadcast : public CFinalizedBudget
{
private:
std::vector<unsigned char> vchSig;
public:
CFinalizedBudgetBroadcast();
CFinalizedBudgetBroadcast(const CFinalizedBudget& other);
@ -283,7 +282,7 @@ public:
READWRITE(nBlockStart);
READWRITE(vecProposals);
READWRITE(vchSig);
}
}
};
//
@ -323,7 +322,7 @@ public:
READWRITE(vchSig);
}
};
@ -340,12 +339,12 @@ private:
public:
std::string strProposalName;
/*
/*
json object with name, short-description, long-description, pdf-url and any other info
This allows the proposal website to stay 100% decentralized
*/
std::string strURL;
std::string strURL;
CTxIn vin;
int nBlockStart;
int nBlockEnd;
@ -356,7 +355,7 @@ public:
map<uint256, CBudgetVote> mapVotes;
//cache object
CBudgetProposal();
CBudgetProposal();
CBudgetProposal(const CBudgetProposal& other);
CBudgetProposal(CTxIn vinIn, std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn);
@ -389,13 +388,13 @@ public:
int64_t GetAllotted() {return nAlloted;}
uint256 GetHash(){
/*
/*
vin is not included on purpose
- Any masternode can make a proposal and the hashes should match regardless of who made it.
- Someone could hyjack a new proposal by changing the vin and the signature check will fail.
However, the network will still propagate the correct version and the incorrect one will be rejected.
- Any masternode can make a proposal and the hashes should match regardless of who made it.
- Someone could hyjack a new proposal by changing the vin and the signature check will fail.
However, the network will still propagate the correct version and the incorrect one will be rejected.
*/
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << strProposalName;
ss << strURL;
@ -404,7 +403,7 @@ public:
ss << nAmount;
ss << address;
uint256 h1 = ss.GetHash();
return h1;
}
@ -432,7 +431,7 @@ class CBudgetProposalBroadcast : public CBudgetProposal
{
private:
std::vector<unsigned char> vchSig;
public:
CBudgetProposalBroadcast();
CBudgetProposalBroadcast(const CBudgetProposal& other);
@ -456,7 +455,7 @@ public:
READWRITE(nAmount);
READWRITE(address);
READWRITE(vchSig);
}
}
};
//
@ -506,7 +505,7 @@ public:
READWRITE(vchSig);
}
};

View File

@ -1,253 +0,0 @@
#include "sync.h"
#include "net.h"
#include "key.h"
#include "util.h"
#include "base58.h"
#include "protocol.h"
#include "activemasternode.h"
#include "masternodeman.h"
#include "spork.h"
#include <boost/lexical_cast.hpp>
#include "masternodeman.h"
using namespace std;
using namespace boost;
std::map<uint256, CMasternodeScanningError> mapMasternodeScanningErrors;
CMasternodeScanning mnscan;
/*
Masternode - Proof of Service
-- What it checks
1.) Making sure Masternodes have their ports open
2.) Are responding to requests made by the network
-- How it works
When a block comes in, DoMasternodePOS is executed if the client is a
masternode. Using the deterministic ranking algorithm up to 1% of the masternode
network is checked each block.
A port is opened from Masternode A to Masternode B, if successful then nothing happens.
If there is an error, a CMasternodeScanningError object is propagated with an error code.
Errors are applied to the Masternodes and a score is incremented within the masternode object,
after a threshold is met, the masternode goes into an error state. Each cycle the score is
decreased, so if the masternode comes back online it will return to the list.
Masternodes in a error state do not receive payment.
-- Future expansion
We want to be able to prove the nodes have many qualities such as a specific CPU speed, bandwidth,
and dedicated storage. E.g. We could require a full node be a computer running 2GHz with 10GB of space.
*/
void ProcessMessageMasternodePOS(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if(fLiteMode) return; //disable all darksend/masternode related functionality
if(!IsSporkActive(SPORK_7_MASTERNODE_SCANNING)) return;
if(IsInitialBlockDownload()) return;
if (strCommand == "mnse") //Masternode Scanning Error
{
CDataStream vMsg(vRecv);
CMasternodeScanningError mnse;
vRecv >> mnse;
CInv inv(MSG_MASTERNODE_SCANNING_ERROR, mnse.GetHash());
pfrom->AddInventoryKnown(inv);
if(mapMasternodeScanningErrors.count(mnse.GetHash())){
return;
}
mapMasternodeScanningErrors.insert(make_pair(mnse.GetHash(), mnse));
if(!mnse.IsValid())
{
LogPrintf("MasternodePOS::mnse - Invalid object\n");
return;
}
CMasternode* pmnA = mnodeman.Find(mnse.vinMasternodeA);
if(pmnA == NULL) return;
if(pmnA->protocolVersion < MIN_MASTERNODE_POS_PROTO_VERSION) return;
int nBlockHeight = chainActive.Tip()->nHeight;
if(nBlockHeight - mnse.nBlockHeight > 10){
LogPrintf("MasternodePOS::mnse - Too old\n");
return;
}
// Lowest masternodes in rank check the highest each block
int a = mnodeman.GetMasternodeRank(mnse.vinMasternodeA, mnse.nBlockHeight, MIN_MASTERNODE_POS_PROTO_VERSION);
if(a == -1 || a > GetCountScanningPerBlock())
{
if(a != -1) LogPrintf("MasternodePOS::mnse - MasternodeA ranking is too high\n");
return;
}
int b = mnodeman.GetMasternodeRank(mnse.vinMasternodeB, mnse.nBlockHeight, MIN_MASTERNODE_POS_PROTO_VERSION, false);
if(b == -1 || b < mnodeman.CountMasternodesAboveProtocol(MIN_MASTERNODE_POS_PROTO_VERSION)-GetCountScanningPerBlock())
{
if(b != -1) LogPrintf("MasternodePOS::mnse - MasternodeB ranking is too low\n");
return;
}
if(!mnse.SignatureValid()){
LogPrintf("MasternodePOS::mnse - Bad masternode message\n");
return;
}
CMasternode* pmnB = mnodeman.Find(mnse.vinMasternodeB);
if(pmnB == NULL) return;
if(fDebug) LogPrintf("ProcessMessageMasternodePOS::mnse - nHeight %d MasternodeA %s MasternodeB %s\n", mnse.nBlockHeight, pmnA->addr.ToString().c_str(), pmnB->addr.ToString().c_str());
pmnB->ApplyScanningError(mnse);
mnse.Relay();
}
}
// Returns how many masternodes are allowed to scan each block
int GetCountScanningPerBlock()
{
return std::max(1, mnodeman.CountMasternodesAboveProtocol(MIN_MASTERNODE_POS_PROTO_VERSION)/100);
}
void CMasternodeScanning::CleanMasternodeScanningErrors()
{
if(chainActive.Tip() == NULL) return;
std::map<uint256, CMasternodeScanningError>::iterator it = mapMasternodeScanningErrors.begin();
while(it != mapMasternodeScanningErrors.end()) {
if(GetTime() > it->second.nExpiration){ //keep them for an hour
LogPrintf("Removing old masternode scanning error %s\n", it->second.GetHash().ToString().c_str());
mapMasternodeScanningErrors.erase(it++);
} else {
it++;
}
}
}
// Check other masternodes to make sure they're running correctly
void CMasternodeScanning::DoMasternodePOSChecks()
{
if(!fMasterNode) return;
if(fLiteMode) return; //disable all darksend/masternode related functionality
if(!IsSporkActive(SPORK_7_MASTERNODE_SCANNING)) return;
if(IsInitialBlockDownload()) return;
int nBlockHeight = chainActive.Tip()->nHeight-5;
int a = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_MASTERNODE_POS_PROTO_VERSION);
if(a == -1 || a > GetCountScanningPerBlock()){
// we don't need to do anything this block
return;
}
// The lowest ranking nodes (Masternode A) check the highest ranking nodes (Masternode B)
CMasternode* pmn = mnodeman.GetMasternodeByRank(mnodeman.CountMasternodesAboveProtocol(MIN_MASTERNODE_POS_PROTO_VERSION)-a, nBlockHeight, MIN_MASTERNODE_POS_PROTO_VERSION, false);
if(pmn == NULL) return;
// -- first check : Port is open
if(!ConnectNode((CAddress)pmn->addr, NULL, true)){
// we couldn't connect to the node, let's send a scanning error
CMasternodeScanningError mnse(activeMasternode.vin, pmn->vin, SCANNING_ERROR_NO_RESPONSE, nBlockHeight);
mnse.Sign();
mapMasternodeScanningErrors.insert(make_pair(mnse.GetHash(), mnse));
mnse.Relay();
}
// success
CMasternodeScanningError mnse(activeMasternode.vin, pmn->vin, SCANNING_SUCCESS, nBlockHeight);
mnse.Sign();
mapMasternodeScanningErrors.insert(make_pair(mnse.GetHash(), mnse));
mnse.Relay();
}
bool CMasternodeScanningError::SignatureValid()
{
std::string errorMessage;
std::string strMessage = vinMasternodeA.ToString() + vinMasternodeB.ToString() +
boost::lexical_cast<std::string>(nBlockHeight) + boost::lexical_cast<std::string>(nErrorType);
CMasternode* pmn = mnodeman.Find(vinMasternodeA);
if(pmn == NULL)
{
LogPrintf("CMasternodeScanningError::SignatureValid() - Unknown Masternode\n");
return false;
}
CScript pubkey;
pubkey = GetScriptForDestination(pmn->pubkey2.GetID());
CTxDestination address1;
ExtractDestination(pubkey, address1);
CBitcoinAddress address2(address1);
if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) {
LogPrintf("CMasternodeScanningError::SignatureValid() - Verify message failed\n");
return false;
}
return true;
}
bool CMasternodeScanningError::Sign()
{
std::string errorMessage;
CKey key2;
CPubKey pubkey2;
std::string strMessage = vinMasternodeA.ToString() + vinMasternodeB.ToString() +
boost::lexical_cast<std::string>(nBlockHeight) + boost::lexical_cast<std::string>(nErrorType);
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2))
{
LogPrintf("CMasternodeScanningError::Sign() - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
return false;
}
CScript pubkey;
pubkey = GetScriptForDestination(pubkey2.GetID());
CTxDestination address1;
ExtractDestination(pubkey, address1);
CBitcoinAddress address2(address1);
//LogPrintf("signing pubkey2 %s \n", address2.ToString().c_str());
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchMasterNodeSignature, key2)) {
LogPrintf("CMasternodeScanningError::Sign() - Sign message failed");
return false;
}
if(!darkSendSigner.VerifyMessage(pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) {
LogPrintf("CMasternodeScanningError::Sign() - Verify message failed");
return false;
}
return true;
}
void CMasternodeScanningError::Relay()
{
CInv inv(MSG_MASTERNODE_SCANNING_ERROR, GetHash());
vector<CInv> vInv;
vInv.push_back(inv);
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes){
pnode->PushMessage("inv", vInv);
}
}

View File

@ -1,115 +0,0 @@
// Copyright (c) 2014-2015 The Dash developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef MASTERNODE_POS_H
#define MASTERNODE_POS_H
#include "sync.h"
#include "net.h"
#include "key.h"
#include "util.h"
#include "base58.h"
#include "main.h"
using namespace std;
using namespace boost;
class CMasternodeScanning;
class CMasternodeScanningError;
extern map<uint256, CMasternodeScanningError> mapMasternodeScanningErrors;
extern CMasternodeScanning mnscan;
static const int MIN_MASTERNODE_POS_PROTO_VERSION = 70080;
/*
1% of the network is scanned every 2.5 minutes, making a full
round of scanning take about 4.16 hours. We're targeting about
a day of proof-of-service errors for complete removal from the
masternode system.
*/
static const int MASTERNODE_SCANNING_ERROR_THESHOLD = 6;
#define SCANNING_SUCCESS 1
#define SCANNING_ERROR_NO_RESPONSE 2
#define SCANNING_ERROR_IX_NO_RESPONSE 3
#define SCANNING_ERROR_MAX 3
void ProcessMessageMasternodePOS(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
class CMasternodeScanning
{
public:
void DoMasternodePOSChecks();
void CleanMasternodeScanningErrors();
};
// Returns how many masternodes are allowed to scan each block
int GetCountScanningPerBlock();
class CMasternodeScanningError
{
public:
CTxIn vinMasternodeA;
CTxIn vinMasternodeB;
int nErrorType;
int nExpiration;
int nBlockHeight;
std::vector<unsigned char> vchMasterNodeSignature;
CMasternodeScanningError ()
{
vinMasternodeA = CTxIn();
vinMasternodeB = CTxIn();
nErrorType = 0;
nExpiration = GetTime()+(60*60);
nBlockHeight = 0;
}
CMasternodeScanningError (CTxIn& vinMasternodeAIn, CTxIn& vinMasternodeBIn, int nErrorTypeIn, int nBlockHeightIn)
{
vinMasternodeA = vinMasternodeAIn;
vinMasternodeB = vinMasternodeBIn;
nErrorType = nErrorTypeIn;
nExpiration = GetTime()+(60*60);
nBlockHeight = nBlockHeightIn;
}
CMasternodeScanningError (CTxIn& vinMasternodeBIn, int nErrorTypeIn, int nBlockHeightIn)
{
//just used for IX, MasternodeA is any client
vinMasternodeA = CTxIn();
vinMasternodeB = vinMasternodeBIn;
nErrorType = nErrorTypeIn;
nExpiration = GetTime()+(60*60);
nBlockHeight = nBlockHeightIn;
}
uint256 GetHash() const {return SerializeHash(*this);}
bool SignatureValid();
bool Sign();
bool IsExpired() {return GetTime() > nExpiration;}
void Relay();
bool IsValid() {
return (nErrorType > 0 && nErrorType <= SCANNING_ERROR_MAX);
}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vinMasternodeA);
READWRITE(vinMasternodeB);
READWRITE(nErrorType);
READWRITE(nExpiration);
READWRITE(nBlockHeight);
READWRITE(vchMasterNodeSignature);
}
};
#endif

View File

@ -195,12 +195,6 @@ void CMasternode::Check()
TRY_LOCK(cs_main, lockRecv);
if(!lockRecv) return;
if(nScanningErrorCount >= MASTERNODE_SCANNING_ERROR_THESHOLD)
{
activeState = MASTERNODE_POS_ERROR;
return;
}
//once spent, stop doing the checks
if(activeState == MASTERNODE_VIN_SPENT) return;
@ -384,9 +378,9 @@ bool CMasternodeBroadcast::CheckAndUpdate(int& nDos, bool fRequested)
if(pmn->sigTime < sigTime){ //take the newest entry
LogPrintf("mnb - Got updated entry for %s\n", addr.ToString().c_str());
pmn->UpdateFromNewBroadcast((*this));
pmn->Check();
if(pmn->IsEnabled()) {
Relay(fRequested);
@ -468,7 +462,7 @@ void CMasternodeBroadcast::Relay(bool fRequested)
}
bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
{
{
std::string errorMessage;
std::string vchPubKey(pubkey.begin(), pubkey.end());

View File

@ -12,7 +12,6 @@
#include "base58.h"
#include "main.h"
#include "masternode.h"
#include "masternode-pos.h"
#include "timedata.h"
#define MASTERNODE_NOT_PROCESSED 0 // initial state
@ -205,22 +204,6 @@ public:
return cacheInputAge+(chainActive.Tip()->nHeight-cacheInputAgeBlock);
}
void ApplyScanningError(CMasternodeScanningError& mnse)
{
if(!mnse.IsValid()) return;
if(mnse.nBlockHeight == nLastScanningErrorBlockHeight) return;
nLastScanningErrorBlockHeight = mnse.nBlockHeight;
if(mnse.nErrorType == SCANNING_SUCCESS){
nScanningErrorCount--;
if(nScanningErrorCount < 0) nScanningErrorCount = 0;
} else { //all other codes are equally as bad
nScanningErrorCount++;
if(nScanningErrorCount > MASTERNODE_SCANNING_ERROR_THESHOLD*2) nScanningErrorCount = MASTERNODE_SCANNING_ERROR_THESHOLD*2;
}
}
std::string Status() {
std::string strStatus = "ACTIVE";
@ -267,7 +250,7 @@ public:
READWRITE(lastTimeSeen);
READWRITE(protocolVersion);
}
uint256 GetHash(){
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << sigTime;
@ -307,7 +290,7 @@ public:
bool CheckAndUpdate(int& nDos);
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
void Relay();
void Relay();
uint256 GetHash(){
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);

View File

@ -129,7 +129,7 @@ Value masternode(const Array& params, bool fHelp)
if (fHelp ||
(strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "stop" && strCommand != "stop-alias" &&
strCommand != "stop-many" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && strCommand != "enforce" &&
strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" &&
strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" &&
strCommand != "outputs"))
throw runtime_error(
"masternode \"command\"... ( \"passphrase\" )\n"
@ -466,7 +466,7 @@ Value masternodelist(const Array& params, bool fHelp)
if (fHelp ||
(strMode != "status" && strMode != "vin" && strMode != "pubkey" && strMode != "lastseen" && strMode != "activeseconds" && strMode != "rank" && strMode != "addr"
&& strMode != "protocol" && strMode != "full" && strMode != "votes" && strMode != "pose" && strMode != "lastpaid"))
&& strMode != "protocol" && strMode != "full" && strMode != "votes" && strMode != "lastpaid"))
{
throw runtime_error(
"masternodelist ( \"mode\" \"filter\" )\n"
@ -480,7 +480,6 @@ Value masternodelist(const Array& params, bool fHelp)
" full - Print info in format 'status protocol pubkey vin lastseen activeseconds'\n"
" (can be additionally filtered, partial match)\n"
" lastseen - Print timestamp of when a masternode was last seen on the network\n"
" pose - Print Proof-of-Service score\n"
" protocol - Print protocol of a masternode (can be additionally filtered, exact match))\n"
" pubkey - Print public key associated with a masternode (can be additionally filtered,\n"
" partial match)\n"
@ -548,10 +547,6 @@ Value masternodelist(const Array& params, bool fHelp)
if(strFilter !="" && address2.ToString().find(strFilter) == string::npos &&
strVin.find(strFilter) == string::npos) continue;
obj.push_back(Pair(strVin, address2.ToString().c_str()));
} else if (strMode == "pose") {
if(strFilter !="" && strVin.find(strFilter) == string::npos) continue;
std::string strOut = boost::lexical_cast<std::string>(mn.nScanningErrorCount);
obj.push_back(Pair(strVin, strOut.c_str()));
} else if(strMode == "status") {
std::string strStatus = mn.Status();
if(strFilter !="" && strVin.find(strFilter) == string::npos && strStatus.find(strFilter) == string::npos) continue;