Bitcoin Core  31.0.0
P2P Digital Currency
asmap.h
Go to the documentation of this file.
1 // Copyright (c) 2019-present The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_UTIL_ASMAP_H
6 #define BITCOIN_UTIL_ASMAP_H
7 
8 #include <uint256.h>
9 #include <util/fs.h>
10 
11 #include <cstddef>
12 #include <cstdint>
13 #include <span>
14 #include <vector>
15 
16 uint32_t Interpret(std::span<const std::byte> asmap, std::span<const std::byte> ip);
17 
18 bool SanityCheckAsmap(std::span<const std::byte> asmap, int bits);
20 bool CheckStandardAsmap(std::span<const std::byte> data);
21 
23 std::vector<std::byte> DecodeAsmap(fs::path path);
25 uint256 AsmapVersion(std::span<const std::byte> data);
26 
27 #endif // BITCOIN_UTIL_ASMAP_H
bool SanityCheckAsmap(std::span< const std::byte > asmap, int bits)
Validates ASMap structure by simulating all possible execution paths.
Definition: asmap.cpp:239
bool CheckStandardAsmap(std::span< const std::byte > data)
Check standard asmap data (128 bits for IPv6)
Definition: asmap.cpp:310
uint256 AsmapVersion(std::span< const std::byte > data)
Calculate the asmap version, a checksum identifying the asmap being used.
Definition: asmap.cpp:348
std::vector< std::byte > DecodeAsmap(fs::path path)
Read and check asmap from provided binary file.
Definition: asmap.cpp:322
static CService ip(uint32_t i)
256-bit opaque blob.
Definition: uint256.h:195
uint32_t Interpret(std::span< const std::byte > asmap, std::span< const std::byte > ip)
Execute the ASMap bytecode to find the ASN for an IP.
Definition: asmap.cpp:182
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:33