aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-12-07 15:31:32 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-12-10 12:14:06 +0100
commit9bbe71b641e2fc985daf127988a14a67c99da50a (patch)
tree6d13cf5ecbceb44ec633ad07b435799c6c73e4f5 /src/net.cpp
parent5dc63ed1ca8aca62f28881ba9ef996d4036a23ea (diff)
downloadbitcoin-9bbe71b641e2fc985daf127988a14a67c99da50a.tar.xz
net: Add and document network messages in protocol.h
- Avoids string typos (by making the compiler check) - Makes it easier to grep for handling/generation of a certain message type - Refer directly to documentation by following the symbol in IDE - Move list of valid message types to protocol.cpp: protocol.cpp is a more appropriate place for this, and having the array there makes it easier to keep things consistent.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 159d44cba1..c5e7ece79d 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -67,14 +67,6 @@ namespace {
};
}
-//immutable thread safe array of allowed commands for logging inbound traffic
-const static std::string logAllowIncomingMsgCmds[] = {
- "version", "addr", "inv", "getdata", "merkleblock",
- "getblocks", "getheaders", "tx", "headers", "block",
- "getaddr", "mempool", "ping", "pong", "alert", "notfound",
- "filterload", "filteradd", "filterclear", "reject",
- "sendheaders", "verack"};
-
const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*";
//
@@ -469,7 +461,7 @@ void CNode::PushVersion()
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id);
else
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
- PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
+ PushMessage(NetMsgType::VERSION, PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
nLocalHostNonce, strSubVersion, nBestHeight, !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY));
}
@@ -2399,8 +2391,8 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa
nPingUsecTime = 0;
fPingQueued = false;
nMinPingUsecTime = std::numeric_limits<int64_t>::max();
- for (unsigned int i = 0; i < sizeof(logAllowIncomingMsgCmds)/sizeof(logAllowIncomingMsgCmds[0]); i++)
- mapRecvBytesPerMsgCmd[logAllowIncomingMsgCmds[i]] = 0;
+ BOOST_FOREACH(const std::string &msg, getAllNetMessageTypes())
+ mapRecvBytesPerMsgCmd[msg] = 0;
mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0;
{