Bitcoin Core  27.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 <net_types.h>
10 #include <util/fs.h>
11 #include <util/result.h>
12 
13 #include <memory>
14 #include <vector>
15 
16 class ArgsManager;
17 class AddrMan;
18 class CAddress;
19 class DataStream;
20 class NetGroupManager;
21 
23 void ReadFromStream(AddrMan& addr, DataStream& ssPeers);
24 
25 bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr);
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 
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:231
bool DumpPeerAddresses(const ArgsManager &args, const AddrMan &addr)
Definition: addrdb.cpp:182
util::Result< std::unique_ptr< AddrMan > > LoadAddrman(const NetGroupManager &netgroupman, const ArgsManager &args)
Returns an error string on failure.
Definition: addrdb.cpp:193
void ReadFromStream(AddrMan &addr, DataStream &ssPeers)
Only used by tests.
Definition: addrdb.cpp:188
void DumpAnchors(const fs::path &anchors_db_path, const std::vector< CAddress > &anchors)
Dump the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:225
ArgsManager & args
Definition: bitcoind.cpp:268
Stochastic address manager.
Definition: addrman.h:88
A CService with information about it as peer.
Definition: protocol.h:332
Access to the banlist database (banlist.json)
Definition: addrdb.h:29
bool Write(const banmap_t &banSet)
Definition: addrdb.cpp:139
const fs::path m_banlist_dat
Definition: addrdb.h:36
bool Read(banmap_t &banSet)
Read the banlist from disk.
Definition: addrdb.cpp:152
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:133
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:147
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:33
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:41