Skip to content

Commit ca478c5

Browse files
author
Sergey
committed
Update mn vote time for remote masternodes
- call UpdateWatchdogVoteTime in CMasternodeMan::ProcessMessage - deserialize masternodeping from the previous version archive without exception - add ability to set time in UpdateWatchdogVoteTime - set nTimeLastWatchdogVote to masternode ping sigTime if sentinel is actual - bump CMasternodeMan::SERIALIZATION_VERSION_STRING
1 parent 3bc38bd commit ca478c5

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/masternode.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,13 @@ void CMasternode::RemoveGovernanceObject(uint256 nGovernanceObjectHash)
911911
mapGovernanceObjectsVotedOn.erase(it);
912912
}
913913

914-
void CMasternode::UpdateWatchdogVoteTime()
914+
void CMasternode::UpdateWatchdogVoteTime(uint64_t t)
915915
{
916916
LOCK(cs);
917-
nTimeLastWatchdogVote = GetTime();
917+
if(t == 0)
918+
nTimeLastWatchdogVote = GetTime();
919+
else
920+
nTimeLastWatchdogVote = t;
918921
}
919922

920923
/**

src/masternode.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static const int MASTERNODE_WATCHDOG_MAX_SECONDS = 120 * 60;
2323
static const int MASTERNODE_NEW_START_REQUIRED_SECONDS = 180 * 60;
2424

2525
static const int MASTERNODE_POSE_BAN_MAX_SCORE = 5;
26+
2627
//
2728
// The Masternode Ping Class : Contains a different serialize method for sending pings from masternodes throughout the network
2829
//
@@ -57,6 +58,8 @@ class CMasternodePing
5758
READWRITE(blockHash);
5859
READWRITE(sigTime);
5960
READWRITE(vchSig);
61+
if(ser_action.ForRead() && (s.size() == 0))
62+
return;
6063
READWRITE(sentinelIsActual);
6164
READWRITE(sentinelVersion);
6265
}
@@ -326,7 +329,7 @@ class CMasternode
326329

327330
void RemoveGovernanceObject(uint256 nGovernanceObjectHash);
328331

329-
void UpdateWatchdogVoteTime();
332+
void UpdateWatchdogVoteTime(uint64_t t = 0);
330333

331334
CMasternode& operator=(CMasternode from)
332335
{

src/masternodeman.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/** Masternode manager */
1717
CMasternodeMan mnodeman;
1818

19-
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-4";
19+
const std::string CMasternodeMan::SERIALIZATION_VERSION_STRING = "CMasternodeMan-Version-5";
2020

2121
struct CompareLastPaidBlock
2222
{
@@ -849,6 +849,12 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
849849
// see if we have this Masternode
850850
CMasternode* pmn = mnodeman.Find(mnp.vin);
851851

852+
// if masternode uses sentinel ping instead of watchdog
853+
// we shoud update nTimeLastWatchdogVote here if sentinel
854+
// ping flag is actual
855+
if(pmn && mnp.sentinelIsActual)
856+
pmn->UpdateWatchdogVoteTime(mnp.sigTime);
857+
852858
// too late, new MNANNOUNCE is required
853859
if(pmn && pmn->IsNewStartRequired()) return;
854860

@@ -1649,7 +1655,7 @@ void CMasternodeMan::SetMasternodeLastPing(const CTxIn& vin, const CMasternodePi
16491655
// we shoud update nTimeLastWatchdogVote here if sentinel
16501656
// ping flag is actual
16511657
if(mnp.sentinelIsActual)
1652-
pMN->UpdateWatchdogVoteTime();
1658+
pMN->UpdateWatchdogVoteTime(mnp.sigTime);
16531659
mapSeenMasternodePing.insert(std::make_pair(mnp.GetHash(), mnp));
16541660

16551661
CMasternodeBroadcast mnb(*pMN);

0 commit comments

Comments
 (0)