mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Refactor CQuorumBlockProcessor and CDeterministicMNManager (#2536)
* Refactor CDeterministicMNManager::ProcessBlock: pintexPrev -> pindex->pprev and/or adjust logic accordingly * Refactor CQuorumBlockProcessor::ProcessBlock: pintexPrev -> pindex->pprev and/or adjust logic accordingly * Drop unused
This commit is contained in:
parent
63b58b1e92
commit
15414dac29
@ -428,14 +428,14 @@ CDeterministicMNManager::CDeterministicMNManager(CEvoDB& _evoDb) :
|
||||
{
|
||||
}
|
||||
|
||||
bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& _state)
|
||||
bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state)
|
||||
{
|
||||
LOCK(cs);
|
||||
|
||||
int nHeight = pindexPrev->nHeight + 1;
|
||||
int nHeight = pindex->nHeight;
|
||||
|
||||
CDeterministicMNList newList;
|
||||
if (!BuildNewListFromBlock(block, pindexPrev, _state, newList, true)) {
|
||||
if (!BuildNewListFromBlock(block, pindex->pprev, _state, newList, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
|
||||
|
||||
newList.SetBlockHash(block.GetHash());
|
||||
|
||||
CDeterministicMNList oldList = GetListForBlock(pindexPrev->GetBlockHash());
|
||||
CDeterministicMNList oldList = GetListForBlock(pindex->pprev->GetBlockHash());
|
||||
CDeterministicMNListDiff diff = oldList.BuildDiff(newList);
|
||||
|
||||
evoDb.Write(std::make_pair(DB_LIST_DIFF, diff.blockHash), diff);
|
||||
|
@ -453,7 +453,7 @@ private:
|
||||
public:
|
||||
CDeterministicMNManager(CEvoDB& _evoDb);
|
||||
|
||||
bool ProcessBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& state);
|
||||
bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
|
||||
bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);
|
||||
|
||||
void UpdatedBlockTip(const CBlockIndex* pindex);
|
||||
|
@ -98,11 +98,11 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CV
|
||||
}
|
||||
}
|
||||
|
||||
if (!llmq::quorumBlockProcessor->ProcessBlock(block, pindex->pprev, state)) {
|
||||
if (!llmq::quorumBlockProcessor->ProcessBlock(block, pindex, state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!deterministicMNManager->ProcessBlock(block, pindex->pprev, state)) {
|
||||
if (!deterministicMNManager->ProcessBlock(block, pindex, state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,19 +105,17 @@ void CQuorumBlockProcessor::ProcessMessage(CNode* pfrom, const std::string& strC
|
||||
}
|
||||
}
|
||||
|
||||
bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& state)
|
||||
bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
bool fDIP0003Active = VersionBitsState(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003, versionbitscache) == THRESHOLD_ACTIVE;
|
||||
bool fDIP0003Active = VersionBitsState(pindex->pprev, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003, versionbitscache) == THRESHOLD_ACTIVE;
|
||||
if (!fDIP0003Active) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int nHeight = pindexPrev->nHeight + 1;
|
||||
|
||||
std::map<Consensus::LLMQType, CFinalCommitment> qcs;
|
||||
if (!GetCommitmentsFromBlock(block, pindexPrev, qcs, state)) {
|
||||
if (!GetCommitmentsFromBlock(block, pindex->pprev, qcs, state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -127,11 +125,9 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex*
|
||||
for (const auto& p : Params().GetConsensus().llmqs) {
|
||||
auto type = p.first;
|
||||
|
||||
uint256 quorumHash = GetQuorumBlockHash(type, pindexPrev);
|
||||
|
||||
// does the currently processed block contain a (possibly null) commitment for the current session?
|
||||
bool hasCommitmentInNewBlock = qcs.count(type) != 0;
|
||||
bool isCommitmentRequired = IsCommitmentRequired(type, pindexPrev);
|
||||
bool isCommitmentRequired = IsCommitmentRequired(type, pindex->pprev);
|
||||
|
||||
if (hasCommitmentInNewBlock && !isCommitmentRequired) {
|
||||
// If we're either not in the mining phase or a non-null commitment was mined already, reject the block
|
||||
@ -147,7 +143,7 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex*
|
||||
|
||||
for (auto& p : qcs) {
|
||||
auto& qc = p.second;
|
||||
if (!ProcessCommitment(pindexPrev, qc, state)) {
|
||||
if (!ProcessCommitment(pindex->pprev, qc, state)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -384,8 +380,6 @@ bool CQuorumBlockProcessor::GetMinableCommitment(Consensus::LLMQType llmqType, c
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
int nHeight = pindexPrev->nHeight + 1;
|
||||
|
||||
if (!IsCommitmentRequired(llmqType, pindexPrev)) {
|
||||
// no commitment required
|
||||
return false;
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
|
||||
|
||||
bool ProcessBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& state);
|
||||
bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
|
||||
bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);
|
||||
|
||||
void AddMinableCommitment(const CFinalCommitment& fqc);
|
||||
|
Loading…
Reference in New Issue
Block a user