aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
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/kernel
parent744e0e36703e26d06bc5cd1ef36a1c8568e71d05 (diff)
parentd5067651991f3e6daf456ba13c7036ddc4545352 (diff)
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/kernel')
-rw-r--r--src/kernel/chainparams.cpp3
-rw-r--r--src/kernel/chainparams.h16
-rw-r--r--src/kernel/messagestartchars.h13
3 files changed, 18 insertions, 14 deletions
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 733a3339b3..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>
@@ -359,7 +360,7 @@ public:
HashWriter h{};
h << consensus.signet_challenge;
uint256 hash = h.GetHash();
- memcpy(pchMessageStart, hash.begin(), 4);
+ std::copy_n(hash.begin(), 4, pchMessageStart.begin());
nDefaultPort = 38333;
nPruneAfterHeight = 1000;
diff --git a/src/kernel/chainparams.h b/src/kernel/chainparams.h
index 2d38af609c..63837bb23e 100644
--- a/src/kernel/chainparams.h
+++ b/src/kernel/chainparams.h
@@ -7,9 +7,8 @@
#define BITCOIN_KERNEL_CHAINPARAMS_H
#include <consensus/params.h>
-#include <netaddress.h>
+#include <kernel/messagestartchars.h>
#include <primitives/block.h>
-#include <protocol.h>
#include <uint256.h>
#include <util/chaintype.h>
#include <util/hash_type.h>
@@ -87,17 +86,8 @@ 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
- {
- return net == NET_I2P ? I2P_SAM31_PORT : GetDefaultPort();
- }
- uint16_t GetDefaultPort(const std::string& addr) const
- {
- CNetAddr a;
- return a.SetSpecial(addr) ? GetDefaultPort(a.GetNetwork()) : GetDefaultPort();
- }
const CBlock& GenesisBlock() const { return genesis; }
/** Default value for -checkmempool and -checkblockindex argument */
@@ -165,7 +155,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