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_SHARD_INFO) ||
43 (type == protocol::mtSHARD_INFO) ||
44 (type == protocol::mtGET_PEER_SHARD_INFO) ||
45 (type == protocol::mtPEER_SHARD_INFO))
46 return TrafficCount::category::shards;
48 if (type == protocol::mtTRANSACTION)
49 return TrafficCount::category::transaction;
51 if (type == protocol::mtVALIDATORLIST)
52 return TrafficCount::category::validatorlist;
54 if (type == protocol::mtVALIDATION)
55 return TrafficCount::category::validation;
57 if (type == protocol::mtPROPOSE_LEDGER)
58 return TrafficCount::category::proposal;
60 if (type == protocol::mtHAVE_SET)
61 return inbound ? TrafficCount::category::get_set
62 : TrafficCount::category::share_set;
64 if (
auto msg =
dynamic_cast<protocol::TMLedgerData const*
>(&message))
66 if (msg->type() == protocol::liTS_CANDIDATE)
67 return (inbound && !msg->has_requestcookie())
68 ? TrafficCount::category::ld_tsc_get
69 : TrafficCount::category::ld_tsc_share;
71 if (msg->type() == protocol::liTX_NODE)
72 return (inbound && !msg->has_requestcookie())
73 ? TrafficCount::category::ld_txn_get
74 : TrafficCount::category::ld_txn_share;
76 if (msg->type() == protocol::liAS_NODE)
77 return (inbound && !msg->has_requestcookie())
78 ? TrafficCount::category::ld_asn_get
79 : TrafficCount::category::ld_asn_share;
81 return (inbound && !msg->has_requestcookie())
82 ? TrafficCount::category::ld_get
83 : TrafficCount::category::ld_share;
86 if (
auto msg =
dynamic_cast<protocol::TMGetLedger const*
>(&message))
88 if (msg->itype() == protocol::liTS_CANDIDATE)
89 return (inbound || msg->has_requestcookie())
90 ? TrafficCount::category::gl_tsc_share
91 : TrafficCount::category::gl_tsc_get;
93 if (msg->itype() == protocol::liTX_NODE)
94 return (inbound || msg->has_requestcookie())
95 ? TrafficCount::category::gl_txn_share
96 : TrafficCount::category::gl_txn_get;
98 if (msg->itype() == protocol::liAS_NODE)
99 return (inbound || msg->has_requestcookie())
100 ? TrafficCount::category::gl_asn_share
101 : TrafficCount::category::gl_asn_get;
103 return (inbound || msg->has_requestcookie())
104 ? TrafficCount::category::gl_share
105 : TrafficCount::category::gl_get;
108 if (
auto msg =
dynamic_cast<protocol::TMGetObjectByHash const*
>(&message))
110 if (msg->type() == protocol::TMGetObjectByHash::otLEDGER)
111 return (msg->query() == inbound)
112 ? TrafficCount::category::share_hash_ledger
113 : TrafficCount::category::get_hash_ledger;
115 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION)
116 return (msg->query() == inbound)
117 ? TrafficCount::category::share_hash_tx
118 : TrafficCount::category::get_hash_tx;
120 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION_NODE)
121 return (msg->query() == inbound)
122 ? TrafficCount::category::share_hash_txnode
123 : TrafficCount::category::get_hash_txnode;
125 if (msg->type() == protocol::TMGetObjectByHash::otSTATE_NODE)
126 return (msg->query() == inbound)
127 ? TrafficCount::category::share_hash_asnode
128 : TrafficCount::category::get_hash_asnode;
130 if (msg->type() == protocol::TMGetObjectByHash::otCAS_OBJECT)
131 return (msg->query() == inbound)
132 ? TrafficCount::category::share_cas_object
133 : TrafficCount::category::get_cas_object;
135 if (msg->type() == protocol::TMGetObjectByHash::otFETCH_PACK)
136 return (msg->query() == inbound)
137 ? TrafficCount::category::share_fetch_pack
138 : TrafficCount::category::get_fetch_pack;
140 return (msg->query() == inbound) ? TrafficCount::category::share_hash
141 : TrafficCount::category::get_hash;
144 return TrafficCount::category::unknown;