Skip to content

Commit

Permalink
refactor: including of dbwrapper moved to cpp files
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Nov 14, 2023
1 parent 929209a commit 6a39a73
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/llmq/dkgsessionmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <evo/deterministicmns.h>

#include <chainparams.h>
#include <dbwrapper.h>
#include <net_processing.h>
#include <spork.h>
#include <util/irange.h>
Expand Down
1 change: 1 addition & 0 deletions src/llmq/dkgsessionmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class CBlockIndex;
class CChainState;
class CDBWrapper;
class CDKGDebugManager;
class CSporkManager;
class PeerManager;
Expand Down
8 changes: 8 additions & 0 deletions src/llmq/instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <bls/bls_batchverifier.h>
#include <chainparams.h>
#include <consensus/validation.h>
#include <dbwrapper.h>
#include <index/txindex.h>
#include <masternode/sync.h>
#include <net_processing.h>
Expand Down Expand Up @@ -57,6 +58,13 @@ uint256 CInstantSendLock::GetRequestId() const
////////////////


CInstantSendDb::CInstantSendDb(bool unitTests, bool fWipe) :
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/isdb"), 32 << 20, unitTests, fWipe))
{
}

CInstantSendDb::~CInstantSendDb() = default;

void CInstantSendDb::Upgrade(const CTxMemPool& mempool)
{
LOCK2(cs_main, mempool.cs);
Expand Down
7 changes: 3 additions & 4 deletions src/llmq/instantsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <chain.h>
#include <coins.h>
#include <dbwrapper.h>
#include <primitives/transaction.h>
#include <threadinterrupt.h>
#include <txmempool.h>
Expand All @@ -22,6 +21,7 @@
#include <unordered_set>

class CChainState;
class CDBWrapper;
class CMasternodeSync;
class CSporkManager;
class PeerManager;
Expand Down Expand Up @@ -121,9 +121,8 @@ class CInstantSendDb


public:
explicit CInstantSendDb(bool unitTests, bool fWipe) :
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/isdb"), 32 << 20, unitTests, fWipe))
{}
explicit CInstantSendDb(bool unitTests, bool fWipe);
~CInstantSendDb();

void Upgrade(const CTxMemPool& mempool) LOCKS_EXCLUDED(cs_db);

Expand Down
10 changes: 10 additions & 0 deletions src/llmq/signing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
#include <bls/bls_batchverifier.h>
#include <chainparams.h>
#include <cxxtimer.hpp>
#include <dbwrapper.h>
#include <masternode/node.h>
#include <net_processing.h>
#include <netmessagemaker.h>
#include <scheduler.h>
#include <streams.h>
#include <util/irange.h>
#include <util/time.h>
#include <util/underlying.h>
Expand All @@ -39,6 +41,14 @@ UniValue CRecoveredSig::ToJson() const
}


CRecoveredSigsDb::CRecoveredSigsDb(bool fMemory, bool fWipe) :
db(std::make_unique<CDBWrapper>(fMemory ? "" : (GetDataDir() / "llmq/recsigdb"), 8 << 20, fMemory, fWipe))
{
MigrateRecoveredSigs();
}

CRecoveredSigsDb::~CRecoveredSigsDb() = default;

void CRecoveredSigsDb::MigrateRecoveredSigs()
{
if (!db->IsEmpty()) return;
Expand Down
11 changes: 5 additions & 6 deletions src/llmq/signing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <unordered_lru_cache.h>

#include <consensus/params.h>
#include <dbwrapper.h>
#include <random.h>
#include <saltedhasher.h>
#include <sync.h>
Expand All @@ -18,6 +17,9 @@
#include <unordered_map>

class CConnman;
class CDataStream;
class CDBBatch;
class CDBWrapper;
class CInv;
class CNode;
class PeerManager;
Expand Down Expand Up @@ -115,11 +117,8 @@ class CRecoveredSigsDb
mutable unordered_lru_cache<uint256, bool, StaticSaltedHasher, 30000> hasSigForHashCache GUARDED_BY(cs);

public:
explicit CRecoveredSigsDb(bool fMemory, bool fWipe) :
db(std::make_unique<CDBWrapper>(fMemory ? "" : (GetDataDir() / "llmq/recsigdb"), 8 << 20, fMemory, fWipe))
{
MigrateRecoveredSigs();
}
explicit CRecoveredSigsDb(bool fMemory, bool fWipe);
~CRecoveredSigsDb();

bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) const;
bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id) const;
Expand Down
1 change: 0 additions & 1 deletion src/llmq/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <consensus/params.h>

#include <dbwrapper.h>
#include <random.h>
#include <set>
#include <sync.h>
Expand Down
4 changes: 2 additions & 2 deletions src/test/evo_instantsend_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/util/setup_common.h>

#include <llmq/instantsend.h>

#include <test/util/setup_common.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(evo_instantsend_tests, BasicTestingSetup)
Expand Down

0 comments on commit 6a39a73

Please sign in to comment.