Bitcoin ABC 0.30.5
P2P Digital Currency
addrdb.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 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 <serialize.h>
11#include <util/fs.h>
12#include <util/result.h>
13
14#include <memory>
15#include <string>
16#include <vector>
17
18class ArgsManager;
19class AddrMan;
20class CAddress;
21class CDataStream;
22class CChainParams;
23
24bool DumpPeerAddresses(const CChainParams &chainParams, const ArgsManager &args,
25 const AddrMan &addr);
27void ReadFromStream(const CChainParams &chainParams, AddrMan &addr,
28 CDataStream &ssPeers);
29
30class CBanEntry {
31public:
32 static const int CURRENT_VERSION = 1;
34 int64_t nCreateTime;
35 int64_t nBanUntil;
36
38
39 explicit CBanEntry(int64_t nCreateTimeIn) {
40 SetNull();
41 nCreateTime = nCreateTimeIn;
42 }
43
46 uint8_t ban_reason = 2;
47 READWRITE(obj.nVersion, obj.nCreateTime, obj.nBanUntil, ban_reason);
48 }
49
50 void SetNull() {
52 nCreateTime = 0;
53 nBanUntil = 0;
54 }
55};
56
58class CBanDB {
59private:
62
63public:
64 CBanDB(fs::path ban_list_path, const CChainParams &_chainParams);
65 bool Write(const banmap_t &banSet);
66 bool Read(banmap_t &banSet);
67};
68
71LoadAddrman(const CChainParams &chainparams, const std::vector<bool> &asmap,
72 const ArgsManager &args);
73
80void DumpAnchors(const CChainParams &chainParams,
81 const fs::path &anchors_db_path,
82 const std::vector<CAddress> &anchors);
83
91std::vector<CAddress> ReadAnchors(const CChainParams &chainParams,
92 const fs::path &anchors_db_path);
93
94#endif // BITCOIN_ADDRDB_H
std::vector< CAddress > ReadAnchors(const CChainParams &chainParams, const fs::path &anchors_db_path)
Read the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:225
util::Result< std::unique_ptr< AddrMan > > LoadAddrman(const CChainParams &chainparams, const std::vector< bool > &asmap, const ArgsManager &args)
Returns an error string on failure.
Definition: addrdb.cpp:165
void ReadFromStream(const CChainParams &chainParams, AddrMan &addr, CDataStream &ssPeers)
Only used by tests.
Definition: addrdb.cpp:159
bool DumpPeerAddresses(const CChainParams &chainParams, const ArgsManager &args, const AddrMan &addr)
Definition: addrdb.cpp:152
void DumpAnchors(const CChainParams &chainParams, const fs::path &anchors_db_path, const std::vector< CAddress > &anchors)
Dump the anchor IP address database (anchors.dat)
Definition: addrdb.cpp:215
Stochastic address manager.
Definition: addrman.h:68
A CService with information about it as peer.
Definition: protocol.h:442
Access to the banlist database (banlist.dat)
Definition: addrdb.h:58
bool Write(const banmap_t &banSet)
Definition: addrdb.cpp:131
const fs::path m_ban_list_path
Definition: addrdb.h:60
CBanDB(fs::path ban_list_path, const CChainParams &_chainParams)
Definition: addrdb.cpp:128
bool Read(banmap_t &banSet)
Definition: addrdb.cpp:136
const CChainParams & chainParams
Definition: addrdb.h:61
Definition: addrdb.h:30
static const int CURRENT_VERSION
Definition: addrdb.h:32
int64_t nCreateTime
Definition: addrdb.h:34
CBanEntry()
Definition: addrdb.h:37
CBanEntry(int64_t nCreateTimeIn)
Definition: addrdb.h:39
SERIALIZE_METHODS(CBanEntry, obj)
Definition: addrdb.h:44
void SetNull()
Definition: addrdb.h:50
int nVersion
Definition: addrdb.h:33
int64_t nBanUntil
Definition: addrdb.h:35
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:80
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:177
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Definition: fs.h:30
std::map< CSubNet, CBanEntry > banmap_t
Definition: net_types.h:13
#define READWRITE(...)
Definition: serialize.h:166