20#include <xrpld/overlay/detail/TrafficCount.h>
32 {protocol::mtVALIDATORLISTCOLLECTION,
36 {protocol::mtPROOF_PATH_REQ,
38 {protocol::mtPROOF_PATH_RESPONSE,
40 {protocol::mtREPLAY_DELTA_REQ,
42 {protocol::mtREPLAY_DELTA_RESPONSE,
44 {protocol::mtHAVE_TRANSACTIONS,
46 {protocol::mtTRANSACTIONS,
53 ::google::protobuf::Message
const& message,
54 protocol::MessageType type,
60 if (type == protocol::mtHAVE_SET)
64 if (
auto msg =
dynamic_cast<protocol::TMLedgerData const*
>(&message))
66 if (msg->type() == protocol::liTS_CANDIDATE)
67 return (inbound && !msg->has_requestcookie())
71 if (msg->type() == protocol::liTX_NODE)
72 return (inbound && !msg->has_requestcookie())
76 if (msg->type() == protocol::liAS_NODE)
77 return (inbound && !msg->has_requestcookie())
81 return (inbound && !msg->has_requestcookie())
86 if (
auto msg =
dynamic_cast<protocol::TMGetLedger const*
>(&message))
88 if (msg->itype() == protocol::liTS_CANDIDATE)
89 return (inbound || msg->has_requestcookie())
93 if (msg->itype() == protocol::liTX_NODE)
94 return (inbound || msg->has_requestcookie())
98 if (msg->itype() == protocol::liAS_NODE)
99 return (inbound || msg->has_requestcookie())
103 return (inbound || msg->has_requestcookie())
108 if (
auto msg =
dynamic_cast<protocol::TMGetObjectByHash const*
>(&message))
110 if (msg->type() == protocol::TMGetObjectByHash::otLEDGER)
111 return (msg->query() == inbound)
115 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION)
116 return (msg->query() == inbound)
120 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION_NODE)
121 return (msg->query() == inbound)
125 if (msg->type() == protocol::TMGetObjectByHash::otSTATE_NODE)
126 return (msg->query() == inbound)
130 if (msg->type() == protocol::TMGetObjectByHash::otCAS_OBJECT)
131 return (msg->query() == inbound)
135 if (msg->type() == protocol::TMGetObjectByHash::otFETCH_PACK)
136 return (msg->query() == inbound)
140 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTIONS)
static category categorize(::google::protobuf::Message const &message, protocol::MessageType type, bool inbound)
Given a protocol message, determine which traffic category it belongs to.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unordered_map< protocol::MessageType, TrafficCount::category > const type_lookup