Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ BITCOIN_CORE_H = \
coinjoin/coinjoin.h \
coinjoin/client.h \
coinjoin/common.h \
coinjoin/context.h \
coinjoin/options.h \
coinjoin/server.h \
coinjoin/util.h \
coinjoin/walletman.h \
coins.h \
common/bloom.h \
compat/assumptions.h \
Expand Down Expand Up @@ -292,6 +292,7 @@ BITCOIN_CORE_H = \
memusage.h \
merkleblock.h \
messagesigner.h \
msg_result.h \
net.h \
net_permissions.h \
net_processing.h \
Expand Down Expand Up @@ -485,8 +486,8 @@ libbitcoin_node_a_SOURCES = \
chainlock/clsig.cpp \
chainlock/signing.cpp \
coinjoin/coinjoin.cpp \
coinjoin/context.cpp \
coinjoin/server.cpp \
coinjoin/walletman.cpp \
consensus/tx_verify.cpp \
dbwrapper.cpp \
deploymentstatus.cpp \
Expand Down
38 changes: 6 additions & 32 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <masternode/meta.h>
#include <masternode/sync.h>
#include <net.h>
#include <net_processing.h>
#include <netmessagemaker.h>
#include <rpc/evo_util.h>
#include <shutdown.h>
Expand All @@ -39,14 +38,12 @@ using wallet::CoinType;
using wallet::CWallet;
using wallet::ReserveDestination;

MessageProcessingResult CCoinJoinClientQueueManager::ProcessMessage(NodeId from, CConnman& connman, PeerManager& peerman,
MessageProcessingResult CCoinJoinClientQueueManager::ProcessMessage(NodeId from, CConnman& connman,
std::string_view msg_type, CDataStream& vRecv)
{
if (msg_type != NetMsgType::DSQUEUE) {
return {};
}

if (m_is_masternode) return {};
if (!m_mn_sync.IsBlockchainSynced()) return {};

assert(m_mn_metaman.IsValid());
Expand Down Expand Up @@ -138,13 +135,12 @@ MessageProcessingResult CCoinJoinClientQueueManager::ProcessMessage(NodeId from,
WITH_LOCK(cs_vecqueue, vecCoinJoinQueue.push_back(dsq));
}
} // cs_ProcessDSQueue
peerman.RelayDSQ(dsq);
ret.m_dsq.push_back(dsq);
return ret;
}

