diff --git a/src/llmq/quorums_dkgsession.h b/src/llmq/quorums_dkgsession.h index 7340ee34edd2b..c7c546d79e1f0 100644 --- a/src/llmq/quorums_dkgsession.h +++ b/src/llmq/quorums_dkgsession.h @@ -10,7 +10,6 @@ #include "bls/bls_worker.h" #include "consensus/params.h" #include "evo/deterministicmns.h" -#include "evo/evodb.h" #include "net.h" #include "llmq/quorums_utils.h" #include "logging.h" @@ -237,7 +236,6 @@ class CDKGSession private: const Consensus::LLMQParams& params; - CEvoDB& evoDb; CBLSWorker& blsWorker; CBLSWorkerCache cache; CDKGSessionManager& dkgManager; @@ -277,8 +275,8 @@ class CDKGSession std::set validCommitments; public: - CDKGSession(const Consensus::LLMQParams& _params, CEvoDB& _evoDb, CBLSWorker& _blsWorker, CDKGSessionManager& _dkgManager) : - params(_params), evoDb(_evoDb), blsWorker(_blsWorker), cache(_blsWorker), dkgManager(_dkgManager) {} + CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDKGSessionManager& _dkgManager) : + params(_params), blsWorker(_blsWorker), cache(_blsWorker), dkgManager(_dkgManager) {} bool Init(const CBlockIndex* _pindexQuorum, const std::vector& mns, const uint256& _myProTxHash); diff --git a/src/llmq/quorums_dkgsessionhandler.cpp b/src/llmq/quorums_dkgsessionhandler.cpp index c8630f00e0b3e..7fa7722c696c1 100644 --- a/src/llmq/quorums_dkgsessionhandler.cpp +++ b/src/llmq/quorums_dkgsessionhandler.cpp @@ -84,12 +84,11 @@ void CDKGPendingMessages::Clear() ////// -CDKGSessionHandler::CDKGSessionHandler(const Consensus::LLMQParams& _params, CEvoDB& _evoDb, CBLSWorker& _blsWorker, CDKGSessionManager& _dkgManager) : +CDKGSessionHandler::CDKGSessionHandler(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDKGSessionManager& _dkgManager) : params(_params), - evoDb(_evoDb), blsWorker(_blsWorker), dkgManager(_dkgManager), - curSession(std::make_shared(_params, _evoDb, _blsWorker, _dkgManager)), + curSession(std::make_shared(_params, _blsWorker, _dkgManager)), pendingContributions((size_t)_params.size * 2), // we allow size*2 messages as we need to make sure we see bad behavior (double messages) pendingComplaints((size_t)_params.size * 2), pendingJustifications((size_t)_params.size * 2), @@ -162,7 +161,7 @@ void CDKGSessionHandler::StopThread() bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pindexQuorum) { - curSession = std::make_shared(params, evoDb, blsWorker, dkgManager); + curSession = std::make_shared(params, blsWorker, dkgManager); if (!deterministicMNManager->IsDIP3Enforced(pindexQuorum->nHeight) || !activeMasternodeManager) { diff --git a/src/llmq/quorums_dkgsessionhandler.h b/src/llmq/quorums_dkgsessionhandler.h index 5b212daa4db6b..d745938b9cc8d 100644 --- a/src/llmq/quorums_dkgsessionhandler.h +++ b/src/llmq/quorums_dkgsessionhandler.h @@ -100,7 +100,6 @@ class CDKGSessionHandler std::atomic stopRequested{false}; const Consensus::LLMQParams& params; - CEvoDB& evoDb; CBLSWorker& blsWorker; CDKGSessionManager& dkgManager; @@ -117,7 +116,7 @@ class CDKGSessionHandler CDKGPendingMessages pendingPrematureCommitments; public: - CDKGSessionHandler(const Consensus::LLMQParams& _params, CEvoDB& _evoDb, CBLSWorker& blsWorker, CDKGSessionManager& _dkgManager); + CDKGSessionHandler(const Consensus::LLMQParams& _params, CBLSWorker& blsWorker, CDKGSessionManager& _dkgManager); ~CDKGSessionHandler(); void UpdatedBlockTip(const CBlockIndex *pindexNew); diff --git a/src/llmq/quorums_dkgsessionmgr.cpp b/src/llmq/quorums_dkgsessionmgr.cpp index 296444954de83..2c8dd0490ef27 100644 --- a/src/llmq/quorums_dkgsessionmgr.cpp +++ b/src/llmq/quorums_dkgsessionmgr.cpp @@ -19,14 +19,13 @@ std::unique_ptr quorumDKGSessionManager{nullptr}; static const std::string DB_VVEC = "qdkg_V"; static const std::string DB_SKCONTRIB = "qdkg_S"; -CDKGSessionManager::CDKGSessionManager(CEvoDB& _evoDb, CBLSWorker& _blsWorker) : - evoDb(_evoDb), - blsWorker(_blsWorker) +CDKGSessionManager::CDKGSessionManager(CDBWrapper& _llmqDb, CBLSWorker& _blsWorker) : llmqDb(_llmqDb), + blsWorker(_blsWorker) { for (const auto& qt : Params().GetConsensus().llmqs) { dkgSessionHandlers.emplace(std::piecewise_construct, std::forward_as_tuple(qt.first), - std::forward_as_tuple(qt.second, evoDb, blsWorker, *this)); + std::forward_as_tuple(qt.second, blsWorker, *this)); } } @@ -160,12 +159,12 @@ bool CDKGSessionManager::GetPrematureCommitment(const uint256& hash, CDKGPrematu void CDKGSessionManager::WriteVerifiedVvecContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& proTxHash, const BLSVerificationVectorPtr& vvec) { - evoDb.GetRawDB().Write(std::make_tuple(DB_VVEC, (uint8_t)llmqType, pindexQuorum->GetBlockHash(), proTxHash), *vvec); + llmqDb.Write(std::make_tuple(DB_VVEC, (uint8_t)llmqType, pindexQuorum->GetBlockHash(), proTxHash), *vvec); } void CDKGSessionManager::WriteVerifiedSkContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const uint256& proTxHash, const CBLSSecretKey& skContribution) { - evoDb.GetRawDB().Write(std::make_tuple(DB_SKCONTRIB, (uint8_t)llmqType, pindexQuorum->GetBlockHash(), proTxHash), skContribution); + llmqDb.Write(std::make_tuple(DB_SKCONTRIB, (uint8_t)llmqType, pindexQuorum->GetBlockHash(), proTxHash), skContribution); } bool CDKGSessionManager::GetVerifiedContributions(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum, const std::vector& validMembers, std::vector& memberIndexesRet, std::vector& vvecsRet, BLSSecretKeyVector& skContributionsRet) @@ -209,10 +208,10 @@ bool CDKGSessionManager::GetVerifiedContribution(Consensus::LLMQType llmqType, c BLSVerificationVector vvec; BLSVerificationVectorPtr vvecPtr; CBLSSecretKey skContribution; - if (evoDb.GetRawDB().Read(std::make_tuple(DB_VVEC, (uint8_t)llmqType, quorumHash, proTxHash), vvec)) { + if (llmqDb.Read(std::make_tuple(DB_VVEC, (uint8_t)llmqType, quorumHash, proTxHash), vvec)) { vvecPtr = std::make_shared(std::move(vvec)); } - evoDb.GetRawDB().Read(std::make_tuple(DB_SKCONTRIB, (uint8_t)llmqType, quorumHash, proTxHash), skContribution); + llmqDb.Read(std::make_tuple(DB_SKCONTRIB, (uint8_t)llmqType, quorumHash, proTxHash), skContribution); it = contributionsCache.emplace(cacheKey, ContributionsCacheEntry{GetTimeMillis(), vvecPtr, skContribution}).first; diff --git a/src/llmq/quorums_dkgsessionmgr.h b/src/llmq/quorums_dkgsessionmgr.h index bbe078343861e..c2284b2adcd43 100644 --- a/src/llmq/quorums_dkgsessionmgr.h +++ b/src/llmq/quorums_dkgsessionmgr.h @@ -20,7 +20,7 @@ class CDKGSessionManager static const int64_t MAX_CONTRIBUTION_CACHE_TIME = 60 * 1000; private: - CEvoDB& evoDb; + CDBWrapper& llmqDb; CBLSWorker& blsWorker; std::map dkgSessionHandlers; @@ -45,7 +45,7 @@ class CDKGSessionManager std::map contributionsCache; public: - CDKGSessionManager(CEvoDB& _evoDb, CBLSWorker& _blsWorker); + CDKGSessionManager(CDBWrapper& _evoDb, CBLSWorker& _blsWorker); ~CDKGSessionManager() {}; void StartThreads(); diff --git a/src/llmq/quorums_init.cpp b/src/llmq/quorums_init.cpp index 87bd3320baa1b..d272d7bc1e8aa 100644 --- a/src/llmq/quorums_init.cpp +++ b/src/llmq/quorums_init.cpp @@ -6,6 +6,7 @@ #include "llmq/quorums_init.h" #include "bls/bls_worker.h" +#include "dbwrapper.h" #include "llmq/quorums.h" #include "llmq/quorums_blockprocessor.h" #include "llmq/quorums_debug.h" @@ -18,17 +19,19 @@ namespace llmq { CBLSWorker* blsWorker; +CDBWrapper* llmqDb; void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests) { + llmqDb = new CDBWrapper(unitTests ? "" : (GetDataDir() / "llmq"), 1 << 20, unitTests, false, CLIENT_VERSION | ADDRV2_FORMAT); blsWorker = new CBLSWorker(); quorumDKGDebugManager.reset(new CDKGDebugManager()); quorumBlockProcessor.reset(new CQuorumBlockProcessor(evoDb)); - quorumDKGSessionManager.reset(new CDKGSessionManager(evoDb, *blsWorker)); + quorumDKGSessionManager.reset(new CDKGSessionManager(*llmqDb, *blsWorker)); quorumManager.reset(new CQuorumManager(evoDb, *blsWorker, *quorumDKGSessionManager)); quorumSigSharesManager.reset(new CSigSharesManager()); - quorumSigningManager.reset(new CSigningManager(unitTests)); + quorumSigningManager.reset(new CSigningManager(*llmqDb, unitTests)); chainLocksHandler.reset(new CChainLocksHandler(scheduler)); } @@ -43,6 +46,8 @@ void DestroyLLMQSystem() quorumManager.reset(); delete blsWorker; blsWorker = nullptr; + delete llmqDb; + llmqDb = nullptr; } void StartLLMQSystem() diff --git a/src/llmq/quorums_init.h b/src/llmq/quorums_init.h index cc56b5ff7c5c7..0f4e3b852cc3c 100644 --- a/src/llmq/quorums_init.h +++ b/src/llmq/quorums_init.h @@ -14,6 +14,8 @@ class CEvoDB; namespace llmq { +extern CDBWrapper* llmqDb; + // Init/destroy LLMQ globals void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests); void DestroyLLMQSystem(); diff --git a/src/llmq/quorums_signing.cpp b/src/llmq/quorums_signing.cpp index 34a1a9816bfc4..b2c04d3af95b6 100644 --- a/src/llmq/quorums_signing.cpp +++ b/src/llmq/quorums_signing.cpp @@ -24,84 +24,75 @@ namespace llmq std::unique_ptr quorumSigningManager{nullptr}; -CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory) : db(fMemory ? "" : (GetDataDir() / "llmq"), 1 << 20, fMemory, false, CLIENT_VERSION | ADDRV2_FORMAT) +CRecoveredSigsDb::CRecoveredSigsDb(CDBWrapper& _db) : db(_db) { } bool CRecoveredSigsDb::HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) { - auto k = std::make_tuple('r', (uint8_t)llmqType, id, msgHash); + auto k = std::make_tuple(std::string("rs_r"), (uint8_t)llmqType, id, msgHash); return db.Exists(k); } bool CRecoveredSigsDb::HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id) { - int64_t t = GetTimeMillis(); - auto cacheKey = std::make_pair(llmqType, id); + bool ret; { LOCK(cs); - auto it = hasSigForIdCache.find(cacheKey); - if (it != hasSigForIdCache.end()) { - it->second.second = t; - return it->second.first; + if (hasSigForIdCache.get(cacheKey, ret)) { + return ret; } } - auto k = std::make_tuple('r', (uint8_t)llmqType, id); - bool ret = db.Exists(k); + auto k = std::make_tuple(std::string("rs_r"), (uint8_t)llmqType, id); + ret = db.Exists(k); LOCK(cs); - hasSigForIdCache.emplace(cacheKey, std::make_pair(ret, t)); + hasSigForIdCache.insert(cacheKey, ret); return ret; } bool CRecoveredSigsDb::HasRecoveredSigForSession(const uint256& signHash) { - int64_t t = GetTimeMillis(); - + bool ret; { LOCK(cs); - auto it = hasSigForSessionCache.find(signHash); - if (it != hasSigForSessionCache.end()) { - it->second.second = t; - return it->second.first; + if (hasSigForSessionCache.get(signHash, ret)) { + return ret; } } - auto k = std::make_tuple('s', signHash); - bool ret = db.Exists(k); + auto k = std::make_tuple(std::string("rs_s"), signHash); + ret = db.Exists(k); LOCK(cs); - hasSigForSessionCache.emplace(signHash, std::make_pair(ret, t)); + hasSigForSessionCache.insert(signHash, ret); return ret; } bool CRecoveredSigsDb::HasRecoveredSigForHash(const uint256& hash) { - int64_t t = GetTimeMillis(); - + bool ret; { LOCK(cs); - auto it = hasSigForHashCache.find(hash); - if (it != hasSigForHashCache.end()) { - it->second.second = t; - return it->second.first; + if (hasSigForHashCache.get(hash, ret)) { + return ret; } } - auto k = std::make_tuple('h', hash); - bool ret = db.Exists(k); + auto k = std::make_tuple(std::string("rs_h"), hash); + ret = db.Exists(k); LOCK(cs); - hasSigForHashCache.emplace(hash, std::make_pair(ret, t)); + hasSigForHashCache.insert(hash, ret); return ret; } bool CRecoveredSigsDb::ReadRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, CRecoveredSig& ret) { - auto k = std::make_tuple('r', (uint8_t)llmqType, id); + auto k = std::make_tuple(std::string("rs_r"), (uint8_t)llmqType, id); CDataStream ds(SER_DISK, CLIENT_VERSION); if (!db.ReadDataStream(k, ds)) { @@ -118,7 +109,7 @@ bool CRecoveredSigsDb::ReadRecoveredSig(Consensus::LLMQType llmqType, const uint bool CRecoveredSigsDb::GetRecoveredSigByHash(const uint256& hash, CRecoveredSig& ret) { - auto k1 = std::make_tuple('h', hash); + auto k1 = std::make_tuple(std::string("rs_h"), hash); std::pair k2; if (!db.Read(k1, k2)) { return false; @@ -138,26 +129,26 @@ void CRecoveredSigsDb::WriteRecoveredSig(const llmq::CRecoveredSig& recSig) // we put these close to each other to leverage leveldb's key compaction // this way, the second key can be used for fast HasRecoveredSig checks while the first key stores the recSig - auto k1 = std::make_tuple('r', recSig.llmqType, recSig.id); - auto k2 = std::make_tuple('r', recSig.llmqType, recSig.id, recSig.msgHash); + auto k1 = std::make_tuple(std::string("rs_r"), recSig.llmqType, recSig.id); + auto k2 = std::make_tuple(std::string("rs_r"), recSig.llmqType, recSig.id, recSig.msgHash); batch.Write(k1, recSig); batch.Write(k2, (uint8_t)1); // store by object hash - auto k3 = std::make_tuple('h', recSig.GetHash()); + auto k3 = std::make_tuple(std::string("rs_h"), recSig.GetHash()); batch.Write(k3, std::make_pair(recSig.llmqType, recSig.id)); // store by signHash auto signHash = llmq::utils::BuildSignHash(recSig); - auto k4 = std::make_tuple('s', signHash); + auto k4 = std::make_tuple(std::string("rs_s"), signHash); batch.Write(k4, (uint8_t)1); // remove the votedForId entry as we won't need it anymore - auto k5 = std::make_tuple('v', recSig.llmqType, recSig.id); + auto k5 = std::make_tuple(std::string("rs_v"), recSig.llmqType, recSig.id); batch.Erase(k5); // store by current time. Allows fast cleanup of old recSigs - auto k6 = std::make_tuple('t', (uint32_t)GetAdjustedTime(), recSig.llmqType, recSig.id); + auto k6 = std::make_tuple(std::string("rs_t"), (uint32_t)GetAdjustedTime(), recSig.llmqType, recSig.id); batch.Write(k6, (uint8_t)1); db.WriteBatch(batch); @@ -166,34 +157,9 @@ void CRecoveredSigsDb::WriteRecoveredSig(const llmq::CRecoveredSig& recSig) int64_t t = GetTimeMillis(); LOCK(cs); - hasSigForIdCache[std::make_pair((Consensus::LLMQType)recSig.llmqType, recSig.id)] = std::make_pair(true, t); - hasSigForSessionCache[signHash] = std::make_pair(true, t); - hasSigForHashCache[recSig.GetHash()] = std::make_pair(true, t); - } -} - -template -static void TruncateCacheMap(std::unordered_map, H>& m, size_t maxSize, size_t truncateThreshold) -{ - typedef typename std::unordered_map, H> Map; - typedef typename Map::iterator Iterator; - - if (m.size() <= truncateThreshold) { - return; - } - - std::vector vec; - vec.reserve(m.size()); - for (auto it = m.begin(); it != m.end(); ++it) { - vec.emplace_back(it); - } - // sort by last access time (descending order) - std::sort(vec.begin(), vec.end(), [](const Iterator& it1, const Iterator& it2) { - return it1->second.second > it2->second.second; - }); - - for (size_t i = maxSize; i < vec.size(); i++) { - m.erase(vec[i]); + hasSigForIdCache.insert(std::make_pair((Consensus::LLMQType)recSig.llmqType, recSig.id), true); + hasSigForSessionCache.insert(signHash, true); + hasSigForHashCache.insert(recSig.GetHash(), true); } } @@ -202,8 +168,8 @@ void CRecoveredSigsDb::CleanupOldRecoveredSigs(int64_t maxAge) std::unique_ptr pcursor(db.NewIterator()); static const uint256 maxUint256 = uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - auto start = std::make_tuple('t', (uint32_t)0, (uint8_t)0, uint256()); - auto end = std::make_tuple('t', (uint32_t)(GetAdjustedTime() - maxAge), (uint8_t)255, maxUint256); + auto start = std::make_tuple(std::string("rs_t"), (uint32_t)0, (uint8_t)0, uint256()); + auto end = std::make_tuple(std::string("rs_t"), (uint32_t)(GetAdjustedTime() - maxAge), (uint8_t)255, maxUint256); pcursor->Seek(start); std::vector> toDelete; @@ -241,11 +207,11 @@ void CRecoveredSigsDb::CleanupOldRecoveredSigs(int64_t maxAge) auto signHash = llmq::utils::BuildSignHash(recSig); - auto k1 = std::make_tuple('r', recSig.llmqType, recSig.id); - auto k2 = std::make_tuple('r', recSig.llmqType, recSig.id, recSig.msgHash); - auto k3 = std::make_tuple('h', recSig.GetHash()); - auto k4 = std::make_tuple('s', signHash); - auto k5 = std::make_tuple('v', recSig.llmqType, recSig.id); + auto k1 = std::make_tuple(std::string("rs_r"), recSig.llmqType, recSig.id); + auto k2 = std::make_tuple(std::string("rs_r"), recSig.llmqType, recSig.id, recSig.msgHash); + auto k3 = std::make_tuple(std::string("rs_h"), recSig.GetHash()); + auto k4 = std::make_tuple(std::string("rs_s"), signHash); + auto k5 = std::make_tuple(std::string("rs_v"), recSig.llmqType, recSig.id); batch.Erase(k1); batch.Erase(k2); batch.Erase(k3); @@ -256,10 +222,6 @@ void CRecoveredSigsDb::CleanupOldRecoveredSigs(int64_t maxAge) hasSigForSessionCache.erase(signHash); hasSigForHashCache.erase(recSig.GetHash()); } - - TruncateCacheMap(hasSigForIdCache, MAX_CACHE_SIZE, MAX_CACHE_TRUNCATE_THRESHOLD); - TruncateCacheMap(hasSigForSessionCache, MAX_CACHE_SIZE, MAX_CACHE_TRUNCATE_THRESHOLD); - TruncateCacheMap(hasSigForHashCache, MAX_CACHE_SIZE, MAX_CACHE_TRUNCATE_THRESHOLD); } for (auto& e : toDelete2) { @@ -271,25 +233,25 @@ void CRecoveredSigsDb::CleanupOldRecoveredSigs(int64_t maxAge) bool CRecoveredSigsDb::HasVotedOnId(Consensus::LLMQType llmqType, const uint256& id) { - auto k = std::make_tuple('v', (uint8_t)llmqType, id); + auto k = std::make_tuple(std::string("rs_v"), (uint8_t)llmqType, id); return db.Exists(k); } bool CRecoveredSigsDb::GetVoteForId(Consensus::LLMQType llmqType, const uint256& id, uint256& msgHashRet) { - auto k = std::make_tuple('v', (uint8_t)llmqType, id); + auto k = std::make_tuple(std::string("rs_v"), (uint8_t)llmqType, id); return db.Read(k, msgHashRet); } void CRecoveredSigsDb::WriteVoteForId(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) { - auto k = std::make_tuple('v', (uint8_t)llmqType, id); + auto k = std::make_tuple(std::string("rs_v"), (uint8_t)llmqType, id); db.Write(k, msgHash); } ////////////////// -CSigningManager::CSigningManager(bool fMemory) : db(fMemory) +CSigningManager::CSigningManager(CDBWrapper& llmqDb, bool fMemory) : db(llmqDb) { } @@ -659,6 +621,16 @@ bool CSigningManager::IsConflicting(Consensus::LLMQType llmqType, const uint256& return false; } +bool CSigningManager::HasVotedOnId(Consensus::LLMQType llmqType, const uint256& id) +{ + return db.HasVotedOnId(llmqType, id); +} + +bool CSigningManager::GetVoteForId(Consensus::LLMQType llmqType, const uint256& id, uint256& msgHashRet) +{ + return db.GetVoteForId(llmqType, id, msgHashRet); +} + CQuorumCPtr CSigningManager::SelectQuorumForSigning(Consensus::LLMQType llmqType, int signHeight, const uint256& selectionHash) { auto& llmqParams = Params().GetConsensus().llmqs.at(llmqType); diff --git a/src/llmq/quorums_signing.h b/src/llmq/quorums_signing.h index d4616d683f30c..a68bded653b3f 100644 --- a/src/llmq/quorums_signing.h +++ b/src/llmq/quorums_signing.h @@ -12,6 +12,7 @@ #include "net.h" #include "saltedhasher.h" #include "sync.h" +#include "unordered_lru_cache.h" #include @@ -69,19 +70,16 @@ class CRecoveredSig class CRecoveredSigsDb { - static const size_t MAX_CACHE_SIZE = 30000; - static const size_t MAX_CACHE_TRUNCATE_THRESHOLD = 50000; - private: - CDBWrapper db; + CDBWrapper& db; RecursiveMutex cs; - std::unordered_map, std::pair, StaticSaltedHasher> hasSigForIdCache; - std::unordered_map, StaticSaltedHasher> hasSigForSessionCache; - std::unordered_map, StaticSaltedHasher> hasSigForHashCache; + unordered_lru_cache, bool, StaticSaltedHasher, 30000> hasSigForIdCache; + unordered_lru_cache hasSigForSessionCache; + unordered_lru_cache hasSigForHashCache; public: - CRecoveredSigsDb(bool fMemory); + CRecoveredSigsDb(CDBWrapper& _db); bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash); bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id); @@ -136,7 +134,7 @@ class CSigningManager std::vector recoveredSigsListeners; public: - CSigningManager(bool fMemory); + CSigningManager(CDBWrapper& llmqDb, bool fMemory); bool AlreadyHave(const CInv& inv); bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret); @@ -163,6 +161,8 @@ class CSigningManager bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id); bool HasRecoveredSigForSession(const uint256& signHash); bool IsConflicting(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash); + bool HasVotedOnId(Consensus::LLMQType llmqType, const uint256& id); + bool GetVoteForId(Consensus::LLMQType llmqType, const uint256& id, uint256& msgHashRet); CQuorumCPtr SelectQuorumForSigning(Consensus::LLMQType llmqType, int signHeight, const uint256& selectionHash); // Verifies a recovered sig that was signed while the chain tip was at signedAtTip bool VerifyRecoveredSig(Consensus::LLMQType llmqType, int signedAtHeight, const uint256& id, const uint256& msgHash, const CBLSSignature& sig);