Bitcoin Core
21.99.0
P2P Digital Currency
src
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 <
serialize.h
>
12
13
#include <string>
14
#include <vector>
15
16
class
CAddress
;
17
class
CAddrMan
;
18
class
CDataStream
;
19
20
class
CBanEntry
21
{
22
public
:
23
static
const
int
CURRENT_VERSION
=1;
24
int
nVersion
;
25
int64_t
nCreateTime
;
26
int64_t
nBanUntil
;
27
28
CBanEntry
()
29
{
30
SetNull
();
31
}
32
33
explicit
CBanEntry
(int64_t nCreateTimeIn)
34
{
35
SetNull
();
36
nCreateTime
= nCreateTimeIn;
37
}
38
39
SERIALIZE_METHODS
(
CBanEntry
, obj)
40
{
41
uint8_t ban_reason = 2;
42
READWRITE
(obj.nVersion, obj.nCreateTime, obj.nBanUntil, ban_reason);
43
}
44
45
void
SetNull
()
46
{
47
nVersion
=
CBanEntry::CURRENT_VERSION
;
48
nCreateTime
= 0;
49
nBanUntil
= 0;
50
}
51
};
52
54
class
CAddrDB
55
{
56
private
:
57
fs::path
pathAddr
;
58
public
:
59
CAddrDB
();
60
bool
Write
(
const
CAddrMan
& addr);
61
bool
Read
(
CAddrMan
& addr);
62
static
bool
Read
(
CAddrMan
& addr,
CDataStream
& ssPeers);
63
};
64
66
class
CBanDB
67
{
68
private
:
69
const
fs::path
m_ban_list_path
;
70
public
:
71
explicit
CBanDB
(fs::path ban_list_path);
72
bool
Write
(
const
banmap_t
& banSet);
73
bool
Read
(
banmap_t
& banSet);
74
};
75
82
void
DumpAnchors
(
const
fs::path& anchors_db_path,
const
std::vector<CAddress>& anchors);
83
90
std::vector<CAddress>
ReadAnchors
(
const
fs::path& anchors_db_path);
91
92
#endif // BITCOIN_ADDRDB_H
CBanDB::Read
bool Read(banmap_t &banSet)
Definition:
addrdb.cpp:131
CBanEntry::CURRENT_VERSION
static const int CURRENT_VERSION
Definition:
addrdb.h:23
fs.h
CAddrDB::CAddrDB
CAddrDB()
Definition:
addrdb.cpp:136
CBanEntry::SetNull
void SetNull()
Definition:
addrdb.h:45
CBanDB::Write
bool Write(const banmap_t &banSet)
Definition:
addrdb.cpp:126
CBanEntry::CBanEntry
CBanEntry()
Definition:
addrdb.h:28
CAddrDB::Write
bool Write(const CAddrMan &addr)
Definition:
addrdb.cpp:141
CAddrDB
Access to the (IP) address database (peers.dat)
Definition:
addrdb.h:54
ReadAnchors
std::vector< CAddress > ReadAnchors(const fs::path &anchors_db_path)
Read the anchor IP address database (anchors.dat)
Definition:
addrdb.cpp:167
net_types.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:161
CBanEntry::nVersion
int nVersion
Definition:
addrdb.h:24
CBanEntry::nCreateTime
int64_t nCreateTime
Definition:
addrdb.h:25
READWRITE
#define READWRITE(...)
Definition:
serialize.h:175
CBanDB
Access to the banlist database (banlist.dat)
Definition:
addrdb.h:66
CBanEntry::SERIALIZE_METHODS
SERIALIZE_METHODS(CBanEntry, obj)
Definition:
addrdb.h:39
CAddrMan
Stochastical (IP) address manager.
Definition:
addrman.h:172
CAddress
A CService with information about it as peer.
Definition:
protocol.h:356
CBanEntry
Definition:
addrdb.h:20
CBanEntry::nBanUntil
int64_t nBanUntil
Definition:
addrdb.h:26
CAddrDB::Read
bool Read(CAddrMan &addr)
Definition:
addrdb.cpp:146
CBanDB::CBanDB
CBanDB(fs::path ban_list_path)
Definition:
addrdb.cpp:122
serialize.h
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition:
streams.h:204
CBanDB::m_ban_list_path
const fs::path m_ban_list_path
Definition:
addrdb.h:69
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition:
net_types.h:13
CBanEntry::CBanEntry
CBanEntry(int64_t nCreateTimeIn)
Definition:
addrdb.h:33
CAddrDB::pathAddr
fs::path pathAddr
Definition:
addrdb.h:57
Generated on Tue Apr 20 2021 20:03:40 for Bitcoin Core by
1.8.17