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:
parent
4afaa1d8cf
commit
f1b868f098
@ -89,7 +89,6 @@ HEADERS += src/activemasternode.h \
|
|||||||
src/limitedmap.h \
|
src/limitedmap.h \
|
||||||
src/main.h \
|
src/main.h \
|
||||||
src/masternode-payments.h \
|
src/masternode-payments.h \
|
||||||
src/masternode-pos.h \
|
|
||||||
src/masternode.h \
|
src/masternode.h \
|
||||||
src/masternodeconfig.h \
|
src/masternodeconfig.h \
|
||||||
src/masternodeman.h \
|
src/masternodeman.h \
|
||||||
@ -385,7 +384,6 @@ SOURCES += src/activemasternode.cpp \
|
|||||||
src/leveldbwrapper.cpp \
|
src/leveldbwrapper.cpp \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/masternode-payments.cpp \
|
src/masternode-payments.cpp \
|
||||||
src/masternode-pos.cpp \
|
|
||||||
src/masternode.cpp \
|
src/masternode.cpp \
|
||||||
src/masternodeconfig.cpp \
|
src/masternodeconfig.cpp \
|
||||||
src/masternodeman.cpp \
|
src/masternodeman.cpp \
|
||||||
|
@ -109,7 +109,6 @@ BITCOIN_CORE_H = \
|
|||||||
main.h \
|
main.h \
|
||||||
masternode.h \
|
masternode.h \
|
||||||
masternode-payments.h \
|
masternode-payments.h \
|
||||||
masternode-pos.h \
|
|
||||||
masternode-budget.h \
|
masternode-budget.h \
|
||||||
masternodeman.h \
|
masternodeman.h \
|
||||||
masternodeconfig.h \
|
masternodeconfig.h \
|
||||||
@ -286,7 +285,6 @@ libbitcoin_common_a_SOURCES = \
|
|||||||
masternode.cpp \
|
masternode.cpp \
|
||||||
masternode-budget.cpp \
|
masternode-budget.cpp \
|
||||||
masternode-payments.cpp \
|
masternode-payments.cpp \
|
||||||
masternode-pos.cpp \
|
|
||||||
masternodeman.cpp \
|
masternodeman.cpp \
|
||||||
masternodeconfig.cpp \
|
masternodeconfig.cpp \
|
||||||
instantx.cpp \
|
instantx.cpp \
|
||||||
|
@ -187,7 +187,6 @@ void CCoinbasePayee::BuildIndex()
|
|||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (ReadBlockFromDisk(block, pindexPrev)) {
|
if (ReadBlockFromDisk(block, pindexPrev)) {
|
||||||
printf("scan block\n");
|
|
||||||
ProcessBlockCoinbaseTX(block.vtx[0], block.nTime);
|
ProcessBlockCoinbaseTX(block.vtx[0], block.nTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,12 +463,6 @@ void CleanTransactionLocksList()
|
|||||||
fFound = true;
|
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)){
|
if(mapTxLockReq.count(it->second.txHash)){
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -3242,7 +3242,6 @@ bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDis
|
|||||||
coinbasePayee.ProcessBlockCoinbaseTX(pblock->vtx[0], pblock->nTime);
|
coinbasePayee.ProcessBlockCoinbaseTX(pblock->vtx[0], pblock->nTime);
|
||||||
darkSendPool.NewBlock();
|
darkSendPool.NewBlock();
|
||||||
masternodePayments.ProcessBlock(GetHeight()+10);
|
masternodePayments.ProcessBlock(GetHeight()+10);
|
||||||
mnscan.DoMasternodePOSChecks();
|
|
||||||
budget.NewBlock();
|
budget.NewBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3943,8 +3942,6 @@ bool static AlreadyHave(const CInv& inv)
|
|||||||
return mapSporks.count(inv.hash);
|
return mapSporks.count(inv.hash);
|
||||||
case MSG_MASTERNODE_WINNER:
|
case MSG_MASTERNODE_WINNER:
|
||||||
return mapMasternodePayeeVotes.count(inv.hash);
|
return mapMasternodePayeeVotes.count(inv.hash);
|
||||||
case MSG_MASTERNODE_SCANNING_ERROR:
|
|
||||||
return mapMasternodeScanningErrors.count(inv.hash);
|
|
||||||
case MSG_BUDGET_VOTE:
|
case MSG_BUDGET_VOTE:
|
||||||
return mapSeenMasternodeBudgetVotes.count(inv.hash);
|
return mapSeenMasternodeBudgetVotes.count(inv.hash);
|
||||||
case MSG_BUDGET_PROPOSAL:
|
case MSG_BUDGET_PROPOSAL:
|
||||||
@ -4116,16 +4113,6 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
pushed = true;
|
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 (!pushed && inv.type == MSG_BUDGET_VOTE) {
|
||||||
if(mapSeenMasternodeBudgetVotes.count(inv.hash)){
|
if(mapSeenMasternodeBudgetVotes.count(inv.hash)){
|
||||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
@ -5057,7 +5044,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
masternodePayments.ProcessMessageMasternodePayments(pfrom, strCommand, vRecv);
|
masternodePayments.ProcessMessageMasternodePayments(pfrom, strCommand, vRecv);
|
||||||
ProcessMessageInstantX(pfrom, strCommand, vRecv);
|
ProcessMessageInstantX(pfrom, strCommand, vRecv);
|
||||||
ProcessSpork(pfrom, strCommand, vRecv);
|
ProcessSpork(pfrom, strCommand, vRecv);
|
||||||
ProcessMessageMasternodePOS(pfrom, strCommand, vRecv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
#include "masternode.h"
|
#include "masternode.h"
|
||||||
#include "masternode-pos.h"
|
|
||||||
//#include "timedata.h"
|
//#include "timedata.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
@ -195,12 +195,6 @@ void CMasternode::Check()
|
|||||||
TRY_LOCK(cs_main, lockRecv);
|
TRY_LOCK(cs_main, lockRecv);
|
||||||
if(!lockRecv) return;
|
if(!lockRecv) return;
|
||||||
|
|
||||||
if(nScanningErrorCount >= MASTERNODE_SCANNING_ERROR_THESHOLD)
|
|
||||||
{
|
|
||||||
activeState = MASTERNODE_POS_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//once spent, stop doing the checks
|
//once spent, stop doing the checks
|
||||||
if(activeState == MASTERNODE_VIN_SPENT) return;
|
if(activeState == MASTERNODE_VIN_SPENT) return;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "masternode.h"
|
#include "masternode.h"
|
||||||
#include "masternode-pos.h"
|
|
||||||
#include "timedata.h"
|
#include "timedata.h"
|
||||||
|
|
||||||
#define MASTERNODE_NOT_PROCESSED 0 // initial state
|
#define MASTERNODE_NOT_PROCESSED 0 // initial state
|
||||||
@ -205,22 +204,6 @@ public:
|
|||||||
return cacheInputAge+(chainActive.Tip()->nHeight-cacheInputAgeBlock);
|
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 Status() {
|
||||||
std::string strStatus = "ACTIVE";
|
std::string strStatus = "ACTIVE";
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ Value masternodelist(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
if (fHelp ||
|
if (fHelp ||
|
||||||
(strMode != "status" && strMode != "vin" && strMode != "pubkey" && strMode != "lastseen" && strMode != "activeseconds" && strMode != "rank" && strMode != "addr"
|
(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(
|
throw runtime_error(
|
||||||
"masternodelist ( \"mode\" \"filter\" )\n"
|
"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"
|
" full - Print info in format 'status protocol pubkey vin lastseen activeseconds'\n"
|
||||||
" (can be additionally filtered, partial match)\n"
|
" (can be additionally filtered, partial match)\n"
|
||||||
" lastseen - Print timestamp of when a masternode was last seen on the network\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"
|
" 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"
|
" pubkey - Print public key associated with a masternode (can be additionally filtered,\n"
|
||||||
" partial match)\n"
|
" partial match)\n"
|
||||||
@ -548,10 +547,6 @@ Value masternodelist(const Array& params, bool fHelp)
|
|||||||
if(strFilter !="" && address2.ToString().find(strFilter) == string::npos &&
|
if(strFilter !="" && address2.ToString().find(strFilter) == string::npos &&
|
||||||
strVin.find(strFilter) == string::npos) continue;
|
strVin.find(strFilter) == string::npos) continue;
|
||||||
obj.push_back(Pair(strVin, address2.ToString().c_str()));
|
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") {
|
} else if(strMode == "status") {
|
||||||
std::string strStatus = mn.Status();
|
std::string strStatus = mn.Status();
|
||||||
if(strFilter !="" && strVin.find(strFilter) == string::npos && strStatus.find(strFilter) == string::npos) continue;
|
if(strFilter !="" && strVin.find(strFilter) == string::npos && strStatus.find(strFilter) == string::npos) continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user