Fabcoin Core
0.16.2
P2P Digital Currency
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
addrdb.h
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2017 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 FABCOIN_ADDRDB_H
7
#define FABCOIN_ADDRDB_H
8
9
#include <
fs.h
>
10
#include <
serialize.h
>
11
12
#include <string>
13
#include <map>
14
15
class
CSubNet
;
16
class
CAddrMan
;
17
class
CDataStream
;
18
19
typedef
enum
BanReason
20
{
21
BanReasonUnknown
= 0,
22
BanReasonNodeMisbehaving
= 1,
23
BanReasonManuallyAdded
= 2
24
}
BanReason
;
25
26
class
CBanEntry
27
{
28
public
:
29
static
const
int
CURRENT_VERSION
=1;
30
int
nVersion
;
31
int64_t
nCreateTime
;
32
int64_t
nBanUntil
;
33
uint8_t
banReason
;
34
35
CBanEntry
()
36
{
37
SetNull
();
38
}
39
40
CBanEntry
(int64_t nCreateTimeIn)
41
{
42
SetNull
();
43
nCreateTime = nCreateTimeIn;
44
}
45
46
ADD_SERIALIZE_METHODS
;
47
48
template
<
typename
Stream,
typename
Operation>
49
inline
void
SerializationOp
(Stream& s, Operation ser_action) {
50
READWRITE
(this->nVersion);
51
READWRITE
(nCreateTime);
52
READWRITE
(nBanUntil);
53
READWRITE
(banReason);
54
}
55
56
void
SetNull
()
57
{
58
nVersion =
CBanEntry::CURRENT_VERSION
;
59
nCreateTime = 0;
60
nBanUntil = 0;
61
banReason =
BanReasonUnknown
;
62
}
63
64
std::string
banReasonToString
()
65
{
66
switch
(banReason) {
67
case
BanReasonNodeMisbehaving
:
68
return
"node misbehaving"
;
69
case
BanReasonManuallyAdded
:
70
return
"manually added"
;
71
default
:
72
return
"unknown"
;
73
}
74
}
75
};
76
77
typedef
std::map<CSubNet, CBanEntry>
banmap_t
;
78
80
class
CAddrDB
81
{
82
private
:
83
fs::path
pathAddr
;
84
public
:
85
CAddrDB
();
86
bool
Write(
const
CAddrMan
& addr);
87
bool
Read(
CAddrMan
& addr);
88
static
bool
Read(
CAddrMan
& addr,
CDataStream
& ssPeers);
89
};
90
92
class
CBanDB
93
{
94
private
:
95
fs::path
pathBanlist
;
96
public
:
97
CBanDB
();
98
bool
Write(
const
banmap_t
& banSet);
99
bool
Read(
banmap_t
& banSet);
100
};
101
102
#endif // FABCOIN_ADDRDB_H
CBanEntry::SetNull
void SetNull()
Definition:
addrdb.h:56
BanReasonManuallyAdded
Definition:
addrdb.h:23
CAddrDB
Access to the (IP) address database (peers.dat)
Definition:
addrdb.h:80
BanReason
BanReason
Definition:
addrdb.h:19
CBanEntry::CBanEntry
CBanEntry(int64_t nCreateTimeIn)
Definition:
addrdb.h:40
READWRITE
#define READWRITE(obj)
Definition:
serialize.h:179
BanReasonUnknown
Definition:
addrdb.h:21
fs.h
CBanEntry::SerializationOp
void SerializationOp(Stream &s, Operation ser_action)
Definition:
addrdb.h:49
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition:
streams.h:146
CBanEntry::nVersion
int nVersion
Definition:
addrdb.h:30
CBanEntry::nCreateTime
int64_t nCreateTime
Definition:
addrdb.h:31
CBanEntry::CBanEntry
CBanEntry()
Definition:
addrdb.h:35
CSubNet
Definition:
netaddress.h:102
CAddrMan
Stochastical (IP) address manager.
Definition:
addrman.h:182
CBanDB
Access to the banlist database (banlist.dat)
Definition:
addrdb.h:92
BanReasonNodeMisbehaving
Definition:
addrdb.h:22
banmap_t
std::map< CSubNet, CBanEntry > banmap_t
Definition:
addrdb.h:77
serialize.h
CBanEntry::banReasonToString
std::string banReasonToString()
Definition:
addrdb.h:64
CBanEntry::nBanUntil
int64_t nBanUntil
Definition:
addrdb.h:32
CBanDB::pathBanlist
fs::path pathBanlist
Definition:
addrdb.h:95
CBanEntry::banReason
uint8_t banReason
Definition:
addrdb.h:33
CAddrDB::pathAddr
fs::path pathAddr
Definition:
addrdb.h:83
CBanEntry::ADD_SERIALIZE_METHODS
ADD_SERIALIZE_METHODS
Definition:
addrdb.h:46
CBanEntry::CURRENT_VERSION
static const int CURRENT_VERSION
Definition:
addrdb.h:29
CBanEntry
Definition:
addrdb.h:26
Generated on Mon Oct 22 2018 15:15:25 for Fabcoin Core by
1.8.11