From 6e5fd003e04b81115b6b164b21f048472d575535 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 21 Aug 2014 16:11:05 +0200 Subject: Move `*Version()` functions to version.h/cpp --- src/bitcoin-cli.cpp | 1 + src/qt/utilitydialog.cpp | 2 +- src/rpcprotocol.cpp | 1 + src/tinyformat.h | 1 + src/util.cpp | 25 ------------------------- src/util.h | 2 -- src/version.cpp | 28 ++++++++++++++++++++++++++++ src/version.h | 4 ++++ 8 files changed, 36 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 0609adcab3..10ca26ff2b 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -8,6 +8,7 @@ #include "rpcclient.h" #include "rpcprotocol.h" #include "chainparamsbase.h" +#include "version.h" #include diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 5fb0da145d..1a39894c9b 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -10,9 +10,9 @@ #include "clientmodel.h" #include "guiutil.h" -#include "clientversion.h" #include "init.h" #include "util.h" +#include "version.h" #include #include diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp index 643208b3b6..a4deddbed3 100644 --- a/src/rpcprotocol.cpp +++ b/src/rpcprotocol.cpp @@ -6,6 +6,7 @@ #include "rpcprotocol.h" #include "util.h" +#include "version.h" #include diff --git a/src/tinyformat.h b/src/tinyformat.h index 929cb66e4d..73d49a1fe4 100644 --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -121,6 +121,7 @@ namespace tfm = tinyformat; #include #include #include +#include #ifndef TINYFORMAT_ERROR # define TINYFORMAT_ERROR(reason) assert(0 && reason) diff --git a/src/util.cpp b/src/util.cpp index 606f5a60f9..80d27d5826 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -13,7 +13,6 @@ #include "random.h" #include "sync.h" #include "uint256.h" -#include "version.h" #include @@ -1116,30 +1115,6 @@ void SetMockTime(int64_t nMockTimeIn) nMockTime = nMockTimeIn; } -string FormatVersion(int nVersion) -{ - if (nVersion%100 == 0) - return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); - else - return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); -} - -string FormatFullVersion() -{ - return CLIENT_BUILD; -} - -// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014) -std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) -{ - std::ostringstream ss; - ss << "/"; - ss << name << ":" << FormatVersion(nClientVersion); - if (!comments.empty()) - ss << "(" << boost::algorithm::join(comments, "; ") << ")"; - ss << "/"; - return ss.str(); -} #ifdef WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) diff --git a/src/util.h b/src/util.h index e0feca07ca..cfbf30c6a4 100644 --- a/src/util.h +++ b/src/util.h @@ -156,8 +156,6 @@ boost::filesystem::path GetTempPath(); void ShrinkDebugFile(); int64_t GetTime(); void SetMockTime(int64_t nMockTimeIn); -std::string FormatFullVersion(); -std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments); void runCommand(std::string strCommand); inline std::string i64tostr(int64_t n) diff --git a/src/version.cpp b/src/version.cpp index d86caa3ac2..8311041ed2 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -4,7 +4,10 @@ #include "version.h" +#include "tinyformat.h" + #include +#include // Name of client reported in the 'version' message. Report the same name // for both bitcoind and bitcoin-qt, to make it harder for attackers to @@ -69,3 +72,28 @@ const std::string CLIENT_NAME("Satoshi"); const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); const std::string CLIENT_DATE(BUILD_DATE); + +static std::string FormatVersion(int nVersion) +{ + if (nVersion%100 == 0) + return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); + else + return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); +} + +std::string FormatFullVersion() +{ + return CLIENT_BUILD; +} + +// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014) +std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) +{ + std::ostringstream ss; + ss << "/"; + ss << name << ":" << FormatVersion(nClientVersion); + if (!comments.empty()) + ss << "(" << boost::algorithm::join(comments, "; ") << ")"; + ss << "/"; + return ss.str(); +} diff --git a/src/version.h b/src/version.h index fbb731c91d..3a6c0f3719 100644 --- a/src/version.h +++ b/src/version.h @@ -7,6 +7,7 @@ #include "clientversion.h" #include +#include // // client versioning @@ -48,4 +49,7 @@ 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 -- cgit v1.2.3