From 71697f97d3f9512f0af934070690c14f1c0d95ea Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 28 Oct 2014 21:33:23 -0400 Subject: [PATCH] Separate protocol versioning from clientversion --- .gitattributes | 2 +- Makefile.am | 2 +- src/Makefile.am | 6 +++--- src/alert.cpp | 1 + src/bitcoin-cli.cpp | 2 +- src/bitcoin-tx.cpp | 1 + src/bitcoind.cpp | 1 + src/{version.cpp => clientversion.cpp} | 2 +- src/clientversion.h | 27 ++++++++++++++++++++++++++ src/db.h | 1 + src/leveldbwrapper.h | 1 + src/net.cpp | 1 + src/qt/clientmodel.cpp | 1 + src/qt/recentrequeststablemodel.cpp | 1 + src/qt/utilitydialog.cpp | 2 +- src/rpcmisc.cpp | 1 + src/rpcnet.cpp | 1 + src/rpcprotocol.cpp | 1 + src/test/alert_tests.cpp | 2 +- src/test/bloom_tests.cpp | 1 + src/test/checkblock_tests.cpp | 1 + src/test/transaction_tests.cpp | 1 + src/test/util_tests.cpp | 2 +- src/txmempool.cpp | 1 + src/version.h | 22 --------------------- 25 files changed, 52 insertions(+), 32 deletions(-) rename src/{version.cpp => clientversion.cpp} (99%) diff --git a/.gitattributes b/.gitattributes index 26d754935..c9cf4a7d9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -src/version.cpp export-subst +src/clientversion.cpp export-subst diff --git a/Makefile.am b/Makefile.am index fe7244edf..7fe381147 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,7 +36,7 @@ COVERAGE_INFO = baseline_filtered_combined.info baseline.info block_test.info \ dist-hook: -$(MAKE) -C $(top_distdir)/src/leveldb clean -$(MAKE) -C $(top_distdir)/src/secp256k1 distclean - -$(GIT) archive --format=tar HEAD -- src/version.cpp | $(AMTAR) -C $(top_distdir) -xf - + -$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf - distcheck-hook: $(MKDIR_P) $(top_distdir)/_build/src/leveldb diff --git a/src/Makefile.am b/src/Makefile.am index 91cc1b96e..8253c4ab1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -146,7 +146,7 @@ obj/build.h: FORCE @$(MKDIR_P) $(builddir)/obj @$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \ $(abs_top_srcdir) -libbitcoin_util_a-version.$(OBJEXT): obj/build.h +libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: shared between bitcoind and bitcoin-qt libbitcoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) @@ -241,6 +241,7 @@ libbitcoin_util_a_SOURCES = \ compat/glibc_sanity.cpp \ compat/glibcxx_sanity.cpp \ chainparamsbase.cpp \ + clientversion.cpp \ random.cpp \ rpcprotocol.cpp \ sync.cpp \ @@ -249,7 +250,6 @@ libbitcoin_util_a_SOURCES = \ utilstrencodings.cpp \ utilmoneystr.cpp \ utiltime.cpp \ - version.cpp \ $(BITCOIN_CORE_H) if GLIBC_BACK_COMPAT @@ -354,7 +354,7 @@ clean-local: .rc.o: @test -f $(WINDRES) - $(AM_V_GEN) $(WINDRES) -i $< -o $@ + $(AM_V_GEN) $(WINDRES) -DWINDRES_PREPROC -i $< -o $@ .mm.o: $(AM_V_CXX) $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ diff --git a/src/alert.cpp b/src/alert.cpp index d49584920..f16898dc3 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -6,6 +6,7 @@ #include "alert.h" #include "chainparams.h" +#include "clientversion.h" #include "key.h" #include "net.h" #include "timedata.h" diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index aa5e285b1..38fbc29fa 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -4,12 +4,12 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "chainparamsbase.h" +#include "clientversion.h" #include "init.h" #include "rpcclient.h" #include "rpcprotocol.h" #include "util.h" #include "utilstrencodings.h" -#include "version.h" #include diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 6f3409edf..c0d21ed36 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "base58.h" +#include "clientversion.h" #include "core/transaction.h" #include "core_io.h" #include "keystore.h" diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 0737b5a83..a79e581a8 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "clientversion.h" #include "rpcserver.h" #include "init.h" #include "main.h" diff --git a/src/version.cpp b/src/clientversion.cpp similarity index 99% rename from src/version.cpp rename to src/clientversion.cpp index d12b681e5..4987c3ed3 100644 --- a/src/version.cpp +++ b/src/clientversion.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "version.h" +#include "clientversion.h" #include "tinyformat.h" diff --git a/src/clientversion.h b/src/clientversion.h index cd7ceb78f..acaf54c6a 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -35,4 +35,31 @@ // Copyright string used in Windows .rc files #define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers" +/* + bitcoind-res.rc includes this file, but it cannot cope with real c++ code. + WINDRES_PREPROC is defined to indicate that its pre-processor is running. + Anything other than a define should be guarded below. +*/ + +#if !defined(WINDRES_PREPROC) + +#include +#include + +static const int CLIENT_VERSION = + 1000000 * CLIENT_VERSION_MAJOR + + 10000 * CLIENT_VERSION_MINOR + + 100 * CLIENT_VERSION_REVISION + + 1 * CLIENT_VERSION_BUILD; + +extern const std::string CLIENT_NAME; +extern const std::string CLIENT_BUILD; +extern const std::string CLIENT_DATE; + + +std::string FormatFullVersion(); +std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments); + +#endif // WINDRES_PREPROC + #endif // CLIENTVERSION_H diff --git a/src/db.h b/src/db.h index 0cbdd8b91..85ffbae1c 100644 --- a/src/db.h +++ b/src/db.h @@ -6,6 +6,7 @@ #ifndef BITCOIN_DB_H #define BITCOIN_DB_H +#include "clientversion.h" #include "serialize.h" #include "streams.h" #include "sync.h" diff --git a/src/leveldbwrapper.h b/src/leveldbwrapper.h index d997d56e0..10b7a2427 100644 --- a/src/leveldbwrapper.h +++ b/src/leveldbwrapper.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_LEVELDBWRAPPER_H #define BITCOIN_LEVELDBWRAPPER_H +#include "clientversion.h" #include "serialize.h" #include "streams.h" #include "util.h" diff --git a/src/net.cpp b/src/net.cpp index 6cccdca95..5ceb82cf8 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -11,6 +11,7 @@ #include "addrman.h" #include "chainparams.h" +#include "clientversion.h" #include "core/transaction.h" #include "ui_interface.h" diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 738fb48ef..aedda4907 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -10,6 +10,7 @@ #include "alert.h" #include "chainparams.h" #include "checkpoints.h" +#include "clientversion.h" #include "main.h" #include "net.h" #include "ui_interface.h" diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp index 5deac8007..5533adab8 100644 --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -5,6 +5,7 @@ #include "recentrequeststablemodel.h" #include "bitcoinunits.h" +#include "clientversion.h" #include "guiutil.h" #include "optionsmodel.h" #include "streams.h" diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 84f88dff5..58bf04062 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -10,8 +10,8 @@ #include "clientmodel.h" #include "guiutil.h" +#include "clientversion.h" #include "init.h" -#include "version.h" #include diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 92ed1c3e2..08e956c96 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -4,6 +4,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "base58.h" +#include "clientversion.h" #include "init.h" #include "main.h" #include "net.h" diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 12dcd5b54..46b5f3d7a 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -4,6 +4,7 @@ #include "rpcserver.h" +#include "clientversion.h" #include "main.h" #include "net.h" #include "netbase.h" diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp index c99d113bc..c2ce73106 100644 --- a/src/rpcprotocol.cpp +++ b/src/rpcprotocol.cpp @@ -5,6 +5,7 @@ #include "rpcprotocol.h" +#include "clientversion.h" #include "tinyformat.h" #include "util.h" #include "utilstrencodings.h" diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 28610f0d2..9cf7a98f4 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -7,13 +7,13 @@ // #include "alert.h" +#include "clientversion.h" #include "data/alertTests.raw.h" #include "serialize.h" #include "streams.h" #include "util.h" #include "utilstrencodings.h" -#include "version.h" #include diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 99b21a23a..783e284af 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -5,6 +5,7 @@ #include "bloom.h" #include "base58.h" +#include "clientversion.h" #include "key.h" #include "main.h" #include "serialize.h" diff --git a/src/test/checkblock_tests.cpp b/src/test/checkblock_tests.cpp index 9151fdc0c..fc36b43e1 100644 --- a/src/test/checkblock_tests.cpp +++ b/src/test/checkblock_tests.cpp @@ -8,6 +8,7 @@ +#include "clientversion.h" #include "main.h" #include "utiltime.h" diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index c46c31e99..d4c9b1a0e 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -5,6 +5,7 @@ #include "data/tx_invalid.json.h" #include "data/tx_valid.json.h" +#include "clientversion.h" #include "key.h" #include "keystore.h" #include "main.h" diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 761210fea..67d50fccf 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -4,12 +4,12 @@ #include "util.h" +#include "clientversion.h" #include "core/transaction.h" #include "random.h" #include "sync.h" #include "utilstrencodings.h" #include "utilmoneystr.h" -#include "version.h" #include #include diff --git a/src/txmempool.cpp b/src/txmempool.cpp index c042dd846..d3d9cb8a0 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -5,6 +5,7 @@ #include "txmempool.h" +#include "clientversion.h" #include "streams.h" #include "util.h" #include "utilmoneystr.h" diff --git a/src/version.h b/src/version.h index a1e440de2..6ee08c205 100644 --- a/src/version.h +++ b/src/version.h @@ -5,25 +5,6 @@ #ifndef BITCOIN_VERSION_H #define BITCOIN_VERSION_H -#include "clientversion.h" - -#include -#include - -// -// client versioning -// - -static const int CLIENT_VERSION = - 1000000 * CLIENT_VERSION_MAJOR - + 10000 * CLIENT_VERSION_MINOR - + 100 * CLIENT_VERSION_REVISION - + 1 * CLIENT_VERSION_BUILD; - -extern const std::string CLIENT_NAME; -extern const std::string CLIENT_BUILD; -extern const std::string CLIENT_DATE; - // // network protocol versioning // @@ -53,7 +34,4 @@ static const int BIP0031_VERSION = 60000; // "mempool" command, enhanced "getdata" behavior starts with this version static const int MEMPOOL_GD_VERSION = 60002; -std::string FormatFullVersion(); -std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments); - #endif // BITCOIN_VERSION_H