Page MenuHomePhabricator

D1795.diff
No OneTemporary

D1795.diff

diff --git a/src/Makefile.am b/src/Makefile.am
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -101,6 +101,7 @@
# bitcoin core #
BITCOIN_CORE_H = \
addrdb.h \
+ address.h \
addrman.h \
base58.h \
bloom.h \
@@ -384,6 +385,7 @@
libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_common_a_SOURCES = \
+ address.cpp \
amount.cpp \
base58.cpp \
cashaddr.cpp \
diff --git a/src/address.h b/src/address.h
new file mode 100644
--- /dev/null
+++ b/src/address.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2018 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_CADDRESS_H
+#define BITCOIN_CADDRESS_H
+
+#include "protocol.h"
+#include "serialize.h"
+
+/**
+ * A CService with information about it as peer.
+ */
+class CAddress : public CService {
+public:
+ CAddress();
+ explicit CAddress(CService ipIn, ServiceFlags nServicesIn);
+
+ void Init();
+
+ ADD_SERIALIZE_METHODS;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream &s, Operation ser_action) {
+ if (ser_action.ForRead()) Init();
+ int nVersion = s.GetVersion();
+ if (s.GetType() & SER_DISK) READWRITE(nVersion);
+ if ((s.GetType() & SER_DISK) ||
+ (nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH)))
+ READWRITE(nTime);
+ uint64_t nServicesInt = nServices;
+ READWRITE(nServicesInt);
+ nServices = (ServiceFlags)nServicesInt;
+ READWRITE(*(CService *)this);
+ }
+
+ // TODO: make private (improves encapsulation)
+public:
+ ServiceFlags nServices;
+
+ // disk and network only
+ unsigned int nTime;
+};
+
+#endif // BITCOIN_CADDRESS_H
diff --git a/src/address.cpp b/src/address.cpp
new file mode 100644
--- /dev/null
+++ b/src/address.cpp
@@ -0,0 +1,19 @@
+// Copyright (c) 2018 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "address.h"
+
+CAddress::CAddress() : CService() {
+ Init();
+}
+
+CAddress::CAddress(CService ipIn, ServiceFlags nServicesIn) : CService(ipIn) {
+ Init();
+ nServices = nServicesIn;
+}
+
+void CAddress::Init() {
+ nServices = NODE_NONE;
+ nTime = 100000000;
+}
diff --git a/src/addrman.h b/src/addrman.h
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -6,6 +6,7 @@
#ifndef BITCOIN_ADDRMAN_H
#define BITCOIN_ADDRMAN_H
+#include "address.h"
#include "netaddress.h"
#include "protocol.h"
#include "random.h"
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -9,6 +9,7 @@
#include "net.h"
+#include "address.h"
#include "addrman.h"
#include "chainparams.h"
#include "clientversion.h"
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -5,6 +5,7 @@
#include "net_processing.h"
+#include "address.h"
#include "addrman.h"
#include "arith_uint256.h"
#include "blockencodings.h"
diff --git a/src/protocol.h b/src/protocol.h
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -349,40 +349,6 @@
return services & NODE_NETWORK;
}
-/**
- * A CService with information about it as peer.
- */
-class CAddress : public CService {
-public:
- CAddress();
- explicit CAddress(CService ipIn, ServiceFlags nServicesIn);
-
- void Init();
-
- ADD_SERIALIZE_METHODS;
-
- template <typename Stream, typename Operation>
- inline void SerializationOp(Stream &s, Operation ser_action) {
- if (ser_action.ForRead()) Init();
- int nVersion = s.GetVersion();
- if (s.GetType() & SER_DISK) READWRITE(nVersion);
- if ((s.GetType() & SER_DISK) ||
- (nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH)))
- READWRITE(nTime);
- uint64_t nServicesInt = nServices;
- READWRITE(nServicesInt);
- nServices = (ServiceFlags)nServicesInt;
- READWRITE(*(CService *)this);
- }
-
- // TODO: make private (improves encapsulation)
-public:
- ServiceFlags nServices;
-
- // disk and network only
- unsigned int nTime;
-};
-
/** getdata message type flags */
const uint32_t MSG_TYPE_MASK = 0xffffffff >> 3;
diff --git a/src/protocol.cpp b/src/protocol.cpp
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -179,20 +179,6 @@
return false;
}
-CAddress::CAddress() : CService() {
- Init();
-}
-
-CAddress::CAddress(CService ipIn, ServiceFlags nServicesIn) : CService(ipIn) {
- Init();
- nServices = nServicesIn;
-}
-
-void CAddress::Init() {
- nServices = NODE_NONE;
- nTime = 100000000;
-}
-
std::string CInv::GetCommand() const {
std::string cmd;
switch (GetKind()) {
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -4,6 +4,7 @@
#include "rpc/server.h"
+#include "address.h"
#include "chainparams.h"
#include "clientversion.h"
#include "config.h"
diff --git a/src/seeder/bitcoin.h b/src/seeder/bitcoin.h
--- a/src/seeder/bitcoin.h
+++ b/src/seeder/bitcoin.h
@@ -6,6 +6,8 @@
#include <string>
#include <vector>
+class CAddress;
+
/**
* The seeder do not use the Params facility.
*
diff --git a/src/seeder/bitcoin.cpp b/src/seeder/bitcoin.cpp
--- a/src/seeder/bitcoin.cpp
+++ b/src/seeder/bitcoin.cpp
@@ -1,5 +1,6 @@
#include "bitcoin.h"
+#include "address.h"
#include "db.h"
#include "hash.h"
#include "netbase.h"
diff --git a/src/seeder/db.h b/src/seeder/db.h
--- a/src/seeder/db.h
+++ b/src/seeder/db.h
@@ -19,6 +19,8 @@
#define REQUIRE_VERSION 70001
+class CAddress;
+
static inline int GetRequireHeight(const bool testnet = fTestNet) {
return testnet ? 500000 : 350000;
}
diff --git a/src/seeder/db.cpp b/src/seeder/db.cpp
--- a/src/seeder/db.cpp
+++ b/src/seeder/db.cpp
@@ -1,4 +1,5 @@
#include "db.h"
+#include "address.h"
#include <cstdlib>
diff --git a/src/seeder/main.cpp b/src/seeder/main.cpp
--- a/src/seeder/main.cpp
+++ b/src/seeder/main.cpp
@@ -1,3 +1,4 @@
+#include "address.h"
#include "bitcoin.h"
#include "clientversion.h"
#include "db.h"
diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp
--- a/src/test/DoS_tests.cpp
+++ b/src/test/DoS_tests.cpp
@@ -4,6 +4,7 @@
// Unit tests for denial-of-service detection/prevention code
+#include "address.h"
#include "chainparams.h"
#include "config.h"
#include "keystore.h"
diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp
--- a/src/test/addrman_tests.cpp
+++ b/src/test/addrman_tests.cpp
@@ -6,6 +6,7 @@
#include <boost/test/unit_test.hpp>
#include <string>
+#include "address.h"
#include "hash.h"
#include "netbase.h"
#include "random.h"
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -2,6 +2,8 @@
// Copyright (c) 2017-2018 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include "address.h"
#include "addrman.h"
#include "chainparams.h"
#include "config.h"
diff --git a/src/test/test_bitcoin_fuzzy.cpp b/src/test/test_bitcoin_fuzzy.cpp
--- a/src/test/test_bitcoin_fuzzy.cpp
+++ b/src/test/test_bitcoin_fuzzy.cpp
@@ -6,6 +6,7 @@
#include "config/bitcoin-config.h"
#endif
+#include "address.h"
#include "addrman.h"
#include "chain.h"
#include "coins.h"

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 10:28 (11 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187350
Default Alt Text
D1795.diff (7 KB)

Event Timeline