mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
refactor: migrate some Dash code to use ChainstateManager::ProcessTransaction
This commit is contained in:
parent
c8571c0956
commit
0073b66aaa
@ -793,7 +793,7 @@ bool CCoinJoinClientManager::CheckAutomaticBackup()
|
||||
//
|
||||
// Passively run mixing in the background to mix funds based on the given configuration.
|
||||
//
|
||||
bool CCoinJoinClientSession::DoAutomaticDenominating(CChainState& active_chainstate, CConnman& connman, CTxMemPool& mempool, bool fDryRun)
|
||||
bool CCoinJoinClientSession::DoAutomaticDenominating(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool, bool fDryRun)
|
||||
{
|
||||
if (m_is_masternode) return false; // no client-side mixing on masternodes
|
||||
if (nState != POOL_STATE_IDLE) return false;
|
||||
@ -946,7 +946,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CChainState& active_chainst
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!CoinJoin::IsCollateralValid(active_chainstate, mempool, CTransaction(txMyCollateral))) {
|
||||
if (!CoinJoin::IsCollateralValid(chainman, mempool, CTransaction(txMyCollateral))) {
|
||||
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::DoAutomaticDenominating -- invalid collateral, recreating...\n");
|
||||
if (!CreateCollateralTransaction(txMyCollateral, strReason)) {
|
||||
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::DoAutomaticDenominating -- create collateral error: %s\n", strReason);
|
||||
@ -973,7 +973,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CChainState& active_chainst
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCoinJoinClientManager::DoAutomaticDenominating(CChainState& active_chainstate, CConnman& connman, CTxMemPool& mempool, bool fDryRun)
|
||||
bool CCoinJoinClientManager::DoAutomaticDenominating(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool, bool fDryRun)
|
||||
{
|
||||
if (m_is_masternode) return false; // no client-side mixing on masternodes
|
||||
if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return false;
|
||||
@ -1016,7 +1016,7 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(CChainState& active_chainst
|
||||
return false;
|
||||
}
|
||||
|
||||
fResult &= session.DoAutomaticDenominating(active_chainstate, connman, mempool, fDryRun);
|
||||
fResult &= session.DoAutomaticDenominating(chainman, connman, mempool, fDryRun);
|
||||
}
|
||||
|
||||
return fResult;
|
||||
@ -1864,7 +1864,7 @@ void CCoinJoinClientQueueManager::DoMaintenance()
|
||||
CheckQueue();
|
||||
}
|
||||
|
||||
void CCoinJoinClientManager::DoMaintenance(CChainState& active_chainstate, CConnman& connman, CTxMemPool& mempool)
|
||||
void CCoinJoinClientManager::DoMaintenance(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool)
|
||||
{
|
||||
if (!CCoinJoinClientOptions::IsEnabled()) return;
|
||||
if (m_is_masternode) return; // no client-side mixing on masternodes
|
||||
@ -1878,7 +1878,7 @@ void CCoinJoinClientManager::DoMaintenance(CChainState& active_chainstate, CConn
|
||||
CheckTimeout();
|
||||
ProcessPendingDsaRequest(connman);
|
||||
if (nDoAutoNextRun == nTick) {
|
||||
DoAutomaticDenominating(active_chainstate, connman, mempool);
|
||||
DoAutomaticDenominating(chainman, connman, mempool);
|
||||
nDoAutoNextRun = nTick + COINJOIN_AUTO_TIMEOUT_MIN + GetRandInt(COINJOIN_AUTO_TIMEOUT_MAX - COINJOIN_AUTO_TIMEOUT_MIN);
|
||||
}
|
||||
}
|
||||
@ -1930,7 +1930,7 @@ void CoinJoinWalletManager::DoMaintenance()
|
||||
{
|
||||
LOCK(cs_wallet_manager_map);
|
||||
for (auto& [_, clientman] : m_wallet_manager_map) {
|
||||
clientman->DoMaintenance(m_chainstate, m_connman, m_mempool);
|
||||
clientman->DoMaintenance(m_chainman, m_connman, m_mempool);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,10 @@ class CCoinJoinClientQueueManager;
|
||||
class CConnman;
|
||||
class CDeterministicMN;
|
||||
class CDeterministicMNManager;
|
||||
class CNode;
|
||||
class ChainstateManager;
|
||||
class CMasternodeMetaMan;
|
||||
class CMasternodeSync;
|
||||
class CNode;
|
||||
class CoinJoinWalletManager;
|
||||
class CTxMemPool;
|
||||
|
||||
@ -74,9 +75,9 @@ public:
|
||||
using wallet_name_cjman_map = std::map<const std::string, std::unique_ptr<CCoinJoinClientManager>>;
|
||||
|
||||
public:
|
||||
CoinJoinWalletManager(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
|
||||
CoinJoinWalletManager(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman, const CTxMemPool& mempool,
|
||||
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode)
|
||||
: m_chainstate(chainstate), m_connman(connman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mempool(mempool), m_mn_sync(mn_sync),
|
||||
: m_chainman(chainman), m_connman(connman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mempool(mempool), m_mn_sync(mn_sync),
|
||||
m_queueman(queueman), m_is_masternode{is_masternode}
|
||||
{}
|
||||
|
||||
@ -112,11 +113,11 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
CChainState& m_chainstate;
|
||||
ChainstateManager& m_chainman;
|
||||
CConnman& m_connman;
|
||||
CDeterministicMNManager& m_dmnman;
|
||||
CMasternodeMetaMan& m_mn_metaman;
|
||||
CTxMemPool& m_mempool;
|
||||
const CTxMemPool& m_mempool;
|
||||
const CMasternodeSync& m_mn_sync;
|
||||
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
||||
|
||||
@ -202,7 +203,7 @@ public:
|
||||
bool GetMixingMasternodeInfo(CDeterministicMNCPtr& ret) const;
|
||||
|
||||
/// Passively run mixing in the background according to the configuration in settings
|
||||
bool DoAutomaticDenominating(CChainState& active_chainstate, CConnman& connman, CTxMemPool& mempool, bool fDryRun = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_coinjoin);
|
||||
bool DoAutomaticDenominating(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool, bool fDryRun = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_coinjoin);
|
||||
|
||||
/// As a client, submit part of a future mixing transaction to a Masternode to start the process
|
||||
bool SubmitDenominate(CConnman& connman);
|
||||
@ -310,7 +311,7 @@ public:
|
||||
bool GetMixingMasternodesInfo(std::vector<CDeterministicMNCPtr>& vecDmnsRet) const EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
|
||||
/// Passively run mixing in the background according to the configuration in settings
|
||||
bool DoAutomaticDenominating(CChainState& active_chainstate, CConnman& connman, CTxMemPool& mempool, bool fDryRun = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
bool DoAutomaticDenominating(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool, bool fDryRun = false) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
|
||||
bool TrySubmitDenominate(const CService& mnAddr, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
bool MarkAlreadyJoinedQueueAsTried(CCoinJoinQueue& dsq) const EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
@ -326,7 +327,7 @@ public:
|
||||
|
||||
void UpdatedBlockTip(const CBlockIndex* pindex);
|
||||
|
||||
void DoMaintenance(CChainState& active_chainstate, CConnman& connman, CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
void DoMaintenance(ChainstateManager& chainman, CConnman& connman, const CTxMemPool& mempool) EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
|
||||
void GetJsonInfo(UniValue& obj) const EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
|
||||
};
|
||||
|
@ -308,10 +308,10 @@ bool CCoinJoinBaseSession::IsValidInOuts(CChainState& active_chainstate, const C
|
||||
|
||||
// Responsibility for checking fee sanity is moved from the mempool to the client (BroadcastTransaction)
|
||||
// but CoinJoin still requires ATMP with fee sanity checks so we need to implement them separately
|
||||
bool ATMPIfSaneFee(CChainState& active_chainstate, CTxMemPool& pool, const CTransactionRef &tx, bool test_accept) {
|
||||
bool ATMPIfSaneFee(ChainstateManager& chainman, const CTransactionRef &tx, bool test_accept) {
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(active_chainstate, pool, tx, /* bypass_limits */ false, /* test_accept */ true);
|
||||
const MempoolAcceptResult result = chainman.ProcessTransaction(tx, /*test_accept=*/true);
|
||||
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
||||
/* Fetch fee and fast-fail if ATMP fails regardless */
|
||||
return false;
|
||||
@ -322,11 +322,11 @@ bool ATMPIfSaneFee(CChainState& active_chainstate, CTxMemPool& pool, const CTran
|
||||
/* Don't re-run ATMP if only doing test run */
|
||||
return true;
|
||||
}
|
||||
return AcceptToMemoryPool(active_chainstate, pool, tx, /* bypass_limits */ false, test_accept).m_result_type == MempoolAcceptResult::ResultType::VALID;
|
||||
return chainman.ProcessTransaction(tx, test_accept).m_result_type == MempoolAcceptResult::ResultType::VALID;
|
||||
}
|
||||
|
||||
// check to make sure the collateral provided by the client is valid
|
||||
bool CoinJoin::IsCollateralValid(CChainState& active_chainstate, CTxMemPool& mempool, const CTransaction& txCollateral)
|
||||
bool CoinJoin::IsCollateralValid(ChainstateManager& chainman, const CTxMemPool& mempool, const CTransaction& txCollateral)
|
||||
{
|
||||
if (txCollateral.vout.empty()) return false;
|
||||
if (txCollateral.nLockTime != 0) return false;
|
||||
@ -352,7 +352,7 @@ bool CoinJoin::IsCollateralValid(CChainState& active_chainstate, CTxMemPool& mem
|
||||
return false;
|
||||
}
|
||||
nValueIn += mempoolTx->vout[txin.prevout.n].nValue;
|
||||
} else if (GetUTXOCoin(active_chainstate, txin.prevout, coin)) {
|
||||
} else if (GetUTXOCoin(chainman.ActiveChainstate(), txin.prevout, coin)) {
|
||||
nValueIn += coin.out.nValue;
|
||||
} else {
|
||||
LogPrint(BCLog::COINJOIN, "CoinJoin::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString()); /* Continued */
|
||||
@ -370,8 +370,8 @@ bool CoinJoin::IsCollateralValid(CChainState& active_chainstate, CTxMemPool& mem
|
||||
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (!ATMPIfSaneFee(active_chainstate, mempool, MakeTransactionRef(txCollateral), /*test_accept=*/true)) {
|
||||
LogPrint(BCLog::COINJOIN, "CoinJoin::IsCollateralValid -- didn't pass AcceptToMemoryPool()\n");
|
||||
if (!ATMPIfSaneFee(chainman, MakeTransactionRef(txCollateral), /*test_accept=*/true)) {
|
||||
LogPrint(BCLog::COINJOIN, "CoinJoin::IsCollateralValid -- didn't pass ATMPIfSaneFee()\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class CChainState;
|
||||
class CConnman;
|
||||
class CBLSPublicKey;
|
||||
class CBlockIndex;
|
||||
class ChainstateManager;
|
||||
class CMasternodeSync;
|
||||
class CTxMemPool;
|
||||
class TxValidationState;
|
||||
@ -368,7 +369,7 @@ namespace CoinJoin
|
||||
constexpr CAmount GetMaxPoolAmount() { return COINJOIN_ENTRY_MAX_SIZE * vecStandardDenominations.front(); }
|
||||
|
||||
/// If the collateral is valid given by a client
|
||||
bool IsCollateralValid(CChainState& active_chainstate, CTxMemPool& mempool, const CTransaction& txCollateral);
|
||||
bool IsCollateralValid(ChainstateManager& chainman, const CTxMemPool& mempool, const CTransaction& txCollateral);
|
||||
|
||||
}
|
||||
|
||||
@ -402,7 +403,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
bool ATMPIfSaneFee(CChainState& active_chainstate, CTxMemPool& pool,
|
||||
const CTransactionRef &tx, bool test_accept = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
bool ATMPIfSaneFee(ChainstateManager& chainman, const CTransactionRef &tx, bool test_accept = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
#endif // BITCOIN_COINJOIN_COINJOIN_H
|
||||
|
@ -9,20 +9,20 @@
|
||||
#endif // ENABLE_WALLET
|
||||
#include <coinjoin/server.h>
|
||||
|
||||
CJContext::CJContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman,
|
||||
CJContext::CJContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman,
|
||||
CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
|
||||
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||
std::unique_ptr<PeerManager>& peerman, bool relay_txes) :
|
||||
dstxman{std::make_unique<CDSTXManager>()},
|
||||
#ifdef ENABLE_WALLET
|
||||
walletman{std::make_unique<CoinJoinWalletManager>(chainstate, connman, dmnman, mn_metaman, mempool, mn_sync,
|
||||
walletman{std::make_unique<CoinJoinWalletManager>(chainman, connman, dmnman, mn_metaman, mempool, mn_sync,
|
||||
queueman, /* is_masternode = */ mn_activeman != nullptr)},
|
||||
queueman{relay_txes
|
||||
? std::make_unique<CCoinJoinClientQueueManager>(connman, peerman, *walletman, dmnman, mn_metaman,
|
||||
mn_sync, /* is_masternode = */ mn_activeman != nullptr)
|
||||
: nullptr},
|
||||
#endif // ENABLE_WALLET
|
||||
server{std::make_unique<CCoinJoinServer>(chainstate, connman, dmnman, *dstxman, mn_metaman, mempool, mn_activeman,
|
||||
server{std::make_unique<CCoinJoinServer>(chainman, connman, dmnman, *dstxman, mn_metaman, mempool, mn_activeman,
|
||||
mn_sync, peerman)}
|
||||
{}
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CBlockPolicyEstimator;
|
||||
class CChainState;
|
||||
class CCoinJoinServer;
|
||||
class CConnman;
|
||||
class CDeterministicMNManager;
|
||||
class CDSTXManager;
|
||||
class ChainstateManager;
|
||||
class CMasternodeMetaMan;
|
||||
class CMasternodeSync;
|
||||
class CTxMemPool;
|
||||
@ -31,7 +31,7 @@ class CoinJoinWalletManager;
|
||||
struct CJContext {
|
||||
CJContext() = delete;
|
||||
CJContext(const CJContext&) = delete;
|
||||
CJContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman,
|
||||
CJContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman,
|
||||
CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CMasternodeSync& mn_sync, std::unique_ptr<PeerManager>& peerman, bool relay_txes);
|
||||
~CJContext();
|
||||
|
@ -331,8 +331,8 @@ void CCoinJoinServer::CommitFinalTransaction()
|
||||
// See if the transaction is valid
|
||||
TRY_LOCK(cs_main, lockMain);
|
||||
mempool.PrioritiseTransaction(hashTx, 0.1 * COIN);
|
||||
if (!lockMain || !ATMPIfSaneFee(m_chainstate, mempool, finalTransaction)) {
|
||||
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CommitFinalTransaction -- AcceptToMemoryPool() error: Transaction not valid\n");
|
||||
if (!lockMain || !ATMPIfSaneFee(m_chainman, finalTransaction)) {
|
||||
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CommitFinalTransaction -- ATMPIfSaneFee() error: Transaction not valid\n");
|
||||
WITH_LOCK(cs_coinjoin, SetNull());
|
||||
// not much we can do in this case, just notify clients
|
||||
RelayCompletedTransaction(ERR_INVALID_TX);
|
||||
@ -463,8 +463,8 @@ void CCoinJoinServer::ChargeRandomFees() const
|
||||
void CCoinJoinServer::ConsumeCollateral(const CTransactionRef& txref) const
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (!ATMPIfSaneFee(m_chainstate, mempool, txref, false /* bypass_limits */)) {
|
||||
LogPrint(BCLog::COINJOIN, "%s -- AcceptToMemoryPool failed\n", __func__);
|
||||
if (!ATMPIfSaneFee(m_chainman, txref)) {
|
||||
LogPrint(BCLog::COINJOIN, "%s -- ATMPIfSaneFee failed\n", __func__);
|
||||
} else {
|
||||
Assert(m_peerman)->RelayTransaction(txref->GetHash());
|
||||
LogPrint(BCLog::COINJOIN, "%s -- Collateral was consumed\n", __func__);
|
||||
@ -582,7 +582,7 @@ bool CCoinJoinServer::AddEntry(const CCoinJoinEntry& entry, PoolMessage& nMessag
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CoinJoin::IsCollateralValid(m_chainstate, mempool, *entry.txCollateral)) {
|
||||
if (!CoinJoin::IsCollateralValid(m_chainman, mempool, *entry.txCollateral)) {
|
||||
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- ERROR: collateral not valid!\n", __func__);
|
||||
nMessageIDRet = ERR_INVALID_COLLATERAL;
|
||||
return false;
|
||||
@ -616,7 +616,7 @@ bool CCoinJoinServer::AddEntry(const CCoinJoinEntry& entry, PoolMessage& nMessag
|
||||
}
|
||||
|
||||
bool fConsumeCollateral{false};
|
||||
if (!IsValidInOuts(m_chainstate, mempool, vin, entry.vecTxOut, nMessageIDRet, &fConsumeCollateral)) {
|
||||
if (!IsValidInOuts(m_chainman.ActiveChainstate(), mempool, vin, entry.vecTxOut, nMessageIDRet, &fConsumeCollateral)) {
|
||||
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- ERROR! IsValidInOuts() failed: %s\n", __func__, CoinJoin::GetMessageByID(nMessageIDRet).translated);
|
||||
if (fConsumeCollateral) {
|
||||
ConsumeCollateral(entry.txCollateral);
|
||||
@ -693,7 +693,7 @@ bool CCoinJoinServer::IsAcceptableDSA(const CCoinJoinAccept& dsa, PoolMessage& n
|
||||
}
|
||||
|
||||
// check collateral
|
||||
if (!fUnitTest && !CoinJoin::IsCollateralValid(m_chainstate, mempool, CTransaction(dsa.txCollateral))) {
|
||||
if (!fUnitTest && !CoinJoin::IsCollateralValid(m_chainman, mempool, CTransaction(dsa.txCollateral))) {
|
||||
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- collateral not valid!\n", __func__);
|
||||
nMessageIDRet = ERR_INVALID_COLLATERAL;
|
||||
return false;
|
||||
|
@ -10,11 +10,11 @@
|
||||
#include <protocol.h>
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CChainState;
|
||||
class CCoinJoinServer;
|
||||
class CDataStream;
|
||||
class CDeterministicMNManager;
|
||||
class CDSTXManager;
|
||||
class ChainstateManager;
|
||||
class CMasternodeMetaMan;
|
||||
class CNode;
|
||||
class CTxMemPool;
|
||||
@ -27,7 +27,7 @@ class UniValue;
|
||||
class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager
|
||||
{
|
||||
private:
|
||||
CChainState& m_chainstate;
|
||||
ChainstateManager& m_chainman;
|
||||
CConnman& connman;
|
||||
CDeterministicMNManager& m_dmnman;
|
||||
CDSTXManager& m_dstxman;
|
||||
@ -90,11 +90,11 @@ private:
|
||||
void SetNull() override EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);
|
||||
|
||||
public:
|
||||
explicit CCoinJoinServer(CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||
explicit CCoinJoinServer(ChainstateManager& chainman, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||
CDSTXManager& dstxman, CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
|
||||
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||
std::unique_ptr<PeerManager>& peerman) :
|
||||
m_chainstate(chainstate),
|
||||
m_chainman(chainman),
|
||||
connman(_connman),
|
||||
m_dmnman(dmnman),
|
||||
m_dstxman(dstxman),
|
||||
|
@ -1891,7 +1891,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
node.llmq_ctx->Stop();
|
||||
}
|
||||
node.llmq_ctx.reset();
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman,
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainman, *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman,
|
||||
*node.mempool, node.mn_activeman.get(), *node.mn_sync, node.peerman, /* unit_tests = */ false, /* wipe = */ fReset || fReindexChainState);
|
||||
// Enable CMNHFManager::{Process, Undo}Block
|
||||
node.mnhf_manager->ConnectManagers(node.chainman.get(), node.llmq_ctx->qman.get());
|
||||
@ -2153,7 +2153,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
|
||||
// ********************************************************* Step 7c: Setup CoinJoin
|
||||
|
||||
node.cj_ctx = std::make_unique<CJContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
|
||||
node.cj_ctx = std::make_unique<CJContext>(chainman, *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
|
||||
node.mn_activeman.get(), *node.mn_sync, node.peerman, !ignores_incoming_txs);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <llmq/context.h>
|
||||
|
||||
#include <dbwrapper.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <llmq/blockprocessor.h>
|
||||
#include <llmq/chainlocks.h>
|
||||
@ -17,7 +18,7 @@
|
||||
#include <llmq/signing.h>
|
||||
#include <llmq/signing_shares.h>
|
||||
|
||||
LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||
LLMQContext::LLMQContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman,
|
||||
CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CMasternodeSync& mn_sync, const std::unique_ptr<PeerManager>& peerman, bool unit_tests,
|
||||
@ -25,28 +26,30 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
|
||||
is_masternode{mn_activeman != nullptr},
|
||||
bls_worker{std::make_shared<CBLSWorker>()},
|
||||
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
|
||||
quorum_block_processor{std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, dmnman, evo_db)},
|
||||
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman,
|
||||
quorum_block_processor{std::make_unique<llmq::CQuorumBlockProcessor>(chainman.ActiveChainstate(), dmnman, evo_db)},
|
||||
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainman.ActiveChainstate(), connman, dmnman, *dkg_debugman,
|
||||
mn_metaman, *quorum_block_processor, mn_activeman, sporkman,
|
||||
peerman, unit_tests, wipe)},
|
||||
qman{std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db,
|
||||
qman{std::make_unique<llmq::CQuorumManager>(*bls_worker, chainman.ActiveChainstate(), connman, dmnman, *qdkgsman, evo_db,
|
||||
*quorum_block_processor, mn_activeman, mn_sync, sporkman, unit_tests,
|
||||
wipe)},
|
||||
sigman{std::make_unique<llmq::CSigningManager>(connman, mn_activeman, chainstate, *qman, peerman, unit_tests, wipe)},
|
||||
sigman{std::make_unique<llmq::CSigningManager>(connman, mn_activeman, chainman.ActiveChainstate(), *qman, peerman, unit_tests, wipe)},
|
||||
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, mn_activeman, *qman, sporkman, peerman)},
|
||||
clhandler{[&]() -> llmq::CChainLocksHandler* const {
|
||||
assert(llmq::chainLocksHandler == nullptr);
|
||||
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainstate, *qman, *sigman, *shareman,
|
||||
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainman.ActiveChainstate(), *qman, *sigman, *shareman,
|
||||
sporkman, mempool, mn_sync, is_masternode);
|
||||
return llmq::chainLocksHandler.get();
|
||||
}()},
|
||||
isman{[&]() -> llmq::CInstantSendManager* const {
|
||||
assert(llmq::quorumInstantSendManager == nullptr);
|
||||
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(*llmq::chainLocksHandler, chainstate, connman, *qman, *sigman, *shareman, sporkman, mempool, mn_sync, peerman, is_masternode, unit_tests, wipe);
|
||||
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(
|
||||
*llmq::chainLocksHandler, chainman.ActiveChainstate(), connman, *qman, *sigman, *shareman, sporkman,
|
||||
mempool, mn_sync, peerman, is_masternode, unit_tests, wipe);
|
||||
return llmq::quorumInstantSendManager.get();
|
||||
}()},
|
||||
ehfSignalsHandler{
|
||||
std::make_unique<llmq::CEHFSignalsHandler>(chainstate, mnhfman, *sigman, *shareman, mempool, *qman)}
|
||||
std::make_unique<llmq::CEHFSignalsHandler>(chainman, mnhfman, *sigman, *shareman, *qman)}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CBLSWorker;
|
||||
class CChainState;
|
||||
class CConnman;
|
||||
class ChainstateManager;
|
||||
class CDeterministicMNManager;
|
||||
class CDBWrapper;
|
||||
class CEvoDB;
|
||||
@ -40,7 +40,7 @@ private:
|
||||
public:
|
||||
LLMQContext() = delete;
|
||||
LLMQContext(const LLMQContext&) = delete;
|
||||
LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||
LLMQContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool,
|
||||
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe);
|
||||
|
@ -15,19 +15,17 @@
|
||||
#include <deploymentstatus.h>
|
||||
#include <index/txindex.h> // g_txindex
|
||||
#include <primitives/transaction.h>
|
||||
#include <txmempool.h>
|
||||
#include <validation.h>
|
||||
|
||||
namespace llmq {
|
||||
|
||||
|
||||
CEHFSignalsHandler::CEHFSignalsHandler(CChainState& chainstate, CMNHFManager& mnhfman, CSigningManager& sigman,
|
||||
CSigSharesManager& shareman, CTxMemPool& mempool, const CQuorumManager& qman) :
|
||||
chainstate(chainstate),
|
||||
CEHFSignalsHandler::CEHFSignalsHandler(ChainstateManager& chainman, CMNHFManager& mnhfman, CSigningManager& sigman,
|
||||
CSigSharesManager& shareman, const CQuorumManager& qman) :
|
||||
m_chainman(chainman),
|
||||
mnhfman(mnhfman),
|
||||
sigman(sigman),
|
||||
shareman(shareman),
|
||||
mempool(mempool),
|
||||
qman(qman)
|
||||
{
|
||||
sigman.RegisterRecoveredSigsListener(this);
|
||||
@ -77,7 +75,7 @@ void CEHFSignalsHandler::trySignEHFSignal(int bit, const CBlockIndex* const pind
|
||||
return;
|
||||
}
|
||||
|
||||
const auto quorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), chainstate.m_chain, qman, requestId);
|
||||
const auto quorum = llmq::SelectQuorumForSigning(llmq_params_opt.value(), m_chainman.ActiveChain(), qman, requestId);
|
||||
if (!quorum) {
|
||||
LogPrintf("CEHFSignalsHandler::trySignEHFSignal no quorum for id=%s\n", requestId.ToString());
|
||||
return;
|
||||
@ -103,7 +101,7 @@ MessageProcessingResult CEHFSignalsHandler::HandleNewRecoveredSig(const CRecover
|
||||
}
|
||||
|
||||
MessageProcessingResult ret;
|
||||
const auto ehfSignals = mnhfman.GetSignalsStage(WITH_LOCK(cs_main, return chainstate.m_chain.Tip()));
|
||||
const auto ehfSignals = mnhfman.GetSignalsStage(WITH_LOCK(cs_main, return m_chainman.ActiveTip()));
|
||||
MNHFTxPayload mnhfPayload;
|
||||
for (const auto& deployment : Params().GetConsensus().vDeployments) {
|
||||
// skip deployments that do not use dip0023 or that have already been mined
|
||||
@ -126,7 +124,7 @@ MessageProcessingResult CEHFSignalsHandler::HandleNewRecoveredSig(const CRecover
|
||||
CTransactionRef tx_to_sent = MakeTransactionRef(std::move(tx));
|
||||
LogPrintf("CEHFSignalsHandler::HandleNewRecoveredSig Special EHF TX is created hash=%s\n", tx_to_sent->GetHash().ToString());
|
||||
LOCK(cs_main);
|
||||
const MempoolAcceptResult result = AcceptToMemoryPool(chainstate, mempool, tx_to_sent, /* bypass_limits */ false);
|
||||
const MempoolAcceptResult result = m_chainman.ProcessTransaction(tx_to_sent);
|
||||
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
|
||||
ret.m_transactions.push_back(tx_to_sent->GetHash());
|
||||
} else {
|
||||
|
@ -10,9 +10,8 @@
|
||||
#include <set>
|
||||
|
||||
class CBlockIndex;
|
||||
class CChainState;
|
||||
class ChainstateManager;
|
||||
class CMNHFManager;
|
||||
class CTxMemPool;
|
||||
|
||||
namespace llmq
|
||||
{
|
||||
@ -23,11 +22,10 @@ class CSigningManager;
|
||||
class CEHFSignalsHandler : public CRecoveredSigsListener
|
||||
{
|
||||
private:
|
||||
CChainState& chainstate;
|
||||
ChainstateManager& m_chainman;
|
||||
CMNHFManager& mnhfman;
|
||||
CSigningManager& sigman;
|
||||
CSigSharesManager& shareman;
|
||||
CTxMemPool& mempool;
|
||||
const CQuorumManager& qman;
|
||||
|
||||
/**
|
||||
@ -36,8 +34,8 @@ private:
|
||||
mutable Mutex cs;
|
||||
std::set<uint256> ids GUARDED_BY(cs);
|
||||
public:
|
||||
explicit CEHFSignalsHandler(CChainState& chainstate, CMNHFManager& mnhfman, CSigningManager& sigman,
|
||||
CSigSharesManager& shareman, CTxMemPool& mempool, const CQuorumManager& qman);
|
||||
explicit CEHFSignalsHandler(ChainstateManager& chainman, CMNHFManager& mnhfman, CSigningManager& sigman,
|
||||
CSigSharesManager& shareman, const CQuorumManager& qman);
|
||||
|
||||
~CEHFSignalsHandler();
|
||||
|
||||
|
@ -134,10 +134,10 @@ static RPCHelpMan coinjoin_start()
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Mixing has been started already.");
|
||||
}
|
||||
|
||||
const ChainstateManager& chainman = EnsureChainman(node);
|
||||
ChainstateManager& chainman = EnsureChainman(node);
|
||||
CTxMemPool& mempool = EnsureMemPool(node);
|
||||
CConnman& connman = EnsureConnman(node);
|
||||
bool result = cj_clientman->DoAutomaticDenominating(chainman.ActiveChainstate(), connman, mempool);
|
||||
bool result = cj_clientman->DoAutomaticDenominating(chainman, connman, mempool);
|
||||
return "Mixing " + (result ? "started successfully" : ("start failed: " + cj_clientman->GetStatuses().original + ", will retry"));
|
||||
},
|
||||
};
|
||||
|
@ -110,12 +110,12 @@ void DashTestSetup(NodeContext& node, const CChainParams& chainparams)
|
||||
node.dmnman = std::make_unique<CDeterministicMNManager>(chainstate, *node.connman, *node.evodb);
|
||||
node.mempool->ConnectManagers(node.dmnman.get());
|
||||
|
||||
node.cj_ctx = std::make_unique<CJContext>(chainstate, *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
|
||||
node.cj_ctx = std::make_unique<CJContext>(*node.chainman, *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
|
||||
/* mn_activeman = */ nullptr, *node.mn_sync, node.peerman, /* relay_txes = */ true);
|
||||
#ifdef ENABLE_WALLET
|
||||
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
||||
#endif // ENABLE_WALLET
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(*node.chainman, *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
||||
/* mn_activeman = */ nullptr, *node.mn_sync, node.peerman, /* unit_tests = */ true, /* wipe = */ false);
|
||||
Assert(node.mnhf_manager)->ConnectManagers(node.chainman.get(), node.llmq_ctx->qman.get());
|
||||
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor), *node.chainman,
|
||||
|
Loading…
Reference in New Issue
Block a user