Add some comments to make quorum merkle root calculation more clear+ (#2984)
This should avoid future confusion.
This commit is contained in:
parent
6677a614a7
commit
2e13d1305c
@ -155,6 +155,7 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre
|
|||||||
static std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> quorumsCached;
|
static std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> quorumsCached;
|
||||||
static std::map<Consensus::LLMQType, std::vector<uint256>> qcHashesCached;
|
static std::map<Consensus::LLMQType, std::vector<uint256>> qcHashesCached;
|
||||||
|
|
||||||
|
// The returned quorums are in reversed order, so the most recent one is at index 0
|
||||||
auto quorums = llmq::quorumBlockProcessor->GetMinedAndActiveCommitmentsUntilBlock(pindexPrev);
|
auto quorums = llmq::quorumBlockProcessor->GetMinedAndActiveCommitmentsUntilBlock(pindexPrev);
|
||||||
std::map<Consensus::LLMQType, std::vector<uint256>> qcHashes;
|
std::map<Consensus::LLMQType, std::vector<uint256>> qcHashes;
|
||||||
size_t hashCount = 0;
|
size_t hashCount = 0;
|
||||||
@ -201,6 +202,9 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre
|
|||||||
const auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)qc.commitment.llmqType);
|
const auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)qc.commitment.llmqType);
|
||||||
auto& v = qcHashes[params.type];
|
auto& v = qcHashes[params.type];
|
||||||
if (v.size() == params.signingActiveQuorumCount) {
|
if (v.size() == params.signingActiveQuorumCount) {
|
||||||
|
// we pop the last entry, which is actually the oldest quorum as GetMinedAndActiveCommitmentsUntilBlock
|
||||||
|
// returned quorums in reversed order. This pop and later push can only work ONCE, but we rely on the
|
||||||
|
// fact that a block can only contain a single commitment for one LLMQ type
|
||||||
v.pop_back();
|
v.pop_back();
|
||||||
}
|
}
|
||||||
v.emplace_back(qcHash);
|
v.emplace_back(qcHash);
|
||||||
|
@ -405,6 +405,7 @@ bool CQuorumBlockProcessor::GetMinedCommitment(Consensus::LLMQType llmqType, con
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The returned quorums are in reversed order, so the most recent one is at index 0
|
||||||
std::vector<const CBlockIndex*> CQuorumBlockProcessor::GetMinedCommitmentsUntilBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex, size_t maxCount)
|
std::vector<const CBlockIndex*> CQuorumBlockProcessor::GetMinedCommitmentsUntilBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex, size_t maxCount)
|
||||||
{
|
{
|
||||||
auto dbIt = evoDb.GetCurTransaction().NewIteratorUniquePtr();
|
auto dbIt = evoDb.GetCurTransaction().NewIteratorUniquePtr();
|
||||||
@ -446,6 +447,7 @@ std::vector<const CBlockIndex*> CQuorumBlockProcessor::GetMinedCommitmentsUntilB
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The returned quorums are in reversed order, so the most recent one is at index 0
|
||||||
std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> CQuorumBlockProcessor::GetMinedAndActiveCommitmentsUntilBlock(const CBlockIndex* pindex)
|
std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> CQuorumBlockProcessor::GetMinedAndActiveCommitmentsUntilBlock(const CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> ret;
|
std::map<Consensus::LLMQType, std::vector<const CBlockIndex*>> ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user