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.
6 #ifndef BITCOIN_ADDRDB_H
7 #define BITCOIN_ADDRDB_H
10 #include "serialize.h"
19 typedef enum BanReason
22 BanReasonNodeMisbehaving
= 1,
23 BanReasonManuallyAdded
= 2
29 static const int CURRENT_VERSION
=1;
40 CBanEntry(int64_t nCreateTimeIn
)
43 nCreateTime
= nCreateTimeIn
;
46 ADD_SERIALIZE_METHODS
;
48 template <typename Stream
, typename Operation
>
49 inline void SerializationOp(Stream
& s
, Operation ser_action
) {
50 READWRITE(this->nVersion
);
51 READWRITE(nCreateTime
);
58 nVersion
= CBanEntry::CURRENT_VERSION
;
61 banReason
= BanReasonUnknown
;
64 std::string
banReasonToString()
67 case BanReasonNodeMisbehaving
:
68 return "node misbehaving";
69 case BanReasonManuallyAdded
:
70 return "manually added";
77 typedef std::map
<CSubNet
, CBanEntry
> banmap_t
;
79 /** Access to the (IP) address database (peers.dat) */
86 bool Write(const CAddrMan
& addr
);
87 bool Read(CAddrMan
& addr
);
88 bool Read(CAddrMan
& addr
, CDataStream
& ssPeers
);
91 /** Access to the banlist database (banlist.dat) */
98 bool Write(const banmap_t
& banSet
);
99 bool Read(banmap_t
& banSet
);
102 #endif // BITCOIN_ADDRDB_H