CGovernanceManager initialization fix (#1138)
* Fix CGovernanceManager initialization problem * Added logging messages for cases where CGovernanceManager receives a message while not synced * Prevent potential NULL pointer dereference
This commit is contained in:
parent
d2f1fd253c
commit
82ca5fdbb8
@ -129,7 +129,10 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
// MAKE SURE WE HAVE A VALID REFERENCE TO THE TIP BEFORE CONTINUING
|
// MAKE SURE WE HAVE A VALID REFERENCE TO THE TIP BEFORE CONTINUING
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) return;
|
if(!pCurrentBlockIndex) {
|
||||||
|
LogPrintf("CGovernanceManager::ProcessMessage MNGOVERNANCEOBJECT -- pCurrentBlockIndex is NULL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CGovernanceObject govobj;
|
CGovernanceObject govobj;
|
||||||
vRecv >> govobj;
|
vRecv >> govobj;
|
||||||
@ -172,7 +175,10 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
else if (strCommand == NetMsgType::MNGOVERNANCEOBJECTVOTE)
|
else if (strCommand == NetMsgType::MNGOVERNANCEOBJECTVOTE)
|
||||||
{
|
{
|
||||||
// Ignore such messages until masternode list is synced
|
// Ignore such messages until masternode list is synced
|
||||||
if(!masternodeSync.IsMasternodeListSynced()) return;
|
if(!masternodeSync.IsMasternodeListSynced()) {
|
||||||
|
LogPrint("gobject", "CGovernanceManager::ProcessMessage MNGOVERNANCEOBJECTVOTE -- masternode list not synced\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CGovernanceVote vote;
|
CGovernanceVote vote;
|
||||||
vRecv >> vote;
|
vRecv >> vote;
|
||||||
@ -1125,6 +1131,10 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex *pindex)
|
|||||||
// On the other hand it should be safe for us to access pindex without holding a lock
|
// On the other hand it should be safe for us to access pindex without holding a lock
|
||||||
// on cs_main because the CBlockIndex objects are dynamically allocated and
|
// on cs_main because the CBlockIndex objects are dynamically allocated and
|
||||||
// presumably never deleted.
|
// presumably never deleted.
|
||||||
|
if(!pindex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
pCurrentBlockIndex = pindex;
|
pCurrentBlockIndex = pindex;
|
||||||
nCachedBlockHeight = pCurrentBlockIndex->nHeight;
|
nCachedBlockHeight = pCurrentBlockIndex->nHeight;
|
||||||
|
@ -1883,6 +1883,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
darkSendPool.UpdatedBlockTip(chainActive.Tip());
|
darkSendPool.UpdatedBlockTip(chainActive.Tip());
|
||||||
mnpayments.UpdatedBlockTip(chainActive.Tip());
|
mnpayments.UpdatedBlockTip(chainActive.Tip());
|
||||||
masternodeSync.UpdatedBlockTip(chainActive.Tip());
|
masternodeSync.UpdatedBlockTip(chainActive.Tip());
|
||||||
|
governance.UpdatedBlockTip(chainActive.Tip());
|
||||||
|
|
||||||
// ********************************************************* Step 11d: start dash-privatesend thread
|
// ********************************************************* Step 11d: start dash-privatesend thread
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user