@@ -102,53 +102,52 @@ void CInstantSendManager::Stop()
102102 }
103103}
104104
105- PeerMsgRet CInstantSendManager::ProcessMessage (const CNode& pfrom, PeerManager& peerman, std::string_view msg_type,
106- CDataStream& vRecv)
107- {
108- if (IsInstantSendEnabled () && msg_type == NetMsgType::ISDLOCK) {
109- const auto islock = std::make_shared<instantsend::InstantSendLock>();
110- vRecv >> *islock;
111- return ProcessMessageInstantSendLock (pfrom, peerman, islock);
112- }
113- return {};
114- }
115-
116105bool ShouldReportISLockTiming () {
117106 return g_stats_client->active () || LogAcceptDebug (BCLog::INSTANTSEND);
118107}
119108
120- PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock (const CNode& pfrom, PeerManager& peerman,
121- const instantsend::InstantSendLockPtr& islock)
109+ MessageProcessingResult CInstantSendManager::ProcessMessage (NodeId from, std::string_view msg_type, CDataStream& vRecv)
122110{
111+ if (!IsInstantSendEnabled () || msg_type != NetMsgType::ISDLOCK) {
112+ return {};
113+ }
114+
115+ const auto islock = std::make_shared<instantsend::InstantSendLock>();
116+ vRecv >> *islock;
117+
123118 auto hash = ::SerializeHash (*islock);
124119
125- WITH_LOCK (::cs_main, peerman.EraseObjectRequest (pfrom.GetId (), CInv (MSG_ISDLOCK, hash)));
120+ MessageProcessingResult ret{};
121+ ret.m_to_erase = CInv{MSG_ISDLOCK, hash};
126122
127123 if (!islock->TriviallyValid ()) {
128- return tl::unexpected{100 };
124+ ret.m_error = MisbehavingError{100 };
125+ return ret;
129126 }
130127
131128 const auto blockIndex = WITH_LOCK (::cs_main, return m_chainstate.m_blockman .LookupBlockIndex (islock->cycleHash ));
132129 if (blockIndex == nullptr ) {
133130 // Maybe we don't have the block yet or maybe some peer spams invalid values for cycleHash
134- return tl::unexpected{1 };
131+ ret.m_error = MisbehavingError{1 };
132+ return ret;
135133 }
136134
137135 // Deterministic islocks MUST use rotation based llmq
138136 auto llmqType = Params ().GetConsensus ().llmqTypeDIP0024InstantSend ;
139137 const auto & llmq_params_opt = Params ().GetLLMQ (llmqType);
140138 assert (llmq_params_opt);
141139 if (blockIndex->nHeight % llmq_params_opt->dkgInterval != 0 ) {
142- return tl::unexpected{100 };
140+ ret.m_error = MisbehavingError{100 };
141+ return ret;
143142 }
144143
145144 if (WITH_LOCK (cs_pendingLocks, return pendingInstantSendLocks.count (hash) || pendingNoTxInstantSendLocks.count (hash)) ||
146145 db.KnownInstantSendLock (hash)) {
147- return {} ;
146+ return ret ;
148147 }
149148
150149 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: received islock, peer=%d\n " , __func__,
151- islock->txid .ToString (), hash.ToString (), pfrom. GetId () );
150+ islock->txid .ToString (), hash.ToString (), from );
152151
153152 if (ShouldReportISLockTiming ()) {
154153 auto time_diff = [&]() -> int64_t {
@@ -168,8 +167,8 @@ PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock(const CNode& pfrom
168167 }
169168
170169 LOCK (cs_pendingLocks);
171- pendingInstantSendLocks.emplace (hash, std::make_pair (pfrom. GetId () , islock));
172- return {} ;
170+ pendingInstantSendLocks.emplace (hash, std::make_pair (from , islock));
171+ return ret ;
173172}
174173
175174bool CInstantSendManager::ProcessPendingInstantSendLocks (PeerManager& peerman)
0 commit comments