| 4879 | } |
| 4880 | |
| 4881 | void PeerManagerImpl::ProcessMessage( |
| 4882 | const Config &config, CNode &pfrom, const std::string &msg_type, |
| 4883 | DataStream &vRecv, const std::chrono::microseconds time_received, |
| 4884 | const std::atomic<bool> &interruptMsgProc) { |
| 4885 | AssertLockHeld(g_msgproc_mutex); |
| 4886 | |
| 4887 | LogPrint(BCLog::NETDEBUG, "received: %s (%u bytes) peer=%d\n", |
| 4888 | SanitizeString(msg_type), vRecv.size(), pfrom.GetId()); |
| 4889 | |
| 4890 | PeerRef peer = GetPeerRef(pfrom.GetId()); |
| 4891 | if (peer == nullptr) { |
| 4892 | return; |
| 4893 | } |
| 4894 | |
| 4895 | if (!m_avalanche && IsAvalancheMessageType(msg_type)) { |
| 4896 | LogPrint(BCLog::AVALANCHE, |
| 4897 | "Avalanche is not initialized, ignoring %s message\n", |
| 4898 | msg_type); |
| 4899 | return; |
| 4900 | } |
| 4901 | |
| 4902 | if (msg_type == NetMsgType::VERSION) { |
| 4903 | // Each connection can only send one version message |
| 4904 | if (pfrom.nVersion != 0) { |
| 4905 | LogPrint(BCLog::NET, "redundant version message from peer=%d\n", |
| 4906 | pfrom.GetId()); |
| 4907 | return; |
| 4908 | } |
| 4909 | |
| 4910 | int64_t nTime; |
| 4911 | CService addrMe; |
| 4912 | uint64_t nNonce = 1; |
| 4913 | ServiceFlags nServices; |
| 4914 | int nVersion; |
| 4915 | std::string cleanSubVer; |
| 4916 | int starting_height = -1; |
| 4917 | bool fRelay = true; |
| 4918 | uint64_t nExtraEntropy = 1; |
| 4919 | |
| 4920 | vRecv >> nVersion >> Using<CustomUintFormatter<8>>(nServices) >> nTime; |
| 4921 | if (nTime < 0) { |
| 4922 | nTime = 0; |
| 4923 | } |
| 4924 | // Ignore the addrMe service bits sent by the peer |
| 4925 | vRecv.ignore(8); |
| 4926 | vRecv >> WithParams(CNetAddr::V1, addrMe); |
| 4927 | if (!pfrom.IsInboundConn()) { |
| 4928 | m_addrman.SetServices(pfrom.addr, nServices); |
| 4929 | } |
| 4930 | if (pfrom.ExpectServicesFromConn() && |
| 4931 | !HasAllDesirableServiceFlags(nServices)) { |
| 4932 | LogPrint(BCLog::NET, |
| 4933 | "peer=%d does not offer the expected services " |
| 4934 | "(%08x offered, %08x expected); disconnecting\n", |
| 4935 | pfrom.GetId(), nServices, |
| 4936 | GetDesirableServiceFlags(nServices)); |
| 4937 | pfrom.fDisconnect = true; |
| 4938 | return; |
nothing calls this directly
no test coverage detected