mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32: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);
|
LOCK(cs);
|
||||||
|
|
||||||
int nHeight = pindexPrev->nHeight + 1;
|
int nHeight = pindex->nHeight;
|
||||||
|
|
||||||
CDeterministicMNList newList;
|
CDeterministicMNList newList;
|
||||||
if (!BuildNewListFromBlock(block, pindexPrev, _state, newList, true)) {
|
if (!BuildNewListFromBlock(block, pindex->pprev, _state, newList, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
|
|||||||
|
|
||||||
newList.SetBlockHash(block.GetHash());
|
newList.SetBlockHash(block.GetHash());
|
||||||
|
|
||||||
CDeterministicMNList oldList = GetListForBlock(pindexPrev->GetBlockHash());
|
CDeterministicMNList oldList = GetListForBlock(pindex->pprev->GetBlockHash());
|
||||||
CDeterministicMNListDiff diff = oldList.BuildDiff(newList);
|
CDeterministicMNListDiff diff = oldList.BuildDiff(newList);
|
||||||
|
|
||||||
evoDb.Write(std::make_pair(DB_LIST_DIFF, diff.blockHash), diff);
|
evoDb.Write(std::make_pair(DB_LIST_DIFF, diff.blockHash), diff);
|
||||||
|
@ -453,7 +453,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
CDeterministicMNManager(CEvoDB& _evoDb);
|
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);
|
bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);
|
||||||
|
|
||||||
void UpdatedBlockTip(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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deterministicMNManager->ProcessBlock(block, pindex->pprev, state)) {
|
if (!deterministicMNManager->ProcessBlock(block, pindex, state)) {
|
||||||
return false;
|
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);
|
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) {
|
if (!fDIP0003Active) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nHeight = pindexPrev->nHeight + 1;
|
|
||||||
|
|
||||||
std::map<Consensus::LLMQType, CFinalCommitment> qcs;
|
std::map<Consensus::LLMQType, CFinalCommitment> qcs;
|
||||||
if (!GetCommitmentsFromBlock(block, pindexPrev, qcs, state)) {
|
if (!GetCommitmentsFromBlock(block, pindex->pprev, qcs, state)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +125,9 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex*
|
|||||||
for (const auto& p : Params().GetConsensus().llmqs) {
|
for (const auto& p : Params().GetConsensus().llmqs) {
|
||||||
auto type = p.first;
|
auto type = p.first;
|
||||||
|
|
||||||
uint256 quorumHash = GetQuorumBlockHash(type, pindexPrev);
|
|
||||||
|
|
||||||
// does the currently processed block contain a (possibly null) commitment for the current session?
|
// does the currently processed block contain a (possibly null) commitment for the current session?
|
||||||
bool hasCommitmentInNewBlock = qcs.count(type) != 0;
|
bool hasCommitmentInNewBlock = qcs.count(type) != 0;
|
||||||
bool isCommitmentRequired = IsCommitmentRequired(type, pindexPrev);
|
bool isCommitmentRequired = IsCommitmentRequired(type, pindex->pprev);
|
||||||
|
|
||||||
if (hasCommitmentInNewBlock && !isCommitmentRequired) {
|
if (hasCommitmentInNewBlock && !isCommitmentRequired) {
|
||||||
// If we're either not in the mining phase or a non-null commitment was mined already, reject the block
|
// 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) {
|
for (auto& p : qcs) {
|
||||||
auto& qc = p.second;
|
auto& qc = p.second;
|
||||||
if (!ProcessCommitment(pindexPrev, qc, state)) {
|
if (!ProcessCommitment(pindex->pprev, qc, state)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,8 +380,6 @@ bool CQuorumBlockProcessor::GetMinableCommitment(Consensus::LLMQType llmqType, c
|
|||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
int nHeight = pindexPrev->nHeight + 1;
|
|
||||||
|
|
||||||
if (!IsCommitmentRequired(llmqType, pindexPrev)) {
|
if (!IsCommitmentRequired(llmqType, pindexPrev)) {
|
||||||
// no commitment required
|
// no commitment required
|
||||||
return false;
|
return false;
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
|
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);
|
bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);
|
||||||
|
|
||||||
void AddMinableCommitment(const CFinalCommitment& fqc);
|
void AddMinableCommitment(const CFinalCommitment& fqc);
|
||||||
|
Loading…
Reference in New Issue
Block a user