Raven Core
3.0.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-2016 The Bitcoin Core developers
3
// Copyright (c) 2017-2019 The Raven Core developers
4
// Distributed under the MIT software license, see the accompanying
5
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7
#ifndef RAVEN_ADDRDB_H
8
#define RAVEN_ADDRDB_H
9
10
#include "
fs.h
"
11
#include "
serialize.h
"
12
13
#include <string>
14
#include <map>
15
16
class
CSubNet
;
17
class
CAddrMan
;
18
class
CDataStream
;
19
20
typedef
enum
BanReason
21
{
22
BanReasonUnknown
= 0,
23
BanReasonNodeMisbehaving
= 1,
24
BanReasonManuallyAdded
= 2
25
}
BanReason
;
26
27
class
CBanEntry
28
{
29
public
:
30
static
const
int
CURRENT_VERSION
=1;
31
int
nVersion
;
32
int64_t
nCreateTime
;
33
int64_t
nBanUntil
;
34
uint8_t
banReason
;
35
36
CBanEntry
()
37
{
38
SetNull
();
39
}
40
41
explicit
CBanEntry
(int64_t nCreateTimeIn)
42
{
43
SetNull
();
44
nCreateTime = nCreateTimeIn;
45
}
46
47
ADD_SERIALIZE_METHODS
;
48
49
template
<
typename
Stream,
typename
Operation>
50
inline
void
SerializationOp
(Stream& s, Operation ser_action) {
51
READWRITE
(this->nVersion);
52
READWRITE
(nCreateTime);
53
READWRITE
(nBanUntil);
54
READWRITE
(banReason);
55
}
56
57
void
SetNull
()
58
{
59
nVersion =
CBanEntry::CURRENT_VERSION
;
60
nCreateTime = 0;
61
nBanUntil = 0;
62
banReason =
BanReasonUnknown
;
63
}
64
65
std::string
banReasonToString
()
const
66
{
67
switch
(banReason) {
68
case
BanReasonNodeMisbehaving
:
69
return
"node misbehaving"
;
70
case
BanReasonManuallyAdded
:
71
return
"manually added"
;
72
default
:
73
return
"unknown"
;
74
}
75
}
76
};
77
78
typedef
std::map<CSubNet, CBanEntry>
banmap_t
;
79
81
class
CAddrDB
82
{
83
private
:
84
fs::path
pathAddr
;
85
public
:
86
CAddrDB
();
87
bool
Write(
const
CAddrMan
& addr);
88
bool
Read(
CAddrMan
& addr);
89
static
bool
Read(
CAddrMan
& addr,
CDataStream
& ssPeers);
90
};
91
93
class
CBanDB
94
{
95
private
:
96
fs::path
pathBanlist
;
97
public
:
98
CBanDB
();
99
bool
Write(
const
banmap_t
& banSet);
100
bool
Read(
banmap_t
& banSet);
101
};
102
103
#endif // RAVEN_ADDRDB_H
CBanEntry::SetNull
void SetNull()
Definition:
addrdb.h:57
BanReasonManuallyAdded
Definition:
addrdb.h:24
CAddrDB
Access to the (IP) address database (peers.dat)
Definition:
addrdb.h:81
BanReason
BanReason
Definition:
addrdb.h:20
CBanEntry::CBanEntry
CBanEntry(int64_t nCreateTimeIn)
Definition:
addrdb.h:41
READWRITE
#define READWRITE(obj)
Definition:
serialize.h:163
BanReasonUnknown
Definition:
addrdb.h:22
fs.h
CBanEntry::SerializationOp
void SerializationOp(Stream &s, Operation ser_action)
Definition:
addrdb.h:50
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition:
streams.h:147
CBanEntry::nVersion
int nVersion
Definition:
addrdb.h:31
CBanEntry::banReasonToString
std::string banReasonToString() const
Definition:
addrdb.h:65
CBanEntry::nCreateTime
int64_t nCreateTime
Definition:
addrdb.h:32
CBanEntry::CBanEntry
CBanEntry()
Definition:
addrdb.h:36
CSubNet
Definition:
netaddress.h:103
CAddrMan
Stochastical (IP) address manager.
Definition:
addrman.h:183
CBanDB
Access to the banlist database (banlist.dat)
Definition:
addrdb.h:93
BanReasonNodeMisbehaving
Definition:
addrdb.h:23
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition:
addrdb.h:78
serialize.h
CBanEntry::nBanUntil
int64_t nBanUntil
Definition:
addrdb.h:33
CBanDB::pathBanlist
fs::path pathBanlist
Definition:
addrdb.h:96
CBanEntry::banReason
uint8_t banReason
Definition:
addrdb.h:34
CAddrDB::pathAddr
fs::path pathAddr
Definition:
addrdb.h:84
CBanEntry::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition:
addrdb.h:47
CBanEntry::CURRENT_VERSION
static const int CURRENT_VERSION
Definition:
addrdb.h:30
CBanEntry
Definition:
addrdb.h:27
Generated on Mon Jul 29 2019 02:32:17 for Raven Core by
1.8.13