mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
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:
11
src/net.h
11
src/net.h
@@ -10,6 +10,7 @@
|
||||
#include <addrman.h>
|
||||
#include <amount.h>
|
||||
#include <bloom.h>
|
||||
#include <chainparams.h>
|
||||
#include <compat.h>
|
||||
#include <crypto/siphash.h>
|
||||
#include <hash.h>
|
||||
@@ -732,13 +733,14 @@ public:
|
||||
// read and deserialize data
|
||||
virtual int Read(const char *data, unsigned int bytes) = 0;
|
||||
// decomposes a message from the context
|
||||
virtual Optional<CNetMessage> GetMessage(const CMessageHeader::MessageStartChars& message_start, std::chrono::microseconds time, uint32_t& out_err) = 0;
|
||||
virtual Optional<CNetMessage> GetMessage(std::chrono::microseconds time, uint32_t& out_err) = 0;
|
||||
virtual ~TransportDeserializer() {}
|
||||
};
|
||||
|
||||
class V1TransportDeserializer final : public TransportDeserializer
|
||||
{
|
||||
private:
|
||||
const CChainParams& m_chain_params;
|
||||
const NodeId m_node_id; // Only for logging
|
||||
mutable CHash256 hasher;
|
||||
mutable uint256 data_hash;
|
||||
@@ -765,8 +767,9 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
V1TransportDeserializer(const NodeId node_id, int nTypeIn, int nVersionIn)
|
||||
: m_node_id(node_id),
|
||||
V1TransportDeserializer(const CChainParams& chain_params, const NodeId node_id, int nTypeIn, int nVersionIn)
|
||||
: m_chain_params(chain_params),
|
||||
m_node_id(node_id),
|
||||
hdrbuf(nTypeIn, nVersionIn),
|
||||
vRecv(nTypeIn, nVersionIn)
|
||||
{
|
||||
@@ -789,7 +792,7 @@ public:
|
||||
if (ret < 0) Reset();
|
||||
return ret;
|
||||
}
|
||||
Optional<CNetMessage> GetMessage(const CMessageHeader::MessageStartChars& message_start, std::chrono::microseconds time, uint32_t& out_err_raw_size) override;
|
||||
Optional<CNetMessage> GetMessage(std::chrono::microseconds time, uint32_t& out_err_raw_size) override;
|
||||
};
|
||||
|
||||
/** The TransportSerializer prepares messages for the network transport
|
||||
|
||||
Reference in New Issue
Block a user