20 #include <ripple/overlay/impl/TrafficCount.h>
26 ::google::protobuf::Message
const& message,
30 if ((type == protocol::mtPING) || (type == protocol::mtSTATUS_CHANGE))
31 return TrafficCount::category::base;
33 if (type == protocol::mtCLUSTER)
34 return TrafficCount::category::cluster;
36 if (type == protocol::mtMANIFESTS)
37 return TrafficCount::category::manifests;
39 if (type == protocol::mtENDPOINTS)
40 return TrafficCount::category::overlay;
42 if ((type == protocol::mtGET_PEER_SHARD_INFO) ||
43 (type == protocol::mtPEER_SHARD_INFO) ||
44 (type == protocol::mtGET_PEER_SHARD_INFO_V2) ||
45 (type == protocol::mtPEER_SHARD_INFO_V2))
46 return TrafficCount::category::shards;
48 if (type == protocol::mtTRANSACTION)
49 return TrafficCount::category::transaction;
51 if (type == protocol::mtVALIDATORLIST ||
52 type == protocol::mtVALIDATORLISTCOLLECTION)
53 return TrafficCount::category::validatorlist;
55 if (type == protocol::mtVALIDATION)
56 return TrafficCount::category::validation;
58 if (type == protocol::mtPROPOSE_LEDGER)
59 return TrafficCount::category::proposal;
61 if (type == protocol::mtHAVE_SET)
62 return inbound ? TrafficCount::category::get_set
63 : TrafficCount::category::share_set;
65 if (
auto msg =
dynamic_cast<protocol::TMLedgerData const*
>(&message))
67 if (msg->type() == protocol::liTS_CANDIDATE)
68 return (inbound && !msg->has_requestcookie())
69 ? TrafficCount::category::ld_tsc_get
70 : TrafficCount::category::ld_tsc_share;
72 if (msg->type() == protocol::liTX_NODE)
73 return (inbound && !msg->has_requestcookie())
74 ? TrafficCount::category::ld_txn_get
75 : TrafficCount::category::ld_txn_share;
77 if (msg->type() == protocol::liAS_NODE)
78 return (inbound && !msg->has_requestcookie())
79 ? TrafficCount::category::ld_asn_get
80 : TrafficCount::category::ld_asn_share;
82 return (inbound && !msg->has_requestcookie())
83 ? TrafficCount::category::ld_get
84 : TrafficCount::category::ld_share;
87 if (
auto msg =
dynamic_cast<protocol::TMGetLedger const*
>(&message))
89 if (msg->itype() == protocol::liTS_CANDIDATE)
90 return (inbound || msg->has_requestcookie())
91 ? TrafficCount::category::gl_tsc_share
92 : TrafficCount::category::gl_tsc_get;
94 if (msg->itype() == protocol::liTX_NODE)
95 return (inbound || msg->has_requestcookie())
96 ? TrafficCount::category::gl_txn_share
97 : TrafficCount::category::gl_txn_get;
99 if (msg->itype() == protocol::liAS_NODE)
100 return (inbound || msg->has_requestcookie())
101 ? TrafficCount::category::gl_asn_share
102 : TrafficCount::category::gl_asn_get;
104 return (inbound || msg->has_requestcookie())
105 ? TrafficCount::category::gl_share
106 : TrafficCount::category::gl_get;
109 if (
auto msg =
dynamic_cast<protocol::TMGetObjectByHash const*
>(&message))
111 if (msg->type() == protocol::TMGetObjectByHash::otLEDGER)
112 return (msg->query() == inbound)
113 ? TrafficCount::category::share_hash_ledger
114 : TrafficCount::category::get_hash_ledger;
116 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION)
117 return (msg->query() == inbound)
118 ? TrafficCount::category::share_hash_tx
119 : TrafficCount::category::get_hash_tx;
121 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION_NODE)
122 return (msg->query() == inbound)
123 ? TrafficCount::category::share_hash_txnode
124 : TrafficCount::category::get_hash_txnode;
126 if (msg->type() == protocol::TMGetObjectByHash::otSTATE_NODE)
127 return (msg->query() == inbound)
128 ? TrafficCount::category::share_hash_asnode
129 : TrafficCount::category::get_hash_asnode;
131 if (msg->type() == protocol::TMGetObjectByHash::otCAS_OBJECT)
132 return (msg->query() == inbound)
133 ? TrafficCount::category::share_cas_object
134 : TrafficCount::category::get_cas_object;
136 if (msg->type() == protocol::TMGetObjectByHash::otFETCH_PACK)
137 return (msg->query() == inbound)
138 ? TrafficCount::category::share_fetch_pack
139 : TrafficCount::category::get_fetch_pack;
141 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTIONS)
142 return TrafficCount::category::get_transactions;
144 return (msg->query() == inbound) ? TrafficCount::category::share_hash
145 : TrafficCount::category::get_hash;
148 if (type == protocol::mtPROOF_PATH_REQ)
149 return TrafficCount::category::proof_path_request;
151 if (type == protocol::mtPROOF_PATH_RESPONSE)
152 return TrafficCount::category::proof_path_response;
154 if (type == protocol::mtREPLAY_DELTA_REQ)
155 return TrafficCount::category::replay_delta_request;
157 if (type == protocol::mtREPLAY_DELTA_RESPONSE)
158 return TrafficCount::category::replay_delta_response;
160 if (type == protocol::mtHAVE_TRANSACTIONS)
161 return TrafficCount::category::have_transactions;
163 if (type == protocol::mtTRANSACTIONS)
164 return TrafficCount::category::requested_transactions;
166 return TrafficCount::category::unknown;