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).
This commit is contained in:
MarcoFalke
2023-07-11 15:44:43 +02:00
parent 21ed784614
commit fa1471e575

View File

@ -12,47 +12,47 @@
static std::atomic<bool> g_initial_block_download_completed(false); static std::atomic<bool> g_initial_block_download_completed(false);
namespace NetMsgType { namespace NetMsgType {
const char *VERSION="version"; const char* VERSION = "version";
const char *VERACK="verack"; const char* VERACK = "verack";
const char *ADDR="addr"; const char* ADDR = "addr";
const char *ADDRV2="addrv2"; const char* ADDRV2 = "addrv2";
const char *SENDADDRV2="sendaddrv2"; const char* SENDADDRV2 = "sendaddrv2";
const char *INV="inv"; const char* INV = "inv";
const char *GETDATA="getdata"; const char* GETDATA = "getdata";
const char *MERKLEBLOCK="merkleblock"; const char* MERKLEBLOCK = "merkleblock";
const char *GETBLOCKS="getblocks"; const char* GETBLOCKS = "getblocks";
const char *GETHEADERS="getheaders"; const char* GETHEADERS = "getheaders";
const char *TX="tx"; const char* TX = "tx";
const char *HEADERS="headers"; const char* HEADERS = "headers";
const char *BLOCK="block"; const char* BLOCK = "block";
const char *GETADDR="getaddr"; const char* GETADDR = "getaddr";
const char *MEMPOOL="mempool"; const char* MEMPOOL = "mempool";
const char *PING="ping"; const char* PING = "ping";
const char *PONG="pong"; const char* PONG = "pong";
const char *NOTFOUND="notfound"; const char* NOTFOUND = "notfound";
const char *FILTERLOAD="filterload"; const char* FILTERLOAD = "filterload";
const char *FILTERADD="filteradd"; const char* FILTERADD = "filteradd";
const char *FILTERCLEAR="filterclear"; const char* FILTERCLEAR = "filterclear";
const char *SENDHEADERS="sendheaders"; const char* SENDHEADERS = "sendheaders";
const char *FEEFILTER="feefilter"; const char* FEEFILTER = "feefilter";
const char *SENDCMPCT="sendcmpct"; const char* SENDCMPCT = "sendcmpct";
const char *CMPCTBLOCK="cmpctblock"; const char* CMPCTBLOCK = "cmpctblock";
const char *GETBLOCKTXN="getblocktxn"; const char* GETBLOCKTXN = "getblocktxn";
const char *BLOCKTXN="blocktxn"; const char* BLOCKTXN = "blocktxn";
const char *GETCFILTERS="getcfilters"; const char* GETCFILTERS = "getcfilters";
const char *CFILTER="cfilter"; const char* CFILTER = "cfilter";
const char *GETCFHEADERS="getcfheaders"; const char* GETCFHEADERS = "getcfheaders";
const char *CFHEADERS="cfheaders"; const char* CFHEADERS = "cfheaders";
const char *GETCFCHECKPT="getcfcheckpt"; const char* GETCFCHECKPT = "getcfcheckpt";
const char *CFCHECKPT="cfcheckpt"; const char* CFCHECKPT = "cfcheckpt";
const char *WTXIDRELAY="wtxidrelay"; const char* WTXIDRELAY = "wtxidrelay";
const char *SENDTXRCNCL="sendtxrcncl"; const char* SENDTXRCNCL = "sendtxrcncl";
} // namespace NetMsgType } // namespace NetMsgType
/** All known message types. Keep this in the same order as the list of /** All known message types. Keep this in the same order as the list of
* messages above and in protocol.h. * messages above and in protocol.h.
*/ */
const static std::string allNetMessageTypes[] = { const static std::vector<std::string> g_all_net_message_types{
NetMsgType::VERSION, NetMsgType::VERSION,
NetMsgType::VERACK, NetMsgType::VERACK,
NetMsgType::ADDR, NetMsgType::ADDR,
@ -89,7 +89,6 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::WTXIDRELAY, NetMsgType::WTXIDRELAY,
NetMsgType::SENDTXRCNCL, NetMsgType::SENDTXRCNCL,
}; };
const static std::vector<std::string> allNetMessageTypesVec(std::begin(allNetMessageTypes), std::end(allNetMessageTypes));
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn) CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn)
{ {
@ -182,7 +181,7 @@ std::string CInv::ToString() const
const std::vector<std::string> &getAllNetMessageTypes() const std::vector<std::string> &getAllNetMessageTypes()
{ {
return allNetMessageTypesVec; return g_all_net_message_types;
} }
/** /**