void CCoinJoinClientManager::ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
{
if (m_is_masternode) return;
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;

Expand All @@ -169,21 +165,18 @@ void CCoinJoinClientManager::ProcessMessage(CNode& peer, CChainState& active_cha
CCoinJoinClientSession::CCoinJoinClientSession(const std::shared_ptr<CWallet>& wallet, CCoinJoinClientManager& clientman,
CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman,
bool is_masternode) :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing is_masternode is a good catch! we don't have wallets on masternodes

const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
m_wallet(wallet),
m_clientman(clientman),
m_dmnman(dmnman),
m_mn_metaman(mn_metaman),
m_mn_sync(mn_sync),
m_isman{isman},
m_queueman(queueman),
m_is_masternode{is_masternode}
m_queueman(queueman)
{}

void CCoinJoinClientSession::ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
{
if (m_is_masternode) return;
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;

Expand Down Expand Up @@ -386,8 +379,6 @@ bool CCoinJoinClientManager::GetMixingMasternodesInfo(std::vector<CDeterministic
//
bool CCoinJoinClientSession::CheckTimeout()
{
if (m_is_masternode) return false;

if (nState == POOL_STATE_IDLE) return false;

if (nState == POOL_STATE_ERROR) {
Expand Down Expand Up @@ -423,7 +414,6 @@ bool CCoinJoinClientSession::CheckTimeout()
void CCoinJoinClientManager::CheckTimeout()
{
AssertLockNotHeld(cs_deqsessions);
if (m_is_masternode) return;

if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return;

Expand All @@ -441,11 +431,6 @@ void CCoinJoinClientManager::CheckTimeout()
//
bool CCoinJoinClientSession::SendDenominate(const std::vector<std::pair<CTxDSIn, CTxOut> >& vecPSInOutPairsIn, CConnman& connman)
{
if (m_is_masternode) {
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::SendDenominate -- CoinJoin from a Masternode is not supported currently.\n");
return false;
}

if (CTransaction(txMyCollateral).IsNull()) {
WalletCJLogPrint(m_wallet, "CCoinJoinClient:SendDenominate -- CoinJoin collateral not set\n");
return false;
Expand Down Expand Up @@ -498,8 +483,6 @@ bool CCoinJoinClientSession::SendDenominate(const std::vector<std::pair<CTxDSIn,
// Process incoming messages from Masternode updating the progress of mixing
void CCoinJoinClientSession::ProcessPoolStateUpdate(CCoinJoinStatusUpdate psssup)
{
if (m_is_masternode) return;

// do not update state when mixing client state is one of these
if (nState == POOL_STATE_IDLE || nState == POOL_STATE_ERROR) return;

Expand Down Expand Up @@ -552,7 +535,6 @@ bool CCoinJoinClientSession::SignFinalTransaction(CNode& peer, CChainState& acti
{
if (!CCoinJoinClientOptions::IsEnabled()) return false;

if (m_is_masternode) return false;
if (!mixingMasternode) return false;

LOCK(m_wallet->cs_wallet);
Expand Down Expand Up @@ -682,8 +664,6 @@ bool CCoinJoinClientSession::SignFinalTransaction(CNode& peer, CChainState& acti
// mixing transaction was completed (failed or successful)
void CCoinJoinClientSession::CompletedTransaction(PoolMessage nMessageID)
{
if (m_is_masternode) return;

if (nMessageID == MSG_SUCCESS) {
m_clientman.UpdatedSuccessBlock();
keyHolderStorage.KeepAll();
Expand All @@ -699,7 +679,6 @@ void CCoinJoinClientSession::CompletedTransaction(PoolMessage nMessageID)

void CCoinJoinClientManager::UpdatedSuccessBlock()
{
if (m_is_masternode) return;
nCachedLastSuccessBlock = nCachedBlockHeight;
}

Expand Down Expand Up @@ -791,7 +770,6 @@ bool CCoinJoinClientManager::CheckAutomaticBackup()
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;

if (!m_mn_sync.IsBlockchainSynced()) {
Expand Down Expand Up @@ -972,7 +950,6 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(ChainstateManager& chainman
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;

if (!m_mn_sync.IsBlockchainSynced()) {
Expand Down Expand Up @@ -1001,7 +978,7 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(ChainstateManager& chainman
AssertLockNotHeld(cs_deqsessions);
LOCK(cs_deqsessions);
if (int(deqSessions.size()) < CCoinJoinClientOptions::GetSessions()) {
deqSessions.emplace_back(m_wallet, *this, m_dmnman, m_mn_metaman, m_mn_sync, m_isman, m_queueman, m_is_masternode);
deqSessions.emplace_back(m_wallet, *this, m_dmnman, m_mn_metaman, m_mn_sync, m_isman, m_queueman);
}
for (auto& session : deqSessions) {
if (!CheckAutomaticBackup()) return false;
Expand Down Expand Up @@ -1840,8 +1817,6 @@ void CCoinJoinClientManager::UpdatedBlockTip(const CBlockIndex* pindex)

void CCoinJoinClientQueueManager::DoMaintenance()
{
if (m_is_masternode) return; // no client-side mixing on masternodes

if (!m_mn_sync.IsBlockchainSynced() || ShutdownRequested()) return;

CheckQueue();
Expand All @@ -1850,7 +1825,6 @@ void CCoinJoinClientQueueManager::DoMaintenance()
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

if (!m_mn_sync.IsBlockchainSynced() || ShutdownRequested()) return;

Expand Down Expand Up @@ -1904,7 +1878,7 @@ void CoinJoinWalletManager::Add(const std::shared_ptr<CWallet>& wallet)
LOCK(cs_wallet_manager_map);
m_wallet_manager_map.try_emplace(wallet->GetName(),
std::make_unique<CCoinJoinClientManager>(wallet, m_dmnman, m_mn_metaman, m_mn_sync,
m_isman, m_queueman, m_is_masternode));
m_isman, m_queueman));
}

void CoinJoinWalletManager::DoMaintenance(CConnman& connman)
Expand Down
35 changes: 12 additions & 23 deletions src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <coinjoin/coinjoin.h>
#include <coinjoin/util.h>
#include <evo/types.h>
#include <msg_result.h>

#include <net_types.h>
#include <protocol.h>
Expand All @@ -29,7 +30,6 @@ class CMasternodeSync;
class CNode;
class CoinJoinWalletManager;
class CTxMemPool;
class PeerManager;

class UniValue;

Expand Down Expand Up @@ -77,15 +77,14 @@ class CoinJoinWalletManager {
public:
CoinJoinWalletManager(ChainstateManager& chainman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
const CTxMemPool& mempool, const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
m_chainman(chainman),
m_dmnman(dmnman),
m_mn_metaman(mn_metaman),
m_mempool(mempool),
m_mn_sync(mn_sync),
m_isman{isman},
m_queueman(queueman),
m_is_masternode{is_masternode}
m_queueman(queueman)
{}

~CoinJoinWalletManager() {
Expand Down Expand Up @@ -128,8 +127,6 @@ class CoinJoinWalletManager {
const llmq::CInstantSendManager& m_isman;
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;

const bool m_is_masternode;

mutable Mutex cs_wallet_manager_map;
wallet_name_cjman_map m_wallet_manager_map GUARDED_BY(cs_wallet_manager_map);
};
Expand All @@ -145,9 +142,6 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
const llmq::CInstantSendManager& m_isman;
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;

// Track node type
const bool m_is_masternode;

std::vector<COutPoint> vecOutPointLocked;

bilingual_str strLastMessage;
Expand Down Expand Up @@ -202,7 +196,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
explicit CCoinJoinClientSession(const std::shared_ptr<wallet::CWallet>& wallet, CCoinJoinClientManager& clientman,
CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode);
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman);

void ProcessMessage(CNode& peer, CChainState& active_chainstate, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);

Expand Down Expand Up @@ -239,20 +233,19 @@ class CCoinJoinClientQueueManager : public CCoinJoinBaseManager
const CMasternodeSync& m_mn_sync;

mutable Mutex cs_ProcessDSQueue;
const bool m_is_masternode;

public:
explicit CCoinJoinClientQueueManager(CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
bool is_masternode) :
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync) :
m_walletman(walletman),
m_dmnman(dmnman),
m_mn_metaman(mn_metaman),
m_mn_sync(mn_sync),
m_is_masternode{is_masternode} {};
m_mn_sync(mn_sync)
{
}

[[nodiscard]] MessageProcessingResult ProcessMessage(NodeId from, CConnman& connman, PeerManager& peerman,
std::string_view msg_type, CDataStream& vRecv)
[[nodiscard]] MessageProcessingResult ProcessMessage(NodeId from, CConnman& connman, std::string_view msg_type,
CDataStream& vRecv)
EXCLUSIVE_LOCKS_REQUIRED(!cs_vecqueue, !cs_ProcessDSQueue);
void DoMaintenance();
};
Expand All @@ -269,9 +262,6 @@ class CCoinJoinClientManager
const llmq::CInstantSendManager& m_isman;
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;

// Track node type
const bool m_is_masternode;

// Keep track of the used Masternodes
std::vector<COutPoint> vecMasternodesUsed;

Expand Down Expand Up @@ -304,14 +294,13 @@ class CCoinJoinClientManager
explicit CCoinJoinClientManager(const std::shared_ptr<wallet::CWallet>& wallet, CDeterministicMNManager& dmnman,
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
const llmq::CInstantSendManager& isman,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
m_wallet(wallet),
m_dmnman(dmnman),
m_mn_metaman(mn_metaman),
m_mn_sync(mn_sync),
m_isman{isman},
m_queueman(queueman),
m_is_masternode{is_masternode}
m_queueman(queueman)
{
}

Expand Down
25 changes: 0 additions & 25 deletions src/coinjoin/context.cpp

This file was deleted.

46 changes: 0 additions & 46 deletions src/coinjoin/context.h

This file was deleted.

Loading
Loading