Use llmqDb for CRecoveredSigsDb

Instead of creating its own CDBWrapper internally.
This commit is contained in:
Alexander Block 2019-03-08 17:30:34 +01:00
parent b2cd1db406
commit 61e10f6512
3 changed files with 8 additions and 8 deletions

View File

@ -33,7 +33,7 @@ void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests)
quorumDKGSessionManager = new CDKGSessionManager(*llmqDb, blsWorker); quorumDKGSessionManager = new CDKGSessionManager(*llmqDb, blsWorker);
quorumManager = new CQuorumManager(evoDb, blsWorker, *quorumDKGSessionManager); quorumManager = new CQuorumManager(evoDb, blsWorker, *quorumDKGSessionManager);
quorumSigSharesManager = new CSigSharesManager(); quorumSigSharesManager = new CSigSharesManager();
quorumSigningManager = new CSigningManager(unitTests); quorumSigningManager = new CSigningManager(*llmqDb, unitTests);
chainLocksHandler = new CChainLocksHandler(scheduler); chainLocksHandler = new CChainLocksHandler(scheduler);
quorumInstantSendManager = new CInstantSendManager(scheduler); quorumInstantSendManager = new CInstantSendManager(scheduler);
} }

View File

@ -24,8 +24,8 @@ namespace llmq
CSigningManager* quorumSigningManager; CSigningManager* quorumSigningManager;
CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory) : CRecoveredSigsDb::CRecoveredSigsDb(CDBWrapper& _db) :
db(fMemory ? "" : (GetDataDir() / "llmq"), 1 << 20, fMemory) db(_db)
{ {
} }
@ -290,8 +290,8 @@ void CRecoveredSigsDb::WriteVoteForId(Consensus::LLMQType llmqType, const uint25
////////////////// //////////////////
CSigningManager::CSigningManager(bool fMemory) : CSigningManager::CSigningManager(CDBWrapper& llmqDb, bool fMemory) :
db(fMemory) db(llmqDb)
{ {
} }

View File

@ -72,7 +72,7 @@ class CRecoveredSigsDb
static const size_t MAX_CACHE_TRUNCATE_THRESHOLD = 50000; static const size_t MAX_CACHE_TRUNCATE_THRESHOLD = 50000;
private: private:
CDBWrapper db; CDBWrapper& db;
CCriticalSection cs; CCriticalSection cs;
std::unordered_map<std::pair<Consensus::LLMQType, uint256>, std::pair<bool, int64_t>, StaticSaltedHasher> hasSigForIdCache; std::unordered_map<std::pair<Consensus::LLMQType, uint256>, std::pair<bool, int64_t>, StaticSaltedHasher> hasSigForIdCache;
@ -80,7 +80,7 @@ private:
std::unordered_map<uint256, std::pair<bool, int64_t>, StaticSaltedHasher> hasSigForHashCache; std::unordered_map<uint256, std::pair<bool, int64_t>, StaticSaltedHasher> hasSigForHashCache;
public: public:
CRecoveredSigsDb(bool fMemory); CRecoveredSigsDb(CDBWrapper& _db);
bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash); bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash);
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id); bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id);
@ -136,7 +136,7 @@ private:
std::vector<CRecoveredSigsListener*> recoveredSigsListeners; std::vector<CRecoveredSigsListener*> recoveredSigsListeners;
public: public:
CSigningManager(bool fMemory); CSigningManager(CDBWrapper& llmqDb, bool fMemory);
bool AlreadyHave(const CInv& inv); bool AlreadyHave(const CInv& inv);
bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret); bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret);