Give V1TransportDeserializer CChainParams& member

This adds a CChainParams& member to V1TransportDeserializer member, and
use it in place of many Params() calls.  In addition to reducing the
number of calls to a global, this removes a parameter from GetMessage
(and will later allow us to remove one from CMessageHeader::IsValid())
This commit is contained in:
Troy Giorshev
2020-06-08 22:26:22 -04:00
parent 5bceef6b12
commit 52d4ae46ab
3 changed files with 16 additions and 13 deletions

View File

@@ -20,7 +20,7 @@ void initialize()
void test_one_input(const std::vector<uint8_t>& buffer)
{
// Construct deserializer, with a dummy NodeId
V1TransportDeserializer deserializer{(NodeId)0, SER_NETWORK, INIT_PROTO_VERSION};
V1TransportDeserializer deserializer{Params(), (NodeId)0, SER_NETWORK, INIT_PROTO_VERSION};
const char* pch = (const char*)buffer.data();
size_t n_bytes = buffer.size();
while (n_bytes > 0) {
@@ -33,7 +33,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
if (deserializer.Complete()) {
const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
uint32_t out_err_raw_size{0};
Optional<CNetMessage> result{deserializer.GetMessage(Params().MessageStart(), m_time, out_err_raw_size)};
Optional<CNetMessage> result{deserializer.GetMessage(m_time, out_err_raw_size)};
if (result) {
assert(result->m_command.size() <= CMessageHeader::COMMAND_SIZE);
assert(result->m_raw_message_size <= buffer.size());