diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 7fca87807..52a5d98b7 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -1,93 +1,81 @@ // Copyright (c) 2012-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #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 * target servers or GUI users specifically. */ const std::string CLIENT_NAME("Bitcoin ABC"); #ifdef HAVE_BUILD_INFO #include // The , which is generated by the build environment // (share/genbuild.sh), could contain only one line of the following: // - "#define BUILD_GIT_TAG ...", if the top commit is tagged // - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged // - "// No build information available", if proper git information is not // available #endif //! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives. //! $Format:%n#define GIT_COMMIT_ID "%H"$ #ifdef BUILD_GIT_TAG #define BUILD_DESC BUILD_GIT_TAG #define BUILD_SUFFIX "" #else #define BUILD_DESC \ "v" STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE( \ CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) #ifdef BUILD_GIT_COMMIT #define BUILD_SUFFIX "-" BUILD_GIT_COMMIT #elif defined(GIT_COMMIT_ID) #define BUILD_SUFFIX "-g" GIT_COMMIT_ID #else #define BUILD_SUFFIX "-unk" #endif #endif const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX); -static std::string FormatVersion(int nVersion) { +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 using given userAgent. + * Format the subversion field according to BIP 14 spec. * (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */ -std::string -FormatSubVersionUserAgent(const std::string &userAgent, - const std::vector &comments) { +std::string FormatUserAgent(const std::string &name, const std::string &version, + const std::vector &comments) { std::ostringstream ss; ss << "/"; - ss << userAgent; + ss << name << ":" << version; if (!comments.empty()) { std::vector::const_iterator it(comments.begin()); ss << "(" << *it; for (++it; it != comments.end(); ++it) { ss << "; " << *it; } ss << ")"; } ss << "/"; return ss.str(); } - -/** - * Format the subversion field according to BIP 14 spec - * (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) - */ -std::string FormatSubVersion(const std::string &name, int nClientVersion, - const std::vector &comments) { - std::ostringstream ss; - ss << name << ":" << FormatVersion(nClientVersion); - return FormatSubVersionUserAgent(ss.str(), comments); -} diff --git a/src/clientversion.h b/src/clientversion.h index 54d31642c..956b14eef 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -1,59 +1,58 @@ // Copyright (c) 2009-2016 The Bitcoin Core developers // Copyright (c) 2017-2019 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_CLIENTVERSION_H #define BITCOIN_CLIENTVERSION_H #if defined(HAVE_CONFIG_H) #include #endif // HAVE_CONFIG_H #include // Check that required client information is defined #if !defined(CLIENT_VERSION_MAJOR) || !defined(CLIENT_VERSION_MINOR) || \ !defined(CLIENT_VERSION_REVISION) || !defined(COPYRIGHT_YEAR) || \ !defined(CLIENT_VERSION_IS_RELEASE) #error Client version information missing: version is not defined by bitcoin-config.h nor defined any other way #endif /** * Converts the parameter X to a string after macro replacement on X has been * performed. * Don't merge these into one macro! */ #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X //! Copyright string used in Windows .rc files #define COPYRIGHT_STR \ "2009-" STRINGIZE(COPYRIGHT_YEAR) " " COPYRIGHT_HOLDERS_FINAL /** * 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 constexpr int CLIENT_VERSION = 1000000 * CLIENT_VERSION_MAJOR + 10000 * CLIENT_VERSION_MINOR + 100 * CLIENT_VERSION_REVISION; extern const std::string CLIENT_NAME; extern const std::string CLIENT_BUILD; +std::string FormatVersion(int nVersion); std::string FormatFullVersion(); -std::string FormatSubVersionUserAgent(const std::string &userAgent, - const std::vector &comments); -std::string FormatSubVersion(const std::string &name, int nClientVersion, - const std::vector &comments); +std::string FormatUserAgent(const std::string &name, const std::string &version, + const std::vector &comments); #endif // WINDRES_PREPROC #endif // BITCOIN_CLIENTVERSION_H diff --git a/src/init.cpp b/src/init.cpp index b561871ba..70158a3c7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,2986 +1,3004 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include