MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / ProcessMessages

Method ProcessMessages

src/net_processing.cpp:8001–8091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7999}
8000
8001bool PeerManagerImpl::ProcessMessages(const Config &config, CNode *pfrom,
8002 std::atomic<bool> &interruptMsgProc) {
8003 AssertLockHeld(g_msgproc_mutex);
8004
8005 PeerRef peer = GetPeerRef(pfrom->GetId());
8006 if (peer == nullptr) {
8007 return false;
8008 }
8009
8010 {
8011 LOCK(peer->m_getdata_requests_mutex);
8012 if (!peer->m_getdata_requests.empty()) {
8013 ProcessGetData(config, *pfrom, *peer, interruptMsgProc);
8014 }
8015 }
8016
8017 const bool processed_orphan = ProcessOrphanTx(config, *peer);
8018
8019 if (pfrom->fDisconnect) {
8020 return false;
8021 }
8022
8023 if (processed_orphan) {
8024 return true;
8025 }
8026
8027 // this maintains the order of responses and prevents m_getdata_requests to
8028 // grow unbounded
8029 {
8030 LOCK(peer->m_getdata_requests_mutex);
8031 if (!peer->m_getdata_requests.empty()) {
8032 return true;
8033 }
8034 }
8035
8036 // Don't bother if send buffer is too full to respond anyway
8037 if (pfrom->fPauseSend) {
8038 return false;
8039 }
8040
8041 auto poll_result{pfrom->PollMessage()};
8042 if (!poll_result) {
8043 // No message to process
8044 return false;
8045 }
8046
8047 CNetMessage &msg{poll_result->first};
8048 bool fMoreWork = poll_result->second;
8049
8050 TRACE6(net, inbound_message, pfrom->GetId(), pfrom->m_addr_name.c_str(),
8051 pfrom->ConnectionTypeAsString().c_str(), msg.m_type.c_str(),
8052 msg.m_recv.size(), msg.m_recv.data());
8053
8054 if (m_opts.capture_messages) {
8055 CaptureMessage(pfrom->addr, msg.m_type, MakeUCharSpan(msg.m_recv),
8056 /*is_incoming=*/true);
8057 }
8058

Callers 1

ThreadMessageHandlerMethod · 0.45

Calls 11

MakeUCharSpanFunction · 0.85
SanitizeStringFunction · 0.85
PollMessageMethod · 0.80
HaveTxToReconsiderMethod · 0.80
GetIdMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
whatMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected