11
11
#include < evo/deterministicmns.h>
12
12
#include < masternode/meta.h>
13
13
#include < masternode/sync.h>
14
- #include < net_processing .h>
14
+ #include < net .h>
15
15
#include < netmessagemaker.h>
16
16
#include < shutdown.h>
17
17
#include < util/check.h>
29
29
#include < memory>
30
30
#include < univalue.h>
31
31
32
- void CCoinJoinClientQueueManager::ProcessMessage (const CNode& peer, PeerManager& peerman , std::string_view msg_type, CDataStream& vRecv)
32
+ PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage (const CNode& peer, std::string_view msg_type, CDataStream& vRecv)
33
33
{
34
- if (fMasternodeMode ) return ;
35
- if (!m_mn_sync.IsBlockchainSynced ()) return ;
34
+ if (fMasternodeMode ) return {} ;
35
+ if (!m_mn_sync.IsBlockchainSynced ()) return {} ;
36
36
37
37
if (msg_type == NetMsgType::DSQUEUE) {
38
- CCoinJoinClientQueueManager::ProcessDSQueue (peer, peerman , vRecv);
38
+ return CCoinJoinClientQueueManager::ProcessDSQueue (peer, vRecv);
39
39
}
40
+ return {};
40
41
}
41
42
42
- void CCoinJoinClientQueueManager::ProcessDSQueue (const CNode& peer, PeerManager& peerman , CDataStream& vRecv)
43
+ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue (const CNode& peer, CDataStream& vRecv)
43
44
{
44
45
CCoinJoinQueue dsq;
45
46
vRecv >> dsq;
46
47
47
48
if (dsq.masternodeOutpoint .IsNull () && dsq.m_protxHash .IsNull ()) {
48
- peerman.Misbehaving (peer.GetId (), 100 );
49
- return ;
49
+ return tl::unexpected{100 };
50
50
}
51
51
52
52
if (dsq.masternodeOutpoint .IsNull ()) {
53
53
auto mnList = deterministicMNManager->GetListAtChainTip ();
54
54
if (auto dmn = mnList.GetValidMN (dsq.m_protxHash )) {
55
55
dsq.masternodeOutpoint = dmn->collateralOutpoint ;
56
56
} else {
57
- peerman.Misbehaving (peer.GetId (), 10 );
58
- return ;
57
+ return tl::unexpected{10 };
59
58
}
60
59
}
61
60
@@ -67,33 +66,32 @@ void CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, PeerManager&
67
66
// process every dsq only once
68
67
for (const auto &q: vecCoinJoinQueue) {
69
68
if (q == dsq) {
70
- return ;
69
+ return {} ;
71
70
}
72
71
if (q.fReady == dsq.fReady && q.masternodeOutpoint == dsq.masternodeOutpoint ) {
73
72
// no way the same mn can send another dsq with the same readiness this soon
74
73
LogPrint (BCLog::COINJOIN, /* Continued */
75
74
" DSQUEUE -- Peer %s is sending WAY too many dsq messages for a masternode with collateral %s\n " ,
76
75
peer.GetLogString (), dsq.masternodeOutpoint .ToStringShort ());
77
- return ;
76
+ return {} ;
78
77
}
79
78
}
80
79
} // cs_vecqueue
81
80
82
81
LogPrint (BCLog::COINJOIN, " DSQUEUE -- %s new\n " , dsq.ToString ());
83
82
84
- if (dsq.IsTimeOutOfBounds ()) return ;
83
+ if (dsq.IsTimeOutOfBounds ()) return {} ;
85
84
86
85
auto mnList = deterministicMNManager->GetListAtChainTip ();
87
86
auto dmn = mnList.GetValidMNByCollateral (dsq.masternodeOutpoint );
88
- if (!dmn) return ;
87
+ if (!dmn) return {} ;
89
88
90
89
if (dsq.m_protxHash .IsNull ()) {
91
90
dsq.m_protxHash = dmn->proTxHash ;
92
91
}
93
92
94
93
if (!dsq.CheckSignature (dmn->pdmnState ->pubKeyOperator .Get ())) {
95
- peerman.Misbehaving (peer.GetId (), 10 );
96
- return ;
94
+ return tl::unexpected{10 };
97
95
}
98
96
99
97
// if the queue is ready, submit if we can
@@ -104,7 +102,7 @@ void CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, PeerManager&
104
102
})) {
105
103
LogPrint (BCLog::COINJOIN, " DSQUEUE -- CoinJoin queue (%s) is ready on masternode %s\n " , dsq.ToString (),
106
104
dmn->pdmnState ->addr .ToString ());
107
- return ;
105
+ return {} ;
108
106
} else {
109
107
int64_t nLastDsq = mmetaman->GetMetaInfo (dmn->proTxHash )->GetLastDsq ();
110
108
int64_t nDsqThreshold = mmetaman->GetDsqThreshold (dmn->proTxHash , mnList.GetValidMNsCount ());
@@ -114,7 +112,7 @@ void CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, PeerManager&
114
112
if (nLastDsq != 0 && nDsqThreshold > mmetaman->GetDsqCount ()) {
115
113
LogPrint (BCLog::COINJOIN, " DSQUEUE -- Masternode %s is sending too many dsq messages\n " ,
116
114
dmn->proTxHash .ToString ());
117
- return ;
115
+ return {} ;
118
116
}
119
117
120
118
mmetaman->AllowMixing (dmn->proTxHash );
@@ -129,6 +127,7 @@ void CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, PeerManager&
129
127
}
130
128
} // cs_ProcessDSQueue
131
129
dsq.Relay (connman);
130
+ return {};
132
131
}
133
132
134
133
void CCoinJoinClientManager::ProcessMessage (CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
0 commit comments