Governance: Fix governance object syncing in AddOrUpdateVote. (#1061)
There is a bug AddOrUpdateVote function in CGovernanceManager. If a new vote has been arrived it is checked if a corresponding parent object are present in the mapObjects. If it is not we need to sync the parent object and return false. But the syncing is never performed because the corresponding code is placed after return statement. So we need to sync and then return.
This commit is contained in:
parent
81c3ccbdf8
commit
d537610047
@ -494,33 +494,35 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, CNode* pfr
|
|||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
if(!mapObjects.count(vote.GetParentHash())) {
|
if(!mapObjects.count(vote.GetParentHash())) {
|
||||||
if(pfrom) {
|
if(pfrom) {
|
||||||
// only ask for missing items after our syncing process is complete --
|
// only ask for missing items after our syncing process is complete --
|
||||||
// otherwise we'll think a full sync succeeded when they return a result
|
// otherwise we'll think a full sync succeeded when they return a result
|
||||||
if(!masternodeSync.IsSynced()) return false;
|
if(!masternodeSync.IsSynced()) return false;
|
||||||
|
|
||||||
// ADD THE VOTE AS AN ORPHAN, TO BE USED UPON RECEIVAL OF THE PARENT OBJECT
|
// ADD THE VOTE AS AN ORPHAN, TO BE USED UPON RECEIVAL OF THE PARENT OBJECT
|
||||||
|
|
||||||
LogPrintf("CGovernanceManager::AddOrUpdateVote - Unknown object %d, asking for source\n", vote.GetParentHash().ToString());
|
LogPrintf("CGovernanceManager::AddOrUpdateVote - Unknown object %d, asking for source\n", vote.GetParentHash().ToString());
|
||||||
mapOrphanVotes[vote.GetParentHash()] = vote;
|
mapOrphanVotes[vote.GetParentHash()] = vote;
|
||||||
|
|
||||||
// ASK FOR THIS VOTES PARENT SPECIFICALLY FROM THIS USER (THEY SHOULD HAVE IT, NO?)
|
// ASK FOR THIS VOTES PARENT SPECIFICALLY FROM THIS USER (THEY SHOULD HAVE IT, NO?)
|
||||||
|
|
||||||
if(!mapAskedForGovernanceObject.count(vote.GetParentHash())){
|
if(!mapAskedForGovernanceObject.count(vote.GetParentHash())){
|
||||||
syncparent = true;
|
syncparent = true;
|
||||||
votehash = vote.GetParentHash();
|
votehash = vote.GetParentHash();
|
||||||
mapAskedForGovernanceObject[vote.GetParentHash()] = GetTime();
|
mapAskedForGovernanceObject[vote.GetParentHash()] = GetTime();
|
||||||
}
|
} else {
|
||||||
|
strError = "Governance object not found! Sync message has been already pushed.";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
strError = "Governance object not found!";
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to keep this out of the locked section
|
// Need to keep this out of the locked section
|
||||||
if(syncparent) {
|
if(syncparent) {
|
||||||
pfrom->PushMessage(NetMsgType::MNGOVERNANCESYNC, votehash);
|
pfrom->PushMessage(NetMsgType::MNGOVERNANCESYNC, votehash);
|
||||||
|
strError = "Governance object not found! Sync message was pushed.";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reestablish lock
|
// Reestablish lock
|
||||||
|
Loading…
Reference in New Issue
Block a user