diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/chainparams.cpp | 3 | ||||
-rw-r--r-- | src/kernel/chainparams.h | 16 | ||||
-rw-r--r-- | src/kernel/messagestartchars.h | 13 |
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 |