Skip to content

Commit fcc618d

Browse files
committed
Merge #15078: rpc: Document bytessent_per_msg and bytesrecv_per_msg
fab3f14 rpc: Document bytessent_per_msg and bytesrecv_per_msg (MarcoFalke) Pull request description: Tree-SHA512: 11af7502933b3dae203d90e36b35019e0ebe67ee09aa77360a27547487bd2b6bcaa18c5f60bc21966291d2ccf44dfedebf40103c4db70a359400f535a66abb23
2 parents f0fa6ba + fab3f14 commit fcc618d

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/net.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2018 The Bitcoin Core developers
2+
// Copyright (c) 2009-2019 The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -80,7 +80,7 @@ enum BindFlags {
8080
// The sleep time needs to be small to avoid new sockets stalling
8181
static const uint64_t SELECT_TIMEOUT_MILLISECONDS = 50;
8282

83-
const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*";
83+
const std::string NET_MESSAGE_COMMAND_OTHER = "*other*";
8484

8585
static const uint64_t RANDOMIZER_ID_NETGROUP = 0x6c0edd8036ef4036ULL; // SHA256("netgroup")[0:8]
8686
static const uint64_t RANDOMIZER_ID_LOCALHOSTNONCE = 0xd93e69e2bbfa5735ULL; // SHA256("localhostnonce")[0:8]
@@ -787,7 +787,6 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
787787
nBytes -= handled;
788788

789789
if (msg.complete()) {
790-
791790
//store received bytes per message command
792791
//to prevent a memory DOS, only allow valid commands
793792
mapMsgCmdSize::iterator i = mapRecvBytesPerMsgCmd.find(msg.hdr.pchCommand);

src/net.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2018 The Bitcoin Core developers
2+
// Copyright (c) 2009-2019 The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -550,6 +550,8 @@ struct LocalServiceInfo {
550550

551551
extern CCriticalSection cs_mapLocalHost;
552552
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(cs_mapLocalHost);
553+
554+
extern const std::string NET_MESSAGE_COMMAND_OTHER;
553555
typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes
554556

555557
class CNodeStats
@@ -696,8 +698,8 @@ class CNode
696698
const uint64_t nKeyedNetGroup;
697699
std::atomic_bool fPauseRecv;
698700
std::atomic_bool fPauseSend;
699-
protected:
700701

702+
protected:
701703
mapMsgCmdSize mapSendBytesPerMsgCmd;
702704
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
703705

src/rpc/net.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2009-2018 The Bitcoin Core developers
1+
// Copyright (c) 2009-2019 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -109,11 +109,15 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
109109
" \"whitelisted\": true|false, (boolean) Whether the peer is whitelisted\n"
110110
" \"minfeefilter\": n, (numeric) The minimum fee rate for transactions this peer accepts\n"
111111
" \"bytessent_per_msg\": {\n"
112-
" \"addr\": n, (numeric) The total bytes sent aggregated by message type\n"
112+
" \"msg\": n, (numeric) The total bytes sent aggregated by message type\n"
113+
" When a message type is not listed in this json object, the bytes sent are 0.\n"
114+
" Only known message types can appear as keys in the object.\n"
113115
" ...\n"
114116
" },\n"
115117
" \"bytesrecv_per_msg\": {\n"
116-
" \"addr\": n, (numeric) The total bytes received aggregated by message type\n"
118+
" \"msg\": n, (numeric) The total bytes received aggregated by message type\n"
119+
" When a message type is not listed in this json object, the bytes received are 0.\n"
120+
" Only known message types can appear as keys in the object and all bytes received of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'.\n"
117121
" ...\n"
118122
" }\n"
119123
" }\n"
@@ -178,14 +182,14 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
178182
obj.pushKV("minfeefilter", ValueFromAmount(stats.minFeeFilter));
179183

180184
UniValue sendPerMsgCmd(UniValue::VOBJ);
181-
for (const mapMsgCmdSize::value_type &i : stats.mapSendBytesPerMsgCmd) {
185+
for (const auto& i : stats.mapSendBytesPerMsgCmd) {
182186
if (i.second > 0)
183187
sendPerMsgCmd.pushKV(i.first, i.second);
184188
}
185189
obj.pushKV("bytessent_per_msg", sendPerMsgCmd);
186190

187191
UniValue recvPerMsgCmd(UniValue::VOBJ);
188-
for (const mapMsgCmdSize::value_type &i : stats.mapRecvBytesPerMsgCmd) {
192+
for (const auto& i : stats.mapRecvBytesPerMsgCmd) {
189193
if (i.second > 0)
190194
recvPerMsgCmd.pushKV(i.first, i.second);
191195
}

0 commit comments

Comments
 (0)