aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/addrdb.cpp2
-rw-r--r--src/kernel/chainparams.cpp1
-rw-r--r--src/kernel/chainparams.h6
-rw-r--r--src/kernel/messagestartchars.h13
-rw-r--r--src/net.cpp2
-rw-r--r--src/net.h5
-rw-r--r--src/node/blockstorage.cpp3
-rw-r--r--src/node/blockstorage.h4
-rw-r--r--src/protocol.h2
-rw-r--r--src/test/net_tests.cpp2
-rw-r--r--src/validation.cpp3
12 files changed, 31 insertions, 13 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index feed4a0061..e542a067a4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -191,6 +191,7 @@ BITCOIN_CORE_H = \
kernel/mempool_options.h \
kernel/mempool_persist.h \
kernel/mempool_removal_reason.h \
+ kernel/messagestartchars.h \
kernel/notifications_interface.h \
kernel/validation_cache_sizes.h \
key.h \
diff --git a/src/addrdb.cpp b/src/addrdb.cpp
index 6b21d3a1ed..50f576624c 100644
--- a/src/addrdb.cpp
+++ b/src/addrdb.cpp
@@ -90,7 +90,7 @@ void DeserializeDB(Stream& stream, Data&& data, bool fCheckSum = true)
{
HashVerifier verifier{stream};
// de-serialize file header (network specific magic number) and ..
- CMessageHeader::MessageStartChars pchMsgTmp;
+ MessageStartChars pchMsgTmp;
verifier >> pchMsgTmp;
// ... verify the network matches ours
if (pchMsgTmp != Params().MessageStart()) {
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index c41559ad98..6cee379faf 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -10,6 +10,7 @@
#include <consensus/merkle.h>
#include <consensus/params.h>
#include <hash.h>
+#include <kernel/messagestartchars.h>
#include <logging.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
diff --git a/src/kernel/chainparams.h b/src/kernel/chainparams.h
index 2d38af609c..f1df878f60 100644
--- a/src/kernel/chainparams.h
+++ b/src/kernel/chainparams.h
@@ -7,9 +7,9 @@
#define BITCOIN_KERNEL_CHAINPARAMS_H
#include <consensus/params.h>
+#include <kernel/messagestartchars.h>
#include <netaddress.h>
#include <primitives/block.h>
-#include <protocol.h>
#include <uint256.h>
#include <util/chaintype.h>
#include <util/hash_type.h>
@@ -87,7 +87,7 @@ public:
};
const Consensus::Params& GetConsensus() const { return consensus; }
- const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
+ const MessageStartChars& MessageStart() const { return pchMessageStart; }
uint16_t GetDefaultPort() const { return nDefaultPort; }
uint16_t GetDefaultPort(Network net) const
{
@@ -165,7 +165,7 @@ protected:
CChainParams() {}
Consensus::Params consensus;
- CMessageHeader::MessageStartChars pchMessageStart;
+ MessageStartChars pchMessageStart;
uint16_t nDefaultPort;
uint64_t nPruneAfterHeight;
uint64_t m_assumed_blockchain_size;
diff --git a/src/kernel/messagestartchars.h b/src/kernel/messagestartchars.h
new file mode 100644
index 0000000000..829616dc8b
--- /dev/null
+++ b/src/kernel/messagestartchars.h
@@ -0,0 +1,13 @@
+// Copyright (c) 2023 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_KERNEL_MESSAGESTARTCHARS_H
+#define BITCOIN_KERNEL_MESSAGESTARTCHARS_H
+
+#include <array>
+#include <cstdint>
+
+using MessageStartChars = std::array<uint8_t, 4>;
+
+#endif // BITCOIN_KERNEL_MESSAGESTARTCHARS_H
diff --git a/src/net.cpp b/src/net.cpp
index d091db74c4..ddbf9a6e3c 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1144,7 +1144,7 @@ bool V2Transport::ProcessReceivedKeyBytes() noexcept
// they receive our uniformly random key and garbage, but detecting this case specially
// means we can log it.
static constexpr std::array<uint8_t, 12> MATCH = {'v', 'e', 'r', 's', 'i', 'o', 'n', 0, 0, 0, 0, 0};
- static constexpr size_t OFFSET = std::tuple_size_v<CMessageHeader::MessageStartChars>;
+ static constexpr size_t OFFSET = std::tuple_size_v<MessageStartChars>;
if (!m_initiating && m_recv_buffer.size() >= OFFSET + MATCH.size()) {
if (std::equal(MATCH.begin(), MATCH.end(), m_recv_buffer.begin() + OFFSET)) {
LogPrint(BCLog::NET, "V2 transport error: V1 peer with wrong MessageStart %s\n",
diff --git a/src/net.h b/src/net.h
index e1d8995a8e..669ff68cb4 100644
--- a/src/net.h
+++ b/src/net.h
@@ -10,15 +10,16 @@
#include <chainparams.h>
#include <common/bloom.h>
#include <compat/compat.h>
-#include <node/connection_types.h>
#include <consensus/amount.h>
#include <crypto/siphash.h>
#include <hash.h>
#include <i2p.h>
+#include <kernel/messagestartchars.h>
#include <net_permissions.h>
#include <netaddress.h>
#include <netbase.h>
#include <netgroup.h>
+#include <node/connection_types.h>
#include <policy/feerate.h>
#include <protocol.h>
#include <random.h>
@@ -360,7 +361,7 @@ public:
class V1Transport final : public Transport
{
private:
- CMessageHeader::MessageStartChars m_magic_bytes;
+ MessageStartChars m_magic_bytes;
const NodeId m_node_id; // Only for logging
mutable Mutex m_recv_mutex; //!< Lock for receive state
mutable CHash256 hasher GUARDED_BY(m_recv_mutex);
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 2e4e077f18..253dee088e 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -11,6 +11,7 @@
#include <flatfile.h>
#include <hash.h>
#include <kernel/chainparams.h>
+#include <kernel/messagestartchars.h>
#include <logging.h>
#include <pow.h>
#include <reverse_iterator.h>
@@ -927,7 +928,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
}
try {
- CMessageHeader::MessageStartChars blk_start;
+ MessageStartChars blk_start;
unsigned int blk_size;
filein >> blk_start >> blk_size;
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index 4b57637427..b251ece31f 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -11,7 +11,7 @@
#include <kernel/blockmanager_opts.h>
#include <kernel/chainparams.h>
#include <kernel/cs_main.h>
-#include <protocol.h>
+#include <kernel/messagestartchars.h>
#include <sync.h>
#include <util/fs.h>
#include <util/hasher.h>
@@ -73,7 +73,7 @@ static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
/** Size of header written by WriteBlockToDisk before a serialized CBlock */
-static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = std::tuple_size_v<CMessageHeader::MessageStartChars> + sizeof(unsigned int);
+static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = std::tuple_size_v<MessageStartChars> + sizeof(unsigned int);
extern std::atomic_bool fReindex;
diff --git a/src/protocol.h b/src/protocol.h
index cb7f9666e1..22e2108afb 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -6,6 +6,7 @@
#ifndef BITCOIN_PROTOCOL_H
#define BITCOIN_PROTOCOL_H
+#include <kernel/messagestartchars.h> // IWYU pragma: export
#include <netaddress.h>
#include <primitives/transaction.h>
#include <serialize.h>
@@ -27,7 +28,6 @@
class CMessageHeader
{
public:
- using MessageStartChars = std::array<uint8_t, 4>;
static constexpr size_t COMMAND_SIZE = 12;
static constexpr size_t MESSAGE_SIZE_SIZE = 4;
static constexpr size_t CHECKSUM_SIZE = 4;
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 3eb7bdec62..34d7867079 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -1114,7 +1114,7 @@ public:
}
/** Send V1 version message header to the transport. */
- void SendV1Version(const CMessageHeader::MessageStartChars& magic)
+ void SendV1Version(const MessageStartChars& magic)
{
CMessageHeader hdr(magic, "version", 126 + InsecureRandRange(11));
CDataStream ser(SER_NETWORK, CLIENT_VERSION);
diff --git a/src/validation.cpp b/src/validation.cpp
index 4bb648d1e5..8d4b8386e8 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -23,6 +23,7 @@
#include <hash.h>
#include <kernel/chainparams.h>
#include <kernel/mempool_entry.h>
+#include <kernel/messagestartchars.h>
#include <kernel/notifications_interface.h>
#include <logging.h>
#include <logging/timer.h>
@@ -4533,7 +4534,7 @@ void ChainstateManager::LoadExternalBlockFile(
unsigned int nSize = 0;
try {
// locate a header
- CMessageHeader::MessageStartChars buf;
+ MessageStartChars buf;
blkdat.FindByte(std::byte(params.MessageStart()[0]));
nRewind = blkdat.GetPos() + 1;
blkdat >> buf;