aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 2b4169ad41..a45ce33a1c 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -4,6 +4,7 @@
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h"
#include "strlcpy.h"
+#include <boost/algorithm/string/join.hpp>
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/filesystem.hpp>
@@ -132,7 +133,7 @@ uint64 GetRand(uint64 nMax)
// The range of the random source must be a multiple of the modulus
// to give every possible output value an equal possibility
- uint64 nRange = (UINT64_MAX / nMax) * nMax;
+ uint64 nRange = (std::numeric_limits<uint64>::max() / nMax) * nMax;
uint64 nRand = 0;
do
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
@@ -1001,7 +1002,7 @@ string FormatVersion(int nVersion)
string FormatFullVersion()
{
- string s = FormatVersion(VERSION) + pszSubVer;
+ string s = FormatVersion(CLIENT_VERSION);
if (VERSION_IS_BETA) {
s += "-";
s += _("beta");
@@ -1009,6 +1010,17 @@ string FormatFullVersion()
return s;
}
+// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014)
+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())
+ ss << "(" << boost::algorithm::join(comments, "; ") << ")";
+ ss << "/";
+ return ss.str();
+}