diff --git a/src/llmq/dkgsessionmgr.cpp b/src/llmq/dkgsessionmgr.cpp index 04ae1d9166ed6..b9e33f30f9d7f 100644 --- a/src/llmq/dkgsessionmgr.cpp +++ b/src/llmq/dkgsessionmgr.cpp @@ -47,8 +47,6 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai return; } - MigrateDKG(); - const Consensus::Params& consensus_params = Params().GetConsensus(); for (const auto& params : consensus_params.llmqs) { auto session_count = (params.useRotation) ? params.signingActiveQuorumCount : 1; @@ -62,96 +60,6 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai } CDKGSessionManager::~CDKGSessionManager() = default; - -void CDKGSessionManager::MigrateDKG() -{ - if (!db->IsEmpty()) return; - - LogPrint(BCLog::LLMQ, "CDKGSessionManager::%d -- start\n", __func__); - - CDBBatch batch(*db); - auto oldDb = std::make_unique(gArgs.GetDataDirNet() / "llmq", 8 << 20); - std::unique_ptr pcursor(oldDb->NewIterator()); - - auto start_vvec = std::make_tuple(DB_VVEC, (Consensus::LLMQType)0, uint256(), uint256()); - pcursor->Seek(start_vvec); - - while (pcursor->Valid()) { - decltype(start_vvec) k; - std::vector v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != DB_VVEC) { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_contrib = std::make_tuple(DB_SKCONTRIB, (Consensus::LLMQType)0, uint256(), uint256()); - pcursor->Seek(start_contrib); - - while (pcursor->Valid()) { - decltype(start_contrib) k; - CBLSSecretKey v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != DB_SKCONTRIB) { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_enc_contrib = std::make_tuple(DB_ENC_CONTRIB, (Consensus::LLMQType)0, uint256(), uint256()); - pcursor->Seek(start_enc_contrib); - - while (pcursor->Valid()) { - decltype(start_enc_contrib) k; - CBLSIESMultiRecipientObjects v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != DB_ENC_CONTRIB) { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - db->WriteBatch(batch); - pcursor.reset(); - oldDb.reset(); - - LogPrint(BCLog::LLMQ, "CDKGSessionManager::%d -- done\n", __func__); -} - void CDKGSessionManager::StartThreads() { for (auto& it : dkgSessionHandlers) { diff --git a/src/llmq/dkgsessionmgr.h b/src/llmq/dkgsessionmgr.h index 1586e1262d6a2..8ca0f9acd07c7 100644 --- a/src/llmq/dkgsessionmgr.h +++ b/src/llmq/dkgsessionmgr.h @@ -101,7 +101,6 @@ class CDKGSessionManager void CleanupOldContributions() const; private: - void MigrateDKG(); void CleanupCache() const; }; } // namespace llmq diff --git a/src/llmq/signing.cpp b/src/llmq/signing.cpp index c43f403e18edd..68b4949438c07 100644 --- a/src/llmq/signing.cpp +++ b/src/llmq/signing.cpp @@ -46,196 +46,10 @@ UniValue CRecoveredSig::ToJson() const CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory, bool fWipe) : db(std::make_unique(fMemory ? "" : (gArgs.GetDataDirNet() / "llmq/recsigdb"), 8 << 20, fMemory, fWipe)) { - MigrateRecoveredSigs(); } CRecoveredSigsDb::~CRecoveredSigsDb() = default; -void CRecoveredSigsDb::MigrateRecoveredSigs() -{ - if (!db->IsEmpty()) return; - - LogPrint(BCLog::LLMQ, "CRecoveredSigsDb::%d -- start\n", __func__); - - CDBBatch batch(*db); - auto oldDb = std::make_unique(gArgs.GetDataDirNet() / "llmq", 8 << 20); - std::unique_ptr pcursor(oldDb->NewIterator()); - - auto start_h = std::make_tuple(std::string("rs_h"), uint256()); - pcursor->Seek(start_h); - - while (pcursor->Valid()) { - decltype(start_h) k; - std::pair v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_h") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_r1 = std::make_tuple(std::string("rs_r"), (Consensus::LLMQType)0, uint256()); - pcursor->Seek(start_r1); - - while (pcursor->Valid()) { - decltype(start_r1) k; - CRecoveredSig v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_r") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_r2 = std::make_tuple(std::string("rs_r"), (Consensus::LLMQType)0, uint256(), uint256()); - pcursor->Seek(start_r2); - - while (pcursor->Valid()) { - decltype(start_r2) k; - uint32_t v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_r") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_s = std::make_tuple(std::string("rs_s"), uint256()); - pcursor->Seek(start_s); - - while (pcursor->Valid()) { - decltype(start_s) k; - uint8_t v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_s") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_t = std::make_tuple(std::string("rs_t"), (uint32_t)0, (Consensus::LLMQType)0, uint256()); - pcursor->Seek(start_t); - - while (pcursor->Valid()) { - decltype(start_t) k; - uint8_t v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_t") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_v = std::make_tuple(std::string("rs_v"), (Consensus::LLMQType)0, uint256()); - pcursor->Seek(start_v); - - while (pcursor->Valid()) { - decltype(start_v) k; - uint256 v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_v") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - auto start_vt = std::make_tuple(std::string("rs_vt"), (uint32_t)0, (Consensus::LLMQType)0, uint256()); - pcursor->Seek(start_vt); - - while (pcursor->Valid()) { - decltype(start_vt) k; - uint8_t v; - - if (!pcursor->GetKey(k) || std::get<0>(k) != "rs_vt") { - break; - } - if (!pcursor->GetValue(v)) { - break; - } - - batch.Write(k, v); - - if (batch.SizeEstimate() >= (1 << 24)) { - db->WriteBatch(batch); - batch.Clear(); - } - - pcursor->Next(); - } - - db->WriteBatch(batch); - pcursor.reset(); - oldDb.reset(); - - LogPrint(BCLog::LLMQ, "CRecoveredSigsDb::%d -- done\n", __func__); -} - bool CRecoveredSigsDb::HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) const { auto k = std::make_tuple(std::string("rs_r"), llmqType, id, msgHash); diff --git a/src/llmq/signing.h b/src/llmq/signing.h index cd63cc9b349be..e3519cb3abf2f 100644 --- a/src/llmq/signing.h +++ b/src/llmq/signing.h @@ -143,8 +143,6 @@ class CRecoveredSigsDb void CleanupOldVotes(int64_t maxAge); private: - void MigrateRecoveredSigs(); - bool ReadRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, CRecoveredSig& ret) const; void RemoveRecoveredSig(CDBBatch& batch, Consensus::LLMQType llmqType, const uint256& id, bool deleteHashKey, bool deleteTimeKey); };