MCPcopy Create free account
hub / github.com/ElementsProject/elements / ProcessMessages

Method ProcessMessages

src/net_processing.cpp:4188–4272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4186}
4187
4188bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc)
4189{
4190 bool fMoreWork = false;
4191
4192 PeerRef peer = GetPeerRef(pfrom->GetId());
4193 if (peer == nullptr) return false;
4194
4195 // For outbound connections, ensure that the initial VERSION message
4196 // has been sent first before processing any incoming messages
4197 if (!pfrom->IsInboundConn() && WITH_LOCK(peer->m_msgproc_mutex, return !peer->m_outbound_version_message_sent)) return false;
4198
4199 {
4200 LOCK(peer->m_getdata_requests_mutex);
4201 if (!peer->m_getdata_requests.empty()) {
4202 ProcessGetData(*pfrom, *peer, interruptMsgProc);
4203 }
4204 }
4205
4206 {
4207 LOCK2(cs_main, g_cs_orphans);
4208 if (!peer->m_orphan_work_set.empty()) {
4209 ProcessOrphanTx(peer->m_orphan_work_set);
4210 }
4211 }
4212
4213 if (pfrom->fDisconnect)
4214 return false;
4215
4216 // this maintains the order of responses
4217 // and prevents m_getdata_requests to grow unbounded
4218 {
4219 LOCK(peer->m_getdata_requests_mutex);
4220 if (!peer->m_getdata_requests.empty()) return true;
4221 }
4222
4223 {
4224 LOCK(g_cs_orphans);
4225 if (!peer->m_orphan_work_set.empty()) return true;
4226 }
4227
4228 // Don't bother if send buffer is too full to respond anyway
4229 if (pfrom->fPauseSend) return false;
4230
4231 std::list<CNetMessage> msgs;
4232 {
4233 LOCK(pfrom->cs_vProcessMsg);
4234 if (pfrom->vProcessMsg.empty()) return false;
4235 // Just take one message
4236 msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin());
4237 pfrom->nProcessQueueSize -= msgs.front().m_raw_message_size;
4238 pfrom->fPauseRecv = pfrom->nProcessQueueSize > m_connman.GetReceiveFloodSize();
4239 fMoreWork = !pfrom->vProcessMsg.empty();
4240 }
4241 CNetMessage& msg(msgs.front());
4242
4243 TRACE6(net, inbound_message,
4244 pfrom->GetId(),
4245 pfrom->m_addr_name.c_str(),

Callers 2

ThreadMessageHandlerMethod · 0.80
ProcessMessagesOnceMethod · 0.80

Calls 13

MakeUCharSpanFunction · 0.85
SanitizeStringFunction · 0.85
GetIdMethod · 0.80
IsInboundConnMethod · 0.80
GetReceiveFloodSizeMethod · 0.80
GetBoolArgMethod · 0.80
GetCommonVersionMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by 1

ProcessMessagesOnceMethod · 0.64