Skip to content

Commit 6352baf

Browse files
committed
refactor: migrate CMNAuth::ProcessMessage()
1 parent 9f85bd0 commit 6352baf

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/evo/mnauth.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
5555
connman.PushMessage(&peer, CNetMsgMaker(peer.GetCommonVersion()).Make(NetMsgType::MNAUTH, mnauth));
5656
}
5757

58-
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
59-
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
60-
std::string_view msg_type, CDataStream& vRecv)
58+
MessageProcessingResult CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman,
59+
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
60+
const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv)
6161
{
6262
assert(mn_metaman.IsValid());
6363

@@ -71,30 +71,30 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CCon
7171

7272
// only one MNAUTH allowed
7373
if (!peer.GetVerifiedProRegTxHash().IsNull()) {
74-
return tl::unexpected{MisbehavingError{100, "duplicate mnauth"}};
74+
return MisbehavingError{100, "duplicate mnauth"};
7575
}
7676

7777
if ((~node_services) & (NODE_NETWORK | NODE_BLOOM)) {
7878
// either NODE_NETWORK or NODE_BLOOM bit is missing in node's services
79-
return tl::unexpected{MisbehavingError{100, "mnauth from a node with invalid services"}};
79+
return MisbehavingError{100, "mnauth from a node with invalid services"};
8080
}
8181

8282
if (mnauth.proRegTxHash.IsNull()) {
83-
return tl::unexpected{MisbehavingError{100, "empty mnauth proRegTxHash"}};
83+
return MisbehavingError{100, "empty mnauth proRegTxHash"};
8484
}
8585

8686
if (!mnauth.sig.IsValid()) {
8787
LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- invalid mnauth for protx=%s with sig=%s\n",
8888
mnauth.proRegTxHash.ToString(), mnauth.sig.ToString(false));
89-
return tl::unexpected{MisbehavingError{100, "invalid mnauth signature"}};
89+
return MisbehavingError{100, "invalid mnauth signature"};
9090
}
9191

9292
const auto dmn = tip_mn_list.GetMN(mnauth.proRegTxHash);
9393
if (!dmn) {
9494
// in case node was unlucky and not up to date, just let it be connected as a regular node, which gives it
9595
// a chance to get up-to-date and thus realize that it's not a MN anymore. We still give it a
9696
// low DoS score.
97-
return tl::unexpected{MisbehavingError{10, "missing mnauth masternode"}};
97+
return MisbehavingError{10, "missing mnauth masternode"};
9898
}
9999

100100
uint256 signHash;
@@ -114,7 +114,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, ServiceFlags node_services, CCon
114114
if (!mnauth.sig.VerifyInsecure(dmn->pdmnState->pubKeyOperator.Get(), signHash, false)) {
115115
// Same as above, MN seems to not know its fate yet, so give it a chance to update. If this is a
116116
// malicious node (DoSing us), it'll get banned soon.
117-
return tl::unexpected{MisbehavingError{10, "mnauth signature verification failed"}};
117+
return MisbehavingError{10, "mnauth signature verification failed"};
118118
}
119119

120120
if (!peer.IsInboundConn()) {

src/evo/mnauth.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class CMNAuth
5858
* @pre CMasternodeMetaMan's database must be successfully loaded before
5959
* attempting to call this function regardless of sync state
6060
*/
61-
static PeerMsgRet ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
62-
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list,
63-
std::string_view msg_type, CDataStream& vRecv);
61+
[[nodiscard]] static MessageProcessingResult ProcessMessage(CNode& peer, ServiceFlags node_services, CConnman& connman, CMasternodeMetaMan& mn_metaman,
62+
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
63+
const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv);
6464
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
6565
};
6666

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5271,7 +5271,7 @@ void PeerManagerImpl::ProcessMessage(
52715271
PostProcessMessage(m_sporkman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom.GetId());
52725272
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
52735273
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
5274-
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, peer->m_their_services, m_connman, m_mn_metaman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
5274+
PostProcessMessage(CMNAuth::ProcessMessage(pfrom, peer->m_their_services, m_connman, m_mn_metaman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom.GetId());
52755275
PostProcessMessage(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom.GetId());
52765276
PostProcessMessage(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, is_masternode, msg_type, vRecv), pfrom.GetId());
52775277
PostProcessMessage(m_llmq_ctx->qman->ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom.GetId());

0 commit comments

Comments
 (0)