aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-09-14 10:39:10 +0100
committerfanquake <fanquake@gmail.com>2023-09-14 11:11:38 +0100
commit1e9d367d0d39f9252bf8f738c216c0fe4c64a898 (patch)
treebcd816ec2019bba21add1328998d08ec789eb6ae /src/node
parent744e0e36703e26d06bc5cd1ef36a1c8568e71d05 (diff)
parentd5067651991f3e6daf456ba13c7036ddc4545352 (diff)
downloadbitcoin-1e9d367d0d39f9252bf8f738c216c0fe4c64a898.tar.xz
Merge bitcoin/bitcoin#28423: kernel: Remove protocol.h/netaddress.h/compat.h from kernel headers
d5067651991f3e6daf456ba13c7036ddc4545352 [refactor] Remove compat.h from kernel headers (TheCharlatan) 36193af47c8dcff53e59498c416b85b59e0d0f91 [refactor] Remove netaddress.h from kernel headers (TheCharlatan) 2b08c55f01996e0b05763f05eac50b83ba9d5a8e [refactor] Add CChainParams member to CConnman (TheCharlatan) f0d1d8b35c3aa9f2f923f74e3dbbf1e5ece4cd2f [refactor] Add missing includes for next commit (TheCharlatan) 534b314a7401d44f51aabd4565f97be9ee411740 kernel: Move MessageStartChars to its own file (TheCharlatan) 9be330b654cfbd792620295f3867f592059d6a7a [refactor] Define MessageStartChars as std::array (TheCharlatan) 37e2b011136ca1cf00dfb9e575d12f0d035a6a2c [refactor] Allow std::array<std::byte, N> in serialize.h (MarcoFalke) Pull request description: This removes the non-consensus critical `protocol.h` and `netaddress.h` headers from the kernel headers. With this patch, they are no longer required to include in order to use the libbitcoinkernel library. This also allows for the removal of the `compat.h` header from the kernel headers. As an added future benefit it also reduces the number of of kernel headers that include the platform specific `bitcoin-config.h`. For those interested, the currently required kernel headers can be inspected visually with the [sourcetrail](https://github.com/CoatiSoftware/Sourcetrail) tool by looking at the required includes of `bitcoin-chainstate.cpp`. --- This is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587), namely its stage 1 step 3: Decouple most non-consensus headers from libbitcoinkernel. ACKs for top commit: stickies-v: re-ACK d506765 hebasto: ACK d5067651991f3e6daf456ba13c7036ddc4545352. ajtowns: utACK d5067651991f3e6daf456ba13c7036ddc4545352 MarcoFalke: lgtm ACK d5067651991f3e6daf456ba13c7036ddc4545352 🍛 Tree-SHA512: 6f90ea510a302c2927e84d16900e89997c39b8ff3ce9d4effeb8a134bd29cc52bd9e81e51aaa11f7496bad00025b78a58b88c5a9e0bb3f4ebbe9a76309215fb7
Diffstat (limited to 'src/node')
-rw-r--r--src/node/blockstorage.cpp6
-rw-r--r--src/node/blockstorage.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index f43c5cbec5..f21c94c0a0 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>
@@ -21,6 +22,7 @@
#include <util/batchpriority.h>
#include <util/fs.h>
#include <util/signalinterrupt.h>
+#include <util/strencodings.h>
#include <util/translation.h>
#include <validation.h>
@@ -927,12 +929,12 @@ 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;
- if (memcmp(blk_start, GetParams().MessageStart(), CMessageHeader::MESSAGE_START_SIZE)) {
+ if (blk_start != GetParams().MessageStart()) {
return error("%s: Block magic mismatch for %s: %s versus expected %s", __func__, pos.ToString(),
HexStr(blk_start),
HexStr(GetParams().MessageStart()));
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index c79fd2c6a1..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 = CMessageHeader::MESSAGE_START_SIZE + sizeof(unsigned int);
+static constexpr size_t BLOCK_SERIALIZATION_HEADER_SIZE = std::tuple_size_v<MessageStartChars> + sizeof(unsigned int);
extern std::atomic_bool fReindex;