12
12
#include < chainparams.h>
13
13
#include < consensus/validation.h>
14
14
#include < masternode/sync.h>
15
- #include < net_processing.h>
16
15
#include < node/blockstorage.h>
17
16
#include < node/ui_interface.h>
18
17
#include < scheduler.h>
21
20
#include < util/thread.h>
22
21
#include < util/time.h>
23
22
#include < validation.h>
23
+ #include < validationinterface.h>
24
24
25
25
namespace llmq
26
26
{
27
27
std::unique_ptr<CChainLocksHandler> chainLocksHandler;
28
28
29
29
CChainLocksHandler::CChainLocksHandler (CChainState& chainstate, CConnman& _connman, CMasternodeSync& mn_sync, CQuorumManager& _qman,
30
30
CSigningManager& _sigman, CSigSharesManager& _shareman, CSporkManager& sporkManager,
31
- CTxMemPool& _mempool, const std::unique_ptr<PeerManager>& peerman ) :
31
+ CTxMemPool& _mempool) :
32
32
m_chainstate (chainstate),
33
33
connman (_connman),
34
34
m_mn_sync (mn_sync),
@@ -37,7 +37,6 @@ CChainLocksHandler::CChainLocksHandler(CChainState& chainstate, CConnman& _connm
37
37
shareman (_shareman),
38
38
spork_manager (sporkManager),
39
39
mempool (_mempool),
40
- m_peerman (peerman),
41
40
scheduler (std::make_unique<CScheduler>()),
42
41
scheduler_thread (std::make_unique<std::thread>(std::thread(util::TraceThread, " cl-schdlr" , [&] { scheduler->serviceQueue (); })))
43
42
{
@@ -91,21 +90,22 @@ CChainLockSig CChainLocksHandler::GetBestChainLock() const
91
90
return bestChainLock;
92
91
}
93
92
94
- void CChainLocksHandler::ProcessMessage (const CNode& pfrom, const std::string& msg_type, CDataStream& vRecv)
93
+ PeerMsgRet CChainLocksHandler::ProcessMessage (const CNode& pfrom, const std::string& msg_type, CDataStream& vRecv)
95
94
{
96
95
if (!AreChainLocksEnabled (spork_manager)) {
97
- return ;
96
+ return {} ;
98
97
}
99
98
100
99
if (msg_type == NetMsgType::CLSIG) {
101
100
CChainLockSig clsig;
102
101
vRecv >> clsig;
103
102
104
- ProcessNewChainLock (pfrom.GetId (), clsig, ::SerializeHash (clsig));
103
+ return ProcessNewChainLock (pfrom.GetId (), clsig, ::SerializeHash (clsig));
105
104
}
105
+ return {};
106
106
}
107
107
108
- void CChainLocksHandler::ProcessNewChainLock (const NodeId from, const llmq::CChainLockSig& clsig, const uint256& hash)
108
+ PeerMsgRet CChainLocksHandler::ProcessNewChainLock (const NodeId from, const llmq::CChainLockSig& clsig, const uint256& hash)
109
109
{
110
110
CheckActiveState ();
111
111
@@ -119,21 +119,21 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
119
119
{
120
120
LOCK (cs);
121
121
if (!seenChainLocks.emplace (hash, GetTimeMillis ()).second ) {
122
- return ;
122
+ return {} ;
123
123
}
124
124
125
125
if (!bestChainLock.IsNull () && clsig.getHeight () <= bestChainLock.getHeight ()) {
126
126
// no need to process/relay older CLSIGs
127
- return ;
127
+ return {} ;
128
128
}
129
129
}
130
130
131
131
if (!VerifyChainLock (clsig)) {
132
132
LogPrint (BCLog::CHAINLOCKS, " CChainLocksHandler::%s -- invalid CLSIG (%s), peer=%d\n " , __func__, clsig.ToString (), from);
133
133
if (from != -1 ) {
134
- m_peerman-> Misbehaving (from, 10 ) ;
134
+ return tl::unexpected{ 10 } ;
135
135
}
136
- return ;
136
+ return {} ;
137
137
}
138
138
139
139
CBlockIndex* pindex = WITH_LOCK (cs_main, return m_chainstate.m_blockman .LookupBlockIndex (clsig.getBlockHash ()));
@@ -150,7 +150,7 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
150
150
LogPrintf (" CChainLocksHandler::%s -- height of CLSIG (%s) does not match the specified block's height (%d)\n " ,
151
151
__func__, clsig.ToString (), pindex->nHeight );
152
152
// Note: not relaying clsig here
153
- return ;
153
+ return {} ;
154
154
}
155
155
156
156
bestChainLockWithKnownBlock = bestChainLock;
@@ -167,7 +167,7 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
167
167
if (pindex == nullptr ) {
168
168
// we don't know the block/header for this CLSIG yet, so bail out for now
169
169
// when the block or the header later comes in, we will enforce the correct chain
170
- return ;
170
+ return {} ;
171
171
}
172
172
173
173
scheduler->scheduleFromNow ([&]() {
@@ -177,6 +177,7 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
177
177
178
178
LogPrint (BCLog::CHAINLOCKS, " CChainLocksHandler::%s -- processed new CLSIG (%s), peer=%d\n " ,
179
179
__func__, clsig.ToString (), from);
180
+ return {};
180
181
}
181
182
182
183
void CChainLocksHandler::AcceptedBlockHeader (gsl::not_null<const CBlockIndex*> pindexNew)
0 commit comments