Bitcoin Core 28.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
16class ArgsManager;
17class AddrMan;
18class CAddress;
19class DataStream;
20class NetGroupManager;
21
23void ReadFromStream(AddrMan& addr, DataStream& ssPeers);
24
25bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr);
26
28class CBanDB
29{
30private:
34 static constexpr const char* JSON_KEY = "banned_nets";
35
38public:
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
60void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
61
68std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path);
69
70#endif // BITCOIN_ADDRDB_H
bool DumpPeerAddresses(const ArgsManager &args, const AddrMan &addr)
Definition: addrdb.cpp:180
std::vector< CAddress > ReadAnchors(const fs::path &anchors_db_path)
Read the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:229
util::Result< std::unique_ptr< AddrMan > > LoadAddrman(const NetGroupManager &netgroupman, const ArgsManager &args)
Returns an error string on failure.
Definition: addrdb.cpp:191
void ReadFromStream(AddrMan &addr, DataStream &ssPeers)
Only used by tests.
Definition: addrdb.cpp:186
void DumpAnchors(const fs::path &anchors_db_path, const std::vector< CAddress > &anchors)
Dump the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:223
ArgsManager & args
Definition: bitcoind.cpp:277
Stochastic address manager.
Definition: addrman.h:89
A CService with information about it as peer.
Definition: protocol.h:367
Access to the banlist database (banlist.json)
Definition: addrdb.h:29
bool Write(const banmap_t &banSet)
Definition: addrdb.cpp:137
const fs::path m_banlist_dat
Definition: addrdb.h:36
bool Read(banmap_t &banSet)
Read the banlist from disk.
Definition: addrdb.cpp:150
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:131
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