Bitcoin Core 22.99.0
P2P Digital Currency
addrdb.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2020 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_ADDRDB_H
7#define BITCOIN_ADDRDB_H
8
9#include <fs.h>
10#include <net_types.h> // For banmap_t
11#include <univalue.h>
12
13#include <optional>
14#include <vector>
15
16class ArgsManager;
17class AddrMan;
18class CAddress;
19class CDataStream;
20struct bilingual_str;
21
22bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr);
24void ReadFromStream(AddrMan& addr, CDataStream& ssPeers);
25
27class CBanDB
28{
29private:
33 static constexpr const char* JSON_KEY = "banned_nets";
34
37public:
38 explicit CBanDB(fs::path ban_list_path);
39 bool Write(const banmap_t& banSet);
40
47 bool Read(banmap_t& banSet);
48};
49
51std::optional<bilingual_str> LoadAddrman(const std::vector<bool>& asmap, const ArgsManager& args, std::unique_ptr<AddrMan>& addrman);
52
59void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
60
67std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path);
68
69#endif // BITCOIN_ADDRDB_H
bool DumpPeerAddresses(const ArgsManager &args, const AddrMan &addr)
Definition: addrdb.cpp:173
std::vector< CAddress > ReadAnchors(const fs::path &anchors_db_path)
Read the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:213
void DumpAnchors(const fs::path &anchors_db_path, const std::vector< CAddress > &anchors)
Dump the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:207
void ReadFromStream(AddrMan &addr, CDataStream &ssPeers)
Only used by tests.
Definition: addrdb.cpp:179
std::optional< bilingual_str > LoadAddrman(const std::vector< bool > &asmap, const ArgsManager &args, std::unique_ptr< AddrMan > &addrman)
Returns an error string on failure.
Definition: addrdb.cpp:184
Stochastic address manager.
Definition: addrman.h:55
A CService with information about it as peer.
Definition: protocol.h:359
Access to the banlist database (banlist.json)
Definition: addrdb.h:28
bool Write(const banmap_t &banSet)
Definition: addrdb.cpp:130
const fs::path m_banlist_dat
Definition: addrdb.h:35
bool Read(banmap_t &banSet)
Read the banlist from disk.
Definition: addrdb.cpp:143
static constexpr const char * JSON_KEY
JSON key under which the data is stored in the json database.
Definition: addrdb.h:33
const fs::path m_banlist_json
Definition: addrdb.h:36
CBanDB(fs::path ban_list_path)
Definition: addrdb.cpp:124
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:205
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
Definition: fs.h:34
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:41
Bilingual messages:
Definition: translation.h:16