mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-30 18:35:54 +02:00
net: make the list of known message types a compile time constant
Turn the `std::vector` to `std::array` because it is cheaper and allows us to have the number of the messages as a compile time constant: `ALL_NET_MESSAGE_TYPES.size()` which can be used in future code to build other `std::array`s with that size.
This commit is contained in:
@@ -21,13 +21,12 @@
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<std::string> g_all_messages;
|
||||
auto g_all_messages = ALL_NET_MESSAGE_TYPES;
|
||||
|
||||
void initialize_p2p_transport_serialization()
|
||||
{
|
||||
ECC_Start();
|
||||
SelectParams(ChainType::REGTEST);
|
||||
g_all_messages = getAllNetMessageTypes();
|
||||
std::sort(g_all_messages.begin(), g_all_messages.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void initialize_process_message()
|
||||
{
|
||||
if (const auto val{std::getenv("LIMIT_TO_MESSAGE_TYPE")}) {
|
||||
LIMIT_TO_MESSAGE_TYPE = val;
|
||||
Assert(std::count(getAllNetMessageTypes().begin(), getAllNetMessageTypes().end(), LIMIT_TO_MESSAGE_TYPE)); // Unknown message type passed
|
||||
Assert(std::count(ALL_NET_MESSAGE_TYPES.begin(), ALL_NET_MESSAGE_TYPES.end(), LIMIT_TO_MESSAGE_TYPE)); // Unknown message type passed
|
||||
}
|
||||
|
||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
||||
|
||||
Reference in New Issue
Block a user