diff --git a/src/clientversion.cpp b/src/clientversion.cpp index fb4f8d8811..9d2d539dc4 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -27,13 +27,9 @@ const std::string CLIENT_NAME("DeFiChain"); * * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is * generated by the build environment, possibly containing the output * of git-describe in a macro called BUILD_DESC - * * secondly, if this is an exported version of the code, GIT_ARCHIVE will - * be defined (automatically using the export-subst git attribute), and - * GIT_COMMIT will contain the commit id. - * * then, three options exist for determining CLIENT_BUILD: + * * then, two options exist for determining CLIENT_BUILD: * * if BUILD_DESC is defined, use that literally (output of git-describe) - * * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit] - * * otherwise, use v[maj].[min].[rev].[build]-unk + * * otherwise, use v[maj].[min].[rev].[build]-unknown * finally CLIENT_VERSION_SUFFIX is added */ @@ -46,32 +42,25 @@ const std::string CLIENT_NAME("DeFiChain"); #define BUILD_SUFFIX release #endif -//! git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$ -#ifdef GIT_ARCHIVE -#define GIT_COMMIT_ID "$Format:%H$" -#define GIT_COMMIT_DATE "$Format:%cD$" -#endif - #define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \ "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix) - -#define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \ - "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit - #define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \ - "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk" + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unknown" +#define BUILD_SUFFIX_TAIL(suffix) \ + DO_STRINGIZE(suffix) #ifndef BUILD_DESC #ifdef BUILD_SUFFIX #define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX) -#elif defined(GIT_COMMIT_ID) -#define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID) +#define BUILD_DESC_SUFFIX BUILD_SUFFIX_TAIL(BUILD_SUFFIX) #else #define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD) +#define BUILD_DESC_SUFFIX "unknown" #endif #endif const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); +const std::string CLIENT_BUILD_SUFFIX(BUILD_DESC_SUFFIX CLIENT_VERSION_SUFFIX); std::string FormatVersion(int nVersion) { @@ -86,6 +75,11 @@ std::string FormatVersionAndSuffix() return CLIENT_BUILD; } +std::string FormatVersionSuffixTail() +{ + return CLIENT_BUILD_SUFFIX; +} + /** * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */ diff --git a/src/clientversion.h b/src/clientversion.h index ebc296b911..504aeac4dd 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -46,6 +46,7 @@ extern const std::string CLIENT_BUILD; std::string FormatVersion(int nVersion); std::string FormatVersionAndSuffix(); +std::string FormatVersionSuffixTail(); std::string FormatUserAgentString(const std::string& name, int nClientVersion, const std::vector& comments); #endif // WINDRES_PREPROC diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index a2ff3f4072..73d6e365f1 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -518,15 +518,16 @@ static UniValue getversioninfo(const JSONRPCRequest& request){ {}, RPCResult{ "{\n" - " \"name\": DeFiChain (string) Node name\n" - " \"version\": \"xxxxx\", (string) Node version string\n" - " \"numericVersion\": xxxxx, (number) Node numeric version\n" - " \"fullVersion\": \"DefiChain:x.x.x\", (string) Full node version string including name and version\n" - " \"userAgent\": \"/DefiChain:x.x.x/\", (string) P2P user agent string (subversion string conforming to BIP-14)\n" - " \"protoVersion\": \"xxxxx\", (number) Operating protocol version\n" - " \"protoVersionMin\": \"xxxxx\", (number) Minimum protocol that's supported by the node\n" - " \"rpcVersion\": \"xxxxx\", (string) RPC version\n" - " \"rpcVersionMin\": \"xxxxx\", (string) Minimum RPC version supported\n" + " \"name\": DeFiChain (string) Node name\n" + " \"version\": \"xxxxx\", (string) Node version string\n" + " \"versionSuffix\": \"xxxxx\", (string) Version suffix\n" + " \"numericVersion\": xxxxx, (number) Node numeric version\n" + " \"fullVersion\": \"DefiChain:x.x.x-suffix\", (string) Full node version string including name and full version including suffix\n" + " \"userAgent\": \"/DefiChain:x.x.x/\", (string) P2P user agent string (subversion string conforming to BIP-14)\n" + " \"protoVersion\": \"xxxxx\", (number) Operating protocol version\n" + " \"protoVersionMin\": \"xxxxx\", (number) Minimum protocol that's supported by the node\n" + " \"rpcVersion\": \"xxxxx\", (string) RPC version\n" + " \"rpcVersionMin\": \"xxxxx\", (string) Minimum RPC version supported\n" " \"spv\":\n" " \"{\n" " \"btc\":\n" @@ -555,10 +556,11 @@ static UniValue getversioninfo(const JSONRPCRequest& request){ spvInfoObj.pushKV("btc", btcInfoObj); std::ostringstream strFullVersion; - strFullVersion << CLIENT_NAME << ":" << FormatVersion(CLIENT_VERSION); + strFullVersion << CLIENT_NAME << ":" << FormatVersionAndSuffix(); nodeInfoObj.pushKV("name", CLIENT_NAME); nodeInfoObj.pushKV("version", FormatVersion(CLIENT_VERSION)); + nodeInfoObj.pushKV("versionSuffix", FormatVersionSuffixTail()); nodeInfoObj.pushKV("numericVersion", CLIENT_VERSION); nodeInfoObj.pushKV("fullVersion",strFullVersion.str()); nodeInfoObj.pushKV("userAgent",strSubVersion);