mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
net: put CJDNS prefix byte in a constant
This commit is contained in:
parent
78fd3c2672
commit
64d6f77907
2 changed files with 7 additions and 3 deletions
|
@ -81,6 +81,10 @@ static const std::array<uint8_t, 6> INTERNAL_IN_IPV6_PREFIX{
|
|||
0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 // 0xFD + sha256("bitcoin")[0:5].
|
||||
};
|
||||
|
||||
/// All CJDNS addresses start with 0xFC. See
|
||||
/// https://github.com/cjdelisle/cjdns/blob/master/doc/Whitepaper.md#pulling-it-all-together
|
||||
static constexpr uint8_t CJDNS_PREFIX{0xFC};
|
||||
|
||||
/// Size of IPv4 address (in bytes).
|
||||
static constexpr size_t ADDR_IPV4_SIZE = 4;
|
||||
|
||||
|
@ -174,7 +178,7 @@ public:
|
|||
[[nodiscard]] bool IsTor() const { return m_net == NET_ONION; }
|
||||
[[nodiscard]] bool IsI2P() const { return m_net == NET_I2P; }
|
||||
[[nodiscard]] bool IsCJDNS() const { return m_net == NET_CJDNS; }
|
||||
[[nodiscard]] bool HasCJDNSPrefix() const { return m_addr[0] == 0xfc; }
|
||||
[[nodiscard]] bool HasCJDNSPrefix() const { return m_addr[0] == CJDNS_PREFIX; }
|
||||
bool IsLocal() const;
|
||||
bool IsRoutable() const;
|
||||
bool IsInternal() const;
|
||||
|
|
|
@ -52,8 +52,8 @@ std::vector<unsigned char> NetGroupManager::GetGroup(const CNetAddr& address) co
|
|||
} else if (address.IsCJDNS()) {
|
||||
// Treat in the same way as Tor and I2P because the address in all of
|
||||
// them is "random" bytes (derived from a public key). However in CJDNS
|
||||
// the first byte is a constant 0xfc, so the random bytes come after it.
|
||||
// Thus skip the constant 8 bits at the start.
|
||||
// the first byte is a constant (see CJDNS_PREFIX), so the random bytes
|
||||
// come after it. Thus skip the constant 8 bits at the start.
|
||||
nBits = 12;
|
||||
} else if (address.IsHeNet()) {
|
||||
// for he.net, use /36 groups
|
||||
|
|
Loading…
Add table
Reference in a new issue