Skip to content

Commit

Permalink
Refactor: always check mnp blockhash in CMasternodePing::CheckAndUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Dec 13, 2020
1 parent c04a4c5 commit c292b9a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireAvailable, bool fCh
return false;
}

// Check if the ping block hash exists and it's within 24 blocks from the tip
if (!mnodeman.IsWithinDepth(blockHash, 2 * MNPING_DEPTH)) {
LogPrint(BCLog::MNPING,"%s: Masternode %s block hash %s is too old or has an invalid block hash\n",
__func__, vin.prevout.hash.ToString(), blockHash.ToString());
nDos = 33;
return false;
}

// see if we have this Masternode
CMasternode* pmn = mnodeman.Find(vin.prevout);
const bool isMasternodeFound = (pmn != nullptr);
Expand Down Expand Up @@ -633,14 +641,6 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireAvailable, bool fCh
return false;
}

// Check if the ping block hash exists and it's within 24 blocks from the tip
if (!mnodeman.IsWithinDepth(blockHash, 2 * MNPING_DEPTH)) {
LogPrint(BCLog::MNPING,"%s: Masternode %s block hash %s is too old or has an invalid block hash\n",
__func__, vin.prevout.hash.ToString(), blockHash.ToString());
nDos = 33;
return false;
}

// ping have passed the basic checks, can be updated now
mnodeman.mapSeenMasternodePing.emplace(GetHash(), *this);

Expand Down

0 comments on commit c292b9a

Please sign in to comment.