mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
fixed ranking issues for PoSe
This commit is contained in:
parent
0e35ed5cb6
commit
4152eea1c1
@ -197,7 +197,7 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand
|
||||
For added DDOS protection, clients can only relay through 20 nodes per block.
|
||||
*/
|
||||
int rank = mnodeman.GetMasternodeRank(activeMasternode.vin, dsr.nBlockHeight, MIN_POOL_PEER_PROTO_VERSION);
|
||||
if(rank > 20){
|
||||
if(rank == -1 || rank > 20){
|
||||
LogPrintf("dsr -- invalid relay Masternode! %s \n", activeMasternode.vin.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
@ -78,16 +78,22 @@ void ProcessMessageMasternodePOS(CNode* pfrom, std::string& strCommand, CDataStr
|
||||
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 > GetCountScanningPerBlock())
|
||||
if(a == -1 || a > GetCountScanningPerBlock())
|
||||
{
|
||||
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 < mnodeman.CountMasternodesAboveProtocol(MIN_MASTERNODE_POS_PROTO_VERSION)-GetCountScanningPerBlock())
|
||||
if(b == -1 || b < mnodeman.CountMasternodesAboveProtocol(MIN_MASTERNODE_POS_PROTO_VERSION)-GetCountScanningPerBlock())
|
||||
{
|
||||
LogPrintf("MasternodePOS::mnse - MasternodeB ranking is too low\n");
|
||||
return;
|
||||
@ -139,28 +145,30 @@ void CMasternodeScanning::DoMasternodePOSChecks()
|
||||
if(!IsSporkActive(SPORK_7_MASTERNODE_SCANNING)) return;
|
||||
if(IsInitialBlockDownload()) return;
|
||||
|
||||
int a = mnodeman.GetMasternodeRank(activeMasternode.vin, chainActive.Tip()->nHeight, MIN_MASTERNODE_POS_PROTO_VERSION);
|
||||
if(a > GetCountScanningPerBlock()){
|
||||
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, chainActive.Tip()->nHeight, MIN_MASTERNODE_POS_PROTO_VERSION, false);
|
||||
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, chainActive.Tip()->nHeight);
|
||||
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, chainActive.Tip()->nHeight);
|
||||
CMasternodeScanningError mnse(activeMasternode.vin, pmn->vin, SCANNING_SUCCESS, nBlockHeight);
|
||||
mnse.Sign();
|
||||
mapMasternodeScanningErrors.insert(make_pair(mnse.GetHash(), mnse));
|
||||
mnse.Relay();
|
||||
|
@ -52,6 +52,7 @@ enum masternodeState {
|
||||
};
|
||||
|
||||
void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
|
||||
bool GetBlockHash(uint256& hash, int nBlockHeight);
|
||||
|
||||
//
|
||||
// The Masternode Class. For managing the Darksend process. It contains the input of the 1000DRK, signature to prove
|
||||
|
@ -3,6 +3,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "masternodeman.h"
|
||||
#include "masternode.h"
|
||||
#include "activemasternode.h"
|
||||
#include "darksend.h"
|
||||
#include "core.h"
|
||||
@ -383,6 +384,10 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in
|
||||
{
|
||||
std::vector<pair<unsigned int, CTxIn> > vecMasternodeScores;
|
||||
|
||||
//make sure we know about this block
|
||||
uint256 hash = 0;
|
||||
if(!GetBlockHash(hash, nBlockHeight)) return -1;
|
||||
|
||||
// scan for winner
|
||||
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
|
||||
|
||||
@ -418,6 +423,10 @@ std::vector<pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int64_t
|
||||
std::vector<pair<unsigned int, CMasternode> > vecMasternodeScores;
|
||||
std::vector<pair<int, CMasternode> > vecMasternodeRanks;
|
||||
|
||||
//make sure we know about this block
|
||||
uint256 hash = 0;
|
||||
if(!GetBlockHash(hash, nBlockHeight)) return vecMasternodeRanks;
|
||||
|
||||
// scan for winner
|
||||
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user