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 
16 class ArgsManager;
17 class CAddrMan;
18 class CAddress;
19 class CDataStream;
20 struct bilingual_str;
21 
22 bool DumpPeerAddresses(const ArgsManager& args, const CAddrMan& addr);
24 void ReadFromStream(CAddrMan& addr, CDataStream& ssPeers);
25 
27 class CBanDB
28 {
29 private:
33  static constexpr const char* JSON_KEY = "banned_nets";
34 
35  const fs::path m_banlist_dat;
36  const fs::path m_banlist_json;
37 public:
38  explicit CBanDB(fs::path ban_list_path);
39  bool Write(const banmap_t& banSet);
40 
47  bool Read(banmap_t& banSet);
48 };
49 
51 std::optional<bilingual_str> LoadAddrman(const std::vector<bool>& asmap, const ArgsManager& args, std::unique_ptr<CAddrMan>& addrman);
52 
59 void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
60 
67 std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path);
68 
69 #endif // BITCOIN_ADDRDB_H
CBanDB::Read
bool Read(banmap_t &banSet)
Read the banlist from disk.
Definition: addrdb.cpp:143
fs.h
CBanDB::JSON_KEY
static constexpr const char * JSON_KEY
JSON key under which the data is stored in the json database.
Definition: addrdb.h:33
CBanDB::m_banlist_json
const fs::path m_banlist_json
Definition: addrdb.h:36
bilingual_str
Bilingual messages:
Definition: translation.h:16
CBanDB::Write
bool Write(const banmap_t &banSet)
Definition: addrdb.cpp:130
CBanDB::m_banlist_dat
const fs::path m_banlist_dat
Definition: addrdb.h:35
ReadAnchors
std::vector< CAddress > ReadAnchors(const fs::path &anchors_db_path)
Read the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:213
DumpPeerAddresses
bool DumpPeerAddresses(const ArgsManager &args, const CAddrMan &addr)
Definition: addrdb.cpp:173
net_types.h
ReadFromStream
void ReadFromStream(CAddrMan &addr, CDataStream &ssPeers)
Only used by tests.
Definition: addrdb.cpp:179
univalue.h
DumpAnchors
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
CBanDB
Access to the banlist database (banlist.json)
Definition: addrdb.h:27
CAddrMan
Stochastical (IP) address manager.
Definition: addrman.h:142
CAddress
A CService with information about it as peer.
Definition: protocol.h:358
ArgsManager
Definition: system.h:158
CBanDB::CBanDB
CBanDB(fs::path ban_list_path)
Definition: addrdb.cpp:124
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:204
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:41
LoadAddrman
std::optional< bilingual_str > LoadAddrman(const std::vector< bool > &asmap, const ArgsManager &args, std::unique_ptr< CAddrMan > &addrman)
Returns an error string on failure.
Definition: addrdb.cpp:184