20 #include <ripple/overlay/impl/TrafficCount.h>
25 ::google::protobuf::Message
const& message,
26 int type,
bool inbound)
28 if ((type == protocol::mtPING) || (type == protocol::mtSTATUS_CHANGE))
29 return TrafficCount::category::base;
31 if (type == protocol::mtCLUSTER)
32 return TrafficCount::category::cluster;
34 if (type == protocol::mtMANIFESTS)
35 return TrafficCount::category::manifests;
37 if (type == protocol::mtENDPOINTS)
38 return TrafficCount::category::overlay;
40 if ((type == protocol::mtGET_SHARD_INFO) ||
41 (type == protocol::mtSHARD_INFO) ||
42 (type == protocol::mtGET_PEER_SHARD_INFO) ||
43 (type == protocol::mtPEER_SHARD_INFO))
44 return TrafficCount::category::shards;
46 if (type == protocol::mtTRANSACTION)
47 return TrafficCount::category::transaction;
49 if (type == protocol::mtVALIDATORLIST)
50 return TrafficCount::category::validatorlist;
52 if (type == protocol::mtVALIDATION)
53 return TrafficCount::category::validation;
55 if (type == protocol::mtPROPOSE_LEDGER)
56 return TrafficCount::category::proposal;
58 if (type == protocol::mtHAVE_SET)
60 TrafficCount::category::get_set:
61 TrafficCount::category::share_set;
63 if (
auto msg =
dynamic_cast<protocol::TMLedgerData const*
>(&message))
65 if (msg->type() == protocol::liTS_CANDIDATE)
66 return (inbound && !msg->has_requestcookie()) ?
67 TrafficCount::category::ld_tsc_get:
68 TrafficCount::category::ld_tsc_share;
70 if (msg->type() == protocol::liTX_NODE)
71 return (inbound && !msg->has_requestcookie()) ?
72 TrafficCount::category::ld_txn_get :
73 TrafficCount::category::ld_txn_share;
75 if (msg->type() == protocol::liAS_NODE)
76 return (inbound && !msg->has_requestcookie()) ?
77 TrafficCount::category::ld_asn_get :
78 TrafficCount::category::ld_asn_share;
80 return (inbound && !msg->has_requestcookie()) ?
81 TrafficCount::category::ld_get :
82 TrafficCount::category::ld_share;
85 if (
auto msg =
dynamic_cast<protocol::TMGetLedger const*
>(&message))
87 if (msg->itype() == protocol::liTS_CANDIDATE)
88 return (inbound || msg->has_requestcookie()) ?
89 TrafficCount::category::gl_tsc_share :
90 TrafficCount::category::gl_tsc_get;
92 if (msg->itype() == protocol::liTX_NODE)
93 return (inbound || msg->has_requestcookie()) ?
94 TrafficCount::category::gl_txn_share :
95 TrafficCount::category::gl_txn_get;
97 if (msg->itype() == protocol::liAS_NODE)
98 return (inbound || msg->has_requestcookie()) ?
99 TrafficCount::category::gl_asn_share :
100 TrafficCount::category::gl_asn_get;
102 return (inbound || msg->has_requestcookie()) ?
103 TrafficCount::category::gl_share :
104 TrafficCount::category::gl_get;
107 if (
auto msg =
dynamic_cast<protocol::TMGetObjectByHash const*
>(&message))
109 if (msg->type() == protocol::TMGetObjectByHash::otLEDGER)
110 return (msg->query() == inbound) ?
111 TrafficCount::category::share_hash_ledger :
112 TrafficCount::category::get_hash_ledger;
114 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION)
115 return (msg->query() == inbound) ?
116 TrafficCount::category::share_hash_tx :
117 TrafficCount::category::get_hash_tx;
119 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION_NODE)
120 return (msg->query() == inbound) ?
121 TrafficCount::category::share_hash_txnode :
122 TrafficCount::category::get_hash_txnode;
124 if (msg->type() == protocol::TMGetObjectByHash::otSTATE_NODE)
125 return (msg->query() == inbound) ?
126 TrafficCount::category::share_hash_asnode :
127 TrafficCount::category::get_hash_asnode;
129 if (msg->type() == protocol::TMGetObjectByHash::otCAS_OBJECT)
130 return (msg->query() == inbound) ?
131 TrafficCount::category::share_cas_object :
132 TrafficCount::category::get_cas_object;
134 if (msg->type() == protocol::TMGetObjectByHash::otFETCH_PACK)
135 return (msg->query() == inbound) ?
136 TrafficCount::category::share_fetch_pack :
137 TrafficCount::category::get_fetch_pack;
139 return (msg->query() == inbound) ?
140 TrafficCount::category::share_hash :
141 TrafficCount::category::get_hash;
144 return TrafficCount::category::unknown;