Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
clientversion.cpp
Go to the documentation of this file.
1
// Copyright (c) 2012-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <bitcoin-build-config.h>
// IWYU pragma: keep
6
7
#include <
clientversion.h
>
8
9
#include <
tinyformat.h
>
10
#include <
util/string.h
>
11
12
#include <string>
13
#include <vector>
14
15
using
util::Join
;
16
22
const
std::string
UA_NAME
(
"Satoshi"
);
23
24
25
#include <bitcoin-build-info.h>
// IWYU pragma: keep
26
// The <bitcoin-build-info.h>, which is generated by the build environment (cmake/script/GenerateBuildInfo.cmake),
27
// could contain only one line of the following:
28
// - "#define BUILD_GIT_TAG ...", if the top commit is tagged
29
// - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
30
// - "// No build information available", if proper git information is not available
31
32
// git will expand the next line to "#define GIT_COMMIT_ID ..." inside archives:
33
//$Format:%n#define GIT_COMMIT_ID "%H"$
34
35
#ifdef BUILD_GIT_TAG
36
#define BUILD_DESC BUILD_GIT_TAG
37
#define BUILD_SUFFIX ""
38
#else
39
#define BUILD_DESC "v" CLIENT_VERSION_STRING
40
#if CLIENT_VERSION_IS_RELEASE
41
#define BUILD_SUFFIX ""
42
#elif defined(BUILD_GIT_COMMIT)
43
#define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
44
#elif defined(GIT_COMMIT_ID)
45
#define BUILD_SUFFIX "-g" GIT_COMMIT_ID
46
#else
47
#define BUILD_SUFFIX "-suse"
48
#endif
49
#endif
50
51
static
std::string
FormatVersion
(
int
nVersion)
52
{
53
return
strprintf
(
"%d.%d.%d"
, nVersion / 10000, (nVersion / 100) % 100, nVersion % 100);
54
}
55
56
std::string
FormatFullVersion
()
57
{
58
static
const
std::string CLIENT_BUILD(
BUILD_DESC
BUILD_SUFFIX
);
59
return
CLIENT_BUILD;
60
}
61
65
std::string
FormatSubVersion
(
const
std::string& name,
int
nClientVersion,
const
std::vector<std::string>& comments)
66
{
67
std::string comments_str;
68
if
(!comments.empty()) comments_str =
strprintf
(
"(%s)"
,
Join
(comments,
"; "
));
69
return
strprintf
(
"/%s:%s%s/"
, name,
FormatVersion
(nClientVersion), comments_str);
70
}
Join
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
Definition
string.h:209
FormatSubVersion
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/bitcoin/bips/blob/master/bip...
Definition
clientversion.cpp:65
BUILD_SUFFIX
#define BUILD_SUFFIX
Definition
clientversion.cpp:47
BUILD_DESC
#define BUILD_DESC
Definition
clientversion.cpp:39
FormatVersion
static std::string FormatVersion(int nVersion)
Definition
clientversion.cpp:51
FormatFullVersion
std::string FormatFullVersion()
Definition
clientversion.cpp:56
clientversion.h
UA_NAME
const std::string UA_NAME
util::Join
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
Definition
string.h:209
string.h
tinyformat.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition
tinyformat.h:1172
Generated on
for Bitcoin Core by
1.18.0