mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
add recent (tip - 12) block hash to mnping
This commit is contained in:
parent
aa91dde992
commit
19d9a65f8a
@ -503,11 +503,13 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
|
||||
CMasternodePing::CMasternodePing()
|
||||
{
|
||||
vin = CTxIn();
|
||||
blockHash = chainActive[chainActive.Height() - 12]->GetBlockHash();
|
||||
}
|
||||
|
||||
CMasternodePing::CMasternodePing(CTxIn& newVin)
|
||||
{
|
||||
vin = newVin;
|
||||
blockHash = chainActive[chainActive.Height() - 12]->GetBlockHash();
|
||||
}
|
||||
|
||||
|
||||
@ -517,7 +519,7 @@ bool CMasternodePing::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
|
||||
std::string strMasterNodeSignMessage;
|
||||
|
||||
sigTime = GetAdjustedTime();
|
||||
std::string strMessage = boost::lexical_cast<std::string>(sigTime);
|
||||
std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast<std::string>(sigTime);
|
||||
|
||||
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) {
|
||||
LogPrintf("CMasternodePing::Sign() - Error: %s\n", errorMessage.c_str());
|
||||
@ -549,30 +551,43 @@ bool CMasternodePing::CheckAndUpdate(int& nDos)
|
||||
if(pmn != NULL && pmn->protocolVersion >= nMasternodeMinProtocol)
|
||||
{
|
||||
// LogPrintf("mnping - Found corresponding mn for vin: %s\n", vin.ToString().c_str());
|
||||
// take this only if it's newer
|
||||
if(pmn->lastMnping < sigTime)
|
||||
// take this only if it's newer and was last updated more then MASTERNODE_MIN_MNP_SECONDS ago
|
||||
if(pmn->lastMnping < sigTime && !pmn->UpdatedWithin(MASTERNODE_MIN_MNP_SECONDS))
|
||||
{
|
||||
std::string strMessage = boost::lexical_cast<std::string>(sigTime);
|
||||
std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast<std::string>(sigTime);
|
||||
|
||||
std::string errorMessage = "";
|
||||
if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage))
|
||||
{
|
||||
LogPrintf("mnping - Got bad Masternode address signature %s \n", vin.ToString().c_str());
|
||||
LogPrintf("mnping - Got bad Masternode address signature %s\n", vin.ToString());
|
||||
nDos = 33;
|
||||
return false;
|
||||
}
|
||||
|
||||
pmn->lastMnping = sigTime;
|
||||
|
||||
if(!pmn->UpdatedWithin(MASTERNODE_MIN_MNP_SECONDS))
|
||||
BlockMap::iterator mi = mapBlockIndex.find(blockHash);
|
||||
if (mi != mapBlockIndex.end() && (*mi).second)
|
||||
{
|
||||
pmn->UpdateLastSeen();
|
||||
pmn->Check();
|
||||
if(!pmn->IsEnabled()) return false;
|
||||
|
||||
Relay();
|
||||
return true;
|
||||
if((*mi).second->nHeight < chainActive.Height() - 24)
|
||||
{
|
||||
LogPrintf("mnping - Masternode %s block hash %s is too old\n", vin.ToString(), blockHash.ToString());
|
||||
nDos = 33;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (fDebug) LogPrintf("mnping - Masternode %s block hash %s is unknown\n", vin.ToString(), blockHash.ToString());
|
||||
// maybe we stuck so we shouldn't ban this node, just fail to accept it
|
||||
// TODO: or should we also request this block?
|
||||
return false;
|
||||
}
|
||||
|
||||
pmn->UpdateLastSeen();
|
||||
pmn->Check();
|
||||
if(!pmn->IsEnabled()) return false;
|
||||
|
||||
Relay();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -589,4 +604,4 @@ void CMasternodePing::Relay()
|
||||
BOOST_FOREACH(CNode* pnode, vNodes){
|
||||
pnode->PushMessage("inv", vInv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -309,6 +309,7 @@ class CMasternodePing
|
||||
public:
|
||||
|
||||
CTxIn vin;
|
||||
uint256 blockHash;
|
||||
std::vector<unsigned char> vchSig;
|
||||
int64_t sigTime; //dsee message times
|
||||
//removed stop
|
||||
@ -321,6 +322,7 @@ public:
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
READWRITE(vin);
|
||||
READWRITE(blockHash);
|
||||
READWRITE(sigTime);
|
||||
READWRITE(vchSig);
|
||||
}
|
||||
@ -333,4 +335,4 @@ public:
|
||||
return Hash(BEGIN(vin), END(vin), BEGIN(sigTime), END(sigTime));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user