Raven Core  3.0.0
P2P Digital Currency
clientversion.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "clientversion.h"
7 
8 #include "tinyformat.h"
9 
10 #include <string>
11 
17 const std::string CLIENT_NAME("Ravencoin");
18 
22 #define CLIENT_VERSION_SUFFIX ""
23 
24 
41 #ifdef HAVE_BUILD_INFO
43 #include "build.h"
44 #endif
45 
47 #ifdef GIT_ARCHIVE
48 #define GIT_COMMIT_ID "$Format:%h$"
49 #define GIT_COMMIT_DATE "$Format:%cD$"
50 #endif
51 
52 #define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \
53  "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix)
54 
55 #define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \
56  "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit
57 
58 #define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \
59  "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk"
60 
61 #ifndef BUILD_DESC
62 #ifdef BUILD_SUFFIX
63 #define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX)
64 #elif defined(GIT_COMMIT_ID)
65 #define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID)
66 #else
67 #define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD)
68 #endif
69 #endif
70 
72 
73 static std::string FormatVersion(int nVersion)
74 {
75  if (nVersion % 100 == 0)
76  return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100);
77  else
78  return strprintf("%d.%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, nVersion % 100);
79 }
80 
81 std::string FormatFullVersion()
82 {
83  return CLIENT_BUILD;
84 }
85 
89 std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments)
90 {
91  std::ostringstream ss;
92  ss << "/";
93  ss << name << ":" << FormatVersion(nClientVersion);
94  if (!comments.empty())
95  {
96  std::vector<std::string>::const_iterator it(comments.begin());
97  ss << "(" << *it;
98  for(++it; it != comments.end(); ++it)
99  ss << "; " << *it;
100  ss << ")";
101  }
102  ss << "/";
103  return ss.str();
104 }
const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX)
const std::string CLIENT_NAME("Ravencoin")
Name of client reported in the &#39;version&#39; message.
#define strprintf
Definition: tinyformat.h:1054
#define CLIENT_VERSION_SUFFIX
Client version number.
std::string FormatFullVersion()
#define BUILD_DESC
std::string FormatSubVersion(const std::string &name, int nClientVersion, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec (https://github.com/raven/bips/blob/master/bip-0...