forked from gridcoin-community/Gridcoin-Research
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: separate clientversion from version
- Loading branch information
Showing
22 changed files
with
140 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) 2012-2020 The Bitcoin Core developers | ||
// Copyright (c) 2021 The Gridcoin developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <clientversion.h> | ||
|
||
#include <tinyformat.h> | ||
|
||
|
||
/** | ||
* Name of client reported in the 'version' message. Report the same name | ||
* for both gridcoinresearchd and gridcoinresearch-qt, to make it harder for attackers to | ||
* target servers or GUI users specifically. | ||
*/ | ||
const std::string CLIENT_NAME("Halford"); | ||
|
||
|
||
#ifdef HAVE_BUILD_INFO | ||
#include "build.h" | ||
// The <obj/build.h>, 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" PACKAGE_VERSION | ||
#if CLIENT_VERSION_IS_RELEASE | ||
#define BUILD_SUFFIX "" | ||
#elif defined(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 | ||
|
||
static std::string FormatVersion(int nVersion) | ||
{ | ||
return strprintf("%d.%d.%d", nVersion / 10000, (nVersion / 100) % 100, nVersion % 100); | ||
} | ||
|
||
std::string FormatFullVersion() | ||
{ | ||
static const std::string CLIENT_BUILD(BUILD_DESC BUILD_SUFFIX); | ||
return CLIENT_BUILD; | ||
} | ||
|
||
/** | ||
* 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<std::string>& comments) | ||
{ | ||
std::ostringstream ss; | ||
ss << "/"; | ||
ss << name << ":" << FormatVersion(nClientVersion); | ||
if (!comments.empty()) | ||
{ | ||
std::vector<std::string>::const_iterator it(comments.begin()); | ||
ss << "(" << *it; | ||
for(++it; it != comments.end(); ++it) | ||
ss << "; " << *it; | ||
ss << ")"; | ||
} | ||
ss << "/"; | ||
return ss.str(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2009-2020 The Bitcoin Core developers | ||
// Copyright (c) 2021 The Gridcoin developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or https://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_CLIENTVERSION_H | ||
#define BITCOIN_CLIENTVERSION_H | ||
|
||
#include <util/macros.h> | ||
|
||
#if defined(HAVE_CONFIG_H) | ||
#include <config/gridcoin-config.h> | ||
#endif //HAVE_CONFIG_H | ||
|
||
// Check that required client information is defined | ||
#if !defined(CLIENT_VERSION_MAJOR) || !defined(CLIENT_VERSION_MINOR) || !defined(CLIENT_VERSION_BUILD) || !defined(CLIENT_VERSION_IS_RELEASE) || !defined(COPYRIGHT_YEAR) | ||
#error Client version information missing: version is not defined by gridcoin-config.h or in any other way | ||
#endif | ||
|
||
//! 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 <string> | ||
#include <vector> | ||
|
||
static const int CLIENT_VERSION = | ||
10000 * CLIENT_VERSION_MAJOR | ||
+ 100 * CLIENT_VERSION_MINOR | ||
+ 1 * CLIENT_VERSION_BUILD; | ||
|
||
extern const std::string CLIENT_NAME; | ||
|
||
|
||
std::string FormatFullVersion(); | ||
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments); | ||
|
||
#endif // WINDRES_PREPROC | ||
|
||
#endif // BITCOIN_CLIENTVERSION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.