11
11
#include < logging.h>
12
12
#include < messagesigner.h>
13
13
#include < net.h>
14
- #include < net_processing.h>
15
14
#include < netmessagemaker.h>
16
15
#include < primitives/block.h>
17
16
#include < protocol.h>
@@ -130,16 +129,17 @@ void CSporkManager::CheckAndRemove()
130
129
}
131
130
}
132
131
133
- void CSporkManager::ProcessMessage (CNode& peer, PeerManager& peerman , CConnman& connman, std::string_view msg_type, CDataStream& vRecv)
132
+ PeerMsgRet CSporkManager::ProcessMessage (CNode& peer, CConnman& connman, std::string_view msg_type, CDataStream& vRecv)
134
133
{
135
134
if (msg_type == NetMsgType::SPORK) {
136
- ProcessSpork (peer, peerman , connman, vRecv);
135
+ return ProcessSpork (peer, connman, vRecv);
137
136
} else if (msg_type == NetMsgType::GETSPORKS) {
138
137
ProcessGetSporks (peer, connman);
139
138
}
139
+ return {};
140
140
}
141
141
142
- void CSporkManager::ProcessSpork (const CNode& peer, PeerManager& peerman , CConnman& connman, CDataStream& vRecv)
142
+ PeerMsgRet CSporkManager::ProcessSpork (const CNode& peer, CConnman& connman, CDataStream& vRecv)
143
143
{
144
144
CSporkMessage spork;
145
145
vRecv >> spork;
@@ -150,22 +150,20 @@ void CSporkManager::ProcessSpork(const CNode& peer, PeerManager& peerman, CConnm
150
150
{
151
151
LOCK (cs_main);
152
152
EraseObjectRequest (peer.GetId (), CInv (MSG_SPORK, hash));
153
- if (!::ChainActive ().Tip ()) return ;
153
+ if (!::ChainActive ().Tip ()) return {} ;
154
154
strLogMsg = strprintf (" SPORK -- hash: %s id: %d value: %10d bestHeight: %d peer=%d" , hash.ToString (), spork.nSporkID , spork.nValue , ::ChainActive ().Height (), peer.GetId ());
155
155
}
156
156
157
157
if (spork.nTimeSigned > GetAdjustedTime () + 2 * 60 * 60 ) {
158
158
LogPrint (BCLog::SPORK, " CSporkManager::ProcessSpork -- ERROR: too far into the future\n " );
159
- peerman.Misbehaving (peer.GetId (), 100 );
160
- return ;
159
+ return tl::unexpected{100 };
161
160
}
162
161
163
162
auto opt_keyIDSigner = spork.GetSignerKeyID ();
164
163
165
164
if (opt_keyIDSigner == std::nullopt || WITH_LOCK (cs, return !setSporkPubKeyIDs.count (*opt_keyIDSigner))) {
166
165
LogPrint (BCLog::SPORK, " CSporkManager::ProcessSpork -- ERROR: invalid signature\n " );
167
- peerman.Misbehaving (peer.GetId (), 100 );
168
- return ;
166
+ return tl::unexpected{100 };
169
167
}
170
168
171
169
auto keyIDSigner = *opt_keyIDSigner;
@@ -176,7 +174,7 @@ void CSporkManager::ProcessSpork(const CNode& peer, PeerManager& peerman, CConnm
176
174
if (mapSporksActive[spork.nSporkID ].count (keyIDSigner)) {
177
175
if (mapSporksActive[spork.nSporkID ][keyIDSigner].nTimeSigned >= spork.nTimeSigned ) {
178
176
LogPrint (BCLog::SPORK, " %s seen\n " , strLogMsg);
179
- return ;
177
+ return {} ;
180
178
} else {
181
179
LogPrintf (" %s updated\n " , strLogMsg);
182
180
}
@@ -198,6 +196,7 @@ void CSporkManager::ProcessSpork(const CNode& peer, PeerManager& peerman, CConnm
198
196
WITH_LOCK (cs_mapSporksCachedValues, mapSporksCachedValues.erase (spork.nSporkID ));
199
197
}
200
198
spork.Relay (connman);
199
+ return {};
201
200
}
202
201
203
202
void CSporkManager::ProcessGetSporks (CNode& peer, CConnman& connman)
0 commit comments