mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
cleanup: drop UpgradeDB for llmq::BlockProcessor
This commit is contained in:
parent
e6391b606a
commit
33728107ec
@ -2074,11 +2074,6 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
break;
|
||||
}
|
||||
|
||||
if (!llmq::quorumBlockProcessor->UpgradeDB()) {
|
||||
strLoadError = _("Error upgrading evo database");
|
||||
break;
|
||||
}
|
||||
|
||||
for (CChainState* chainstate : chainman.GetAll()) {
|
||||
if (!is_coinsview_empty(chainstate)) {
|
||||
uiInterface.InitMessage(_("Verifying blocks...").translated);
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <consensus/validation.h>
|
||||
#include <net.h>
|
||||
#include <net_processing.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <primitives/block.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <saltedhasher.h>
|
||||
@ -353,64 +352,6 @@ bool CQuorumBlockProcessor::UndoBlock(const CBlock& block, gsl::not_null<const C
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO remove this with 0.15.0
|
||||
bool CQuorumBlockProcessor::UpgradeDB()
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
||||
if (m_chainstate.m_chain.Tip() == nullptr) {
|
||||
// should have no records
|
||||
return m_evoDb.IsEmpty();
|
||||
}
|
||||
|
||||
uint256 bestBlock;
|
||||
if (m_evoDb.GetRawDB().Read(DB_BEST_BLOCK_UPGRADE, bestBlock) && bestBlock == m_chainstate.m_chain.Tip()->GetBlockHash()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LogPrintf("CQuorumBlockProcessor::%s -- Upgrading DB...\n", __func__);
|
||||
|
||||
if (m_chainstate.m_chain.Height() >= Params().GetConsensus().DIP0003EnforcementHeight) {
|
||||
const auto* pindex = m_chainstate.m_chain[Params().GetConsensus().DIP0003EnforcementHeight];
|
||||
while (pindex != nullptr) {
|
||||
if (fPruneMode && ((pindex->nStatus & BLOCK_HAVE_DATA) == 0)) {
|
||||
// Too late, we already pruned blocks we needed to reprocess commitments
|
||||
return false;
|
||||
}
|
||||
CBlock block;
|
||||
bool r = ReadBlockFromDisk(block, pindex, Params().GetConsensus());
|
||||
assert(r);
|
||||
|
||||
std::multimap<Consensus::LLMQType, CFinalCommitment> qcs;
|
||||
BlockValidationState dummyState;
|
||||
GetCommitmentsFromBlock(block, pindex, qcs, dummyState);
|
||||
|
||||
for (const auto& p : qcs) {
|
||||
const auto& qc = p.second;
|
||||
if (qc.IsNull()) {
|
||||
continue;
|
||||
}
|
||||
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
|
||||
m_evoDb.GetRawDB().Write(std::make_pair(DB_MINED_COMMITMENT, std::make_pair(qc.llmqType, qc.quorumHash)), std::make_pair(qc, pindex->GetBlockHash()));
|
||||
const auto& llmq_params_opt = GetLLMQParams(qc.llmqType);
|
||||
assert(llmq_params_opt.has_value());
|
||||
if (llmq::utils::IsQuorumRotationEnabled(llmq_params_opt.value(), pQuorumBaseBlockIndex)) {
|
||||
m_evoDb.GetRawDB().Write(BuildInversedHeightKeyIndexed(qc.llmqType, pindex->nHeight, int(qc.quorumIndex)), pQuorumBaseBlockIndex->nHeight);
|
||||
} else {
|
||||
m_evoDb.GetRawDB().Write(BuildInversedHeightKey(qc.llmqType, pindex->nHeight), pQuorumBaseBlockIndex->nHeight);
|
||||
}
|
||||
}
|
||||
|
||||
m_evoDb.GetRawDB().Write(DB_BEST_BLOCK_UPGRADE, pindex->GetBlockHash());
|
||||
|
||||
pindex = m_chainstate.m_chain.Next(pindex);
|
||||
}
|
||||
}
|
||||
|
||||
LogPrintf("CQuorumBlockProcessor::%s -- Upgrade done...\n", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CQuorumBlockProcessor::GetCommitmentsFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, std::multimap<Consensus::LLMQType, CFinalCommitment>& ret, BlockValidationState& state)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
@ -51,8 +51,6 @@ private:
|
||||
public:
|
||||
explicit CQuorumBlockProcessor(CChainState& chainstate, CConnman& _connman, CEvoDB& evoDb, const std::unique_ptr<PeerManager>& peerman);
|
||||
|
||||
bool UpgradeDB();
|
||||
|
||||
void ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv);
|
||||
|
||||
bool ProcessBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
Loading…
Reference in New Issue
Block a user