Skip to content

Commit fa1471e

Browse files
author
MarcoFalke
committed
refactor: Remove duplicate allNetMessageTypesVec
With C++11 (and later), the duplicate variable is no longer needed. Also, run clang-format on the namespace, as the script in the next commit relies on a specific format. This prevents a clang-format run in the future from breaking the script. (Review hint: --ignore-all-space).
1 parent 21ed784 commit fa1471e

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

src/protocol.cpp

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@
1212
static std::atomic<bool> g_initial_block_download_completed(false);
1313

1414
namespace NetMsgType {
15-
const char *VERSION="version";
16-
const char *VERACK="verack";
17-
const char *ADDR="addr";
18-
const char *ADDRV2="addrv2";
19-
const char *SENDADDRV2="sendaddrv2";
20-
const char *INV="inv";
21-
const char *GETDATA="getdata";
22-
const char *MERKLEBLOCK="merkleblock";
23-
const char *GETBLOCKS="getblocks";
24-
const char *GETHEADERS="getheaders";
25-
const char *TX="tx";
26-
const char *HEADERS="headers";
27-
const char *BLOCK="block";
28-
const char *GETADDR="getaddr";
29-
const char *MEMPOOL="mempool";
30-
const char *PING="ping";
31-
const char *PONG="pong";
32-
const char *NOTFOUND="notfound";
33-
const char *FILTERLOAD="filterload";
34-
const char *FILTERADD="filteradd";
35-
const char *FILTERCLEAR="filterclear";
36-
const char *SENDHEADERS="sendheaders";
37-
const char *FEEFILTER="feefilter";
38-
const char *SENDCMPCT="sendcmpct";
39-
const char *CMPCTBLOCK="cmpctblock";
40-
const char *GETBLOCKTXN="getblocktxn";
41-
const char *BLOCKTXN="blocktxn";
42-
const char *GETCFILTERS="getcfilters";
43-
const char *CFILTER="cfilter";
44-
const char *GETCFHEADERS="getcfheaders";
45-
const char *CFHEADERS="cfheaders";
46-
const char *GETCFCHECKPT="getcfcheckpt";
47-
const char *CFCHECKPT="cfcheckpt";
48-
const char *WTXIDRELAY="wtxidrelay";
49-
const char *SENDTXRCNCL="sendtxrcncl";
15+
const char* VERSION = "version";
16+
const char* VERACK = "verack";
17+
const char* ADDR = "addr";
18+
const char* ADDRV2 = "addrv2";
19+
const char* SENDADDRV2 = "sendaddrv2";
20+
const char* INV = "inv";
21+
const char* GETDATA = "getdata";
22+
const char* MERKLEBLOCK = "merkleblock";
23+
const char* GETBLOCKS = "getblocks";
24+
const char* GETHEADERS = "getheaders";
25+
const char* TX = "tx";
26+
const char* HEADERS = "headers";
27+
const char* BLOCK = "block";
28+
const char* GETADDR = "getaddr";
29+
const char* MEMPOOL = "mempool";
30+
const char* PING = "ping";
31+
const char* PONG = "pong";
32+
const char* NOTFOUND = "notfound";
33+
const char* FILTERLOAD = "filterload";
34+
const char* FILTERADD = "filteradd";
35+
const char* FILTERCLEAR = "filterclear";
36+
const char* SENDHEADERS = "sendheaders";
37+
const char* FEEFILTER = "feefilter";
38+
const char* SENDCMPCT = "sendcmpct";
39+
const char* CMPCTBLOCK = "cmpctblock";
40+
const char* GETBLOCKTXN = "getblocktxn";
41+
const char* BLOCKTXN = "blocktxn";
42+
const char* GETCFILTERS = "getcfilters";
43+
const char* CFILTER = "cfilter";
44+
const char* GETCFHEADERS = "getcfheaders";
45+
const char* CFHEADERS = "cfheaders";
46+
const char* GETCFCHECKPT = "getcfcheckpt";
47+
const char* CFCHECKPT = "cfcheckpt";
48+
const char* WTXIDRELAY = "wtxidrelay";
49+
const char* SENDTXRCNCL = "sendtxrcncl";
5050
} // namespace NetMsgType
5151

5252
/** All known message types. Keep this in the same order as the list of
5353
* messages above and in protocol.h.
5454
*/
55-
const static std::string allNetMessageTypes[] = {
55+
const static std::vector<std::string> g_all_net_message_types{
5656
NetMsgType::VERSION,
5757
NetMsgType::VERACK,
5858
NetMsgType::ADDR,
@@ -89,7 +89,6 @@ const static std::string allNetMessageTypes[] = {
8989
NetMsgType::WTXIDRELAY,
9090
NetMsgType::SENDTXRCNCL,
9191
};
92-
const static std::vector<std::string> allNetMessageTypesVec(std::begin(allNetMessageTypes), std::end(allNetMessageTypes));
9392

9493
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn)
9594
{
@@ -182,7 +181,7 @@ std::string CInv::ToString() const
182181

183182
const std::vector<std::string> &getAllNetMessageTypes()
184183
{
185-
return allNetMessageTypesVec;
184+
return g_all_net_message_types;
186185
}
187186

188187
/**

0 commit comments

Comments
 (0)