Bitcoin Core  24.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-2021 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 AddrMan;
18 class CAddress;
19 class CDataStream;
20 class NetGroupManager;
21 struct bilingual_str;
22 
23 bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr);
25 void ReadFromStream(AddrMan& addr, CDataStream& ssPeers);
26 
28 class CBanDB
29 {
30 private:
34  static constexpr const char* JSON_KEY = "banned_nets";
35 
38 public:
39  explicit CBanDB(fs::path ban_list_path);
40  bool Write(const banmap_t& banSet);
41 
48  bool Read(banmap_t& banSet);
49 };
50 
52 std::optional<bilingual_str> LoadAddrman(const NetGroupManager& netgroupman, const ArgsManager& args, std::unique_ptr<AddrMan>& addrman);
53 
60 void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
61 
68 std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path);
69 
70 #endif // BITCOIN_ADDRDB_H
std::vector< CAddress > ReadAnchors(const fs::path &anchors_db_path)
Read the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:223
std::optional< bilingual_str > LoadAddrman(const NetGroupManager &netgroupman, const ArgsManager &args, std::unique_ptr< AddrMan > &addrman)
Returns an error string on failure.
Definition: addrdb.cpp:185
bool DumpPeerAddresses(const ArgsManager &args, const AddrMan &addr)
Definition: addrdb.cpp:174
void DumpAnchors(const fs::path &anchors_db_path, const std::vector< CAddress > &anchors)
Dump the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:217
void ReadFromStream(AddrMan &addr, CDataStream &ssPeers)
Only used by tests.
Definition: addrdb.cpp:180
Stochastic address manager.
Definition: addrman.h:87
A CService with information about it as peer.
Definition: protocol.h:355
Access to the banlist database (banlist.json)
Definition: addrdb.h:29
bool Write(const banmap_t &banSet)
Definition: addrdb.cpp:131
const fs::path m_banlist_dat
Definition: addrdb.h:36
bool Read(banmap_t &banSet)
Read the banlist from disk.
Definition: addrdb.cpp:144
static constexpr const char * JSON_KEY
JSON key under which the data is stored in the json database.
Definition: addrdb.h:34
const fs::path m_banlist_json
Definition: addrdb.h:37
CBanDB(fs::path ban_list_path)
Definition: addrdb.cpp:125
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:186
Netgroup manager.
Definition: netgroup.h:16
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:31
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:41
ArgsManager args
Bilingual messages:
Definition: translation.h:18