Skip to content

Commit

Permalink
Merge pull request #785 from pocketnetteam:fix/jury_check
Browse files Browse the repository at this point in the history
Refactor moderation vote validation in Vote.hpp: move jury vote checks to the appropriate section, ensuring correct processing logic and maintaining delay acceptance for moderator votes.
  • Loading branch information
andyoknen authored Dec 13, 2024
2 parents 9e9649d + f3a85ba commit e4e4fd2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/pocketdb/consensus/moderation/Vote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ namespace PocketConsensus
if (ConsensusRepoInst.Exists_S1S2T(*ptx->GetAddress(), *ptx->GetJuryId(), { MODERATION_VOTE }))
return {false, ConsensusResult_Duplicate};

// The moderators' votes should be accepted with a delay, in case the jury gets into the orphan block
auto juryFlag = ConsensusRepoInst.Get(*ptx->GetJuryId());
if (!juryFlag || *juryFlag->GetType() != MODERATION_FLAG
|| !juryFlag->GetHeight() || (Height - *juryFlag->GetHeight() < 10))
return {false, ConsensusResult_NotAllowed};

// Votes allowed if moderator requested by system
if (!ConsensusRepoInst.AllowJuryModerate(*ptx->GetAddress(), *ptx->GetJuryId()))
return {false, ConsensusResult_NotAllowed};

return Success;
}

Expand Down Expand Up @@ -97,6 +87,17 @@ namespace PocketConsensus
if (!ConsensusRepoInst.ExistsActiveJury(*ptx->GetJuryId()))
return {false, ConsensusResult_NotFound};

// The moderators' votes should be accepted with a delay, in case the jury gets into the orphan block
auto juryFlag = ConsensusRepoInst.Get(*ptx->GetJuryId());
if (!juryFlag || *juryFlag->GetType() != MODERATION_FLAG
|| !juryFlag->GetHeight() || (Height - *juryFlag->GetHeight() < 10))
return {false, ConsensusResult_NotAllowed};

// Votes allowed if moderator requested by system
if (!ConsensusRepoInst.AllowJuryModerate(*ptx->GetAddress(), *ptx->GetJuryId()))
return {false, ConsensusResult_NotAllowed};


return Success;
}
};
Expand Down

0 comments on commit e4e4fd2

Please sign in to comment.