Skip to content

Commit c4b8dd2

Browse files
committed
Merge #17297: refactor: Remove addrdb.h dependency from node.h
f44abe4 refactor: Remove addrdb.h dependency from node.h (Hennadii Stepanov) Pull request description: `node.h` includes `addrdb.h` just for the sake of `banmap_t` type. This PR makes dependencies simpler and explicit. ~Also needless `typedef` has been removed from `enum BanReason`.~ ACKs for top commit: laanwj: ACK f44abe4 practicalswift: ACK f44abe4 Tree-SHA512: 33a1be20e5c629daf4a61ebbf93ea6494b9256887cebd4974de4782f6d324404b6cc84909533d9502b2cc19902083f1f9307d4fb7231e67db5b412b842d13072
2 parents 463eab5 + f44abe4 commit c4b8dd2

File tree

7 files changed

+23
-6
lines changed

7 files changed

+23
-6
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ BITCOIN_CORE_H = \
152152
net.h \
153153
net_permissions.h \
154154
net_processing.h \
155+
net_types.h \
155156
netaddress.h \
156157
netbase.h \
157158
netmessagemaker.h \

src/addrdb.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define BITCOIN_ADDRDB_H
88

99
#include <fs.h>
10+
#include <net_types.h> // For banmap_t
1011
#include <serialize.h>
1112

1213
#include <string>
@@ -79,8 +80,6 @@ class CBanEntry
7980
}
8081
};
8182

82-
typedef std::map<CSubNet, CBanEntry> banmap_t;
83-
8483
/** Access to the (IP) address database (peers.dat) */
8584
class CAddrDB
8685
{

src/banman.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <addrdb.h>
1212
#include <fs.h>
13+
#include <net_types.h> // For banmap_t
1314
#include <sync.h>
1415

1516
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")

src/interfaces/node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#ifndef BITCOIN_INTERFACES_NODE_H
66
#define BITCOIN_INTERFACES_NODE_H
77

8-
#include <addrdb.h> // For banmap_t
98
#include <amount.h> // For CAmount
109
#include <net.h> // For CConnman::NumConnections
10+
#include <net_types.h> // For banmap_t
1111
#include <netaddress.h> // For Network
1212
#include <support/allocators/secure.h> // For SecureString
1313

src/net_types.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2019 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_NET_TYPES_H
6+
#define BITCOIN_NET_TYPES_H
7+
8+
#include <map>
9+
10+
class CBanEntry;
11+
class CSubNet;
12+
13+
using banmap_t = std::map<CSubNet, CBanEntry>;
14+
15+
#endif // BITCOIN_NET_TYPES_H

src/qt/bantablemodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#include <qt/bantablemodel.h>
66

7-
#include <qt/clientmodel.h>
8-
97
#include <interfaces/node.h>
8+
#include <net_types.h> // For banmap_t
9+
#include <qt/clientmodel.h>
1010

1111
#include <algorithm>
1212

src/rpc/net.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#include <clientversion.h>
99
#include <core_io.h>
1010
#include <net.h>
11-
#include <net_processing.h>
1211
#include <net_permissions.h>
12+
#include <net_processing.h>
13+
#include <net_types.h> // For banmap_t
1314
#include <netbase.h>
1415
#include <node/context.h>
1516
#include <policy/settings.h>

0 commit comments

Comments
 (0)