Skip to content

Commit 5d58dd9

Browse files
authored
Make sure to clear setAskFor in Dash submodules (#1730)
* Make sure to clear setAskFor in Dash submodules Thanks @sidhujag for finding the bug * partially revert previous commit * skip mnv until mn list is synced
1 parent 3e86c41 commit 5d58dd9

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

src/governance.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,20 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
148148
{
149149
// MAKE SURE WE HAVE A VALID REFERENCE TO THE TIP BEFORE CONTINUING
150150

151+
CGovernanceObject govobj;
152+
vRecv >> govobj;
153+
154+
uint256 nHash = govobj.GetHash();
155+
156+
pfrom->setAskFor.erase(nHash);
151157

152158
if(!masternodeSync.IsMasternodeListSynced()) {
153159
LogPrint("gobject", "MNGOVERNANCEOBJECT -- masternode list not synced\n");
154160
return;
155161
}
156162

157-
CGovernanceObject govobj;
158-
vRecv >> govobj;
159-
160-
uint256 nHash = govobj.GetHash();
161163
std::string strHash = nHash.ToString();
162164

163-
pfrom->setAskFor.erase(nHash);
164-
165165
LogPrint("gobject", "MNGOVERNANCEOBJECT -- Received object: %s\n", strHash);
166166

167167
if(!AcceptObjectMessage(nHash)) {
@@ -232,22 +232,23 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
232232
// A NEW GOVERNANCE OBJECT VOTE HAS ARRIVED
233233
else if (strCommand == NetMsgType::MNGOVERNANCEOBJECTVOTE)
234234
{
235+
CGovernanceVote vote;
236+
vRecv >> vote;
237+
238+
uint256 nHash = vote.GetHash();
239+
240+
pfrom->setAskFor.erase(nHash);
241+
235242
// Ignore such messages until masternode list is synced
236243
if(!masternodeSync.IsMasternodeListSynced()) {
237244
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- masternode list not synced\n");
238245
return;
239246
}
240247

241-
CGovernanceVote vote;
242-
vRecv >> vote;
243-
244248
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- Received vote: %s\n", vote.ToString());
245249

246-
uint256 nHash = vote.GetHash();
247250
std::string strHash = nHash.ToString();
248251

249-
pfrom->setAskFor.erase(nHash);
250-
251252
if(!AcceptVoteMessage(nHash)) {
252253
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- Received unrequested vote object: %s, hash: %s, peer = %d\n",
253254
vote.ToString(), strHash, pfrom->GetId());

src/instantx.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ void CInstantSend::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataSt
4545
if(fLiteMode) return; // disable all Dash specific functionality
4646
if(!sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED)) return;
4747

48-
// Ignore any InstantSend messages until masternode list is synced
49-
if(!masternodeSync.IsMasternodeListSynced()) return;
50-
5148
// NOTE: NetMsgType::TXLOCKREQUEST is handled via ProcessMessage() in main.cpp
5249

5350
if (strCommand == NetMsgType::TXLOCKVOTE) // InstantSend Transaction Lock Consensus Votes
@@ -57,17 +54,21 @@ void CInstantSend::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataSt
5754
CTxLockVote vote;
5855
vRecv >> vote;
5956

57+
58+
uint256 nVoteHash = vote.GetHash();
59+
60+
pfrom->setAskFor.erase(nVoteHash);
61+
62+
// Ignore any InstantSend messages until masternode list is synced
63+
if(!masternodeSync.IsMasternodeListSynced()) return;
64+
6065
LOCK(cs_main);
6166
#ifdef ENABLE_WALLET
6267
if (pwalletMain)
6368
LOCK(pwalletMain->cs_wallet);
6469
#endif
6570
LOCK(cs_instantsend);
6671

67-
uint256 nVoteHash = vote.GetHash();
68-
69-
pfrom->setAskFor.erase(nVoteHash);
70-
7172
if(mapTxLockVotes.count(nVoteHash)) return;
7273
mapTxLockVotes.insert(std::make_pair(nVoteHash, vote));
7374

src/masternode-payments.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ int CMasternodePayments::GetMinMasternodePaymentsProto() {
305305

306306
void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman)
307307
{
308-
// Ignore any payments messages until masternode list is synced
309-
if(!masternodeSync.IsMasternodeListSynced()) return;
310-
311308
if(fLiteMode) return; // disable all Dash specific functionality
312309

313310
if (strCommand == NetMsgType::MASTERNODEPAYMENTSYNC) { //Masternode Payments Request Sync
@@ -342,6 +339,11 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
342339

343340
pfrom->setAskFor.erase(nHash);
344341

342+
// TODO: clear setAskFor for MSG_MASTERNODE_PAYMENT_BLOCK too
343+
344+
// Ignore any payments messages until masternode list is synced
345+
if(!masternodeSync.IsMasternodeListSynced()) return;
346+
345347
{
346348
LOCK(cs_mapMasternodePaymentVotes);
347349
if(mapMasternodePaymentVotes.count(nHash)) {

src/masternodeman.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,6 @@ std::pair<CService, std::set<uint256> > CMasternodeMan::PopScheduledMnbRequestCo
771771
void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv, CConnman& connman)
772772
{
773773
if(fLiteMode) return; // disable all Dash specific functionality
774-
if(!masternodeSync.IsBlockchainSynced()) return;
775774

776775
if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast
777776

@@ -780,6 +779,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
780779

781780
pfrom->setAskFor.erase(mnb.GetHash());
782781

782+
if(!masternodeSync.IsBlockchainSynced()) return;
783+
783784
LogPrint("masternode", "MNANNOUNCE -- Masternode announce, masternode=%s\n", mnb.vin.prevout.ToStringShort());
784785

785786
int nDos = 0;
@@ -803,6 +804,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
803804

804805
pfrom->setAskFor.erase(nHash);
805806

807+
if(!masternodeSync.IsBlockchainSynced()) return;
808+
806809
LogPrint("masternode", "MNPING -- Masternode ping, masternode=%s\n", mnp.vin.prevout.ToStringShort());
807810

808811
// Need LOCK2 here to ensure consistent locking order because the CheckAndUpdate call below locks cs_main
@@ -909,6 +912,10 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
909912
CMasternodeVerification mnv;
910913
vRecv >> mnv;
911914

915+
pfrom->setAskFor.erase(mnv.GetHash());
916+
917+
if(!masternodeSync.IsMasternodeListSynced()) return;
918+
912919
if(mnv.vchSig1.empty()) {
913920
// CASE 1: someone asked me to verify myself /IP we are using/
914921
SendVerifyReply(pfrom, mnv, connman);

0 commit comments

Comments
 (0)