aboutsummaryrefslogtreecommitdiff
path: root/src/version.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-08-21 16:11:05 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-08-26 13:25:21 +0200
commit6e5fd003e04b81115b6b164b21f048472d575535 (patch)
tree7420ebadf22b1b10bebd08ad3294abc7e8a9b565 /src/version.cpp
parentb4aa769bcb82519024ee54fc84a37c34420d53b8 (diff)
Move `*Version()` functions to version.h/cpp
Diffstat (limited to 'src/version.cpp')
-rw-r--r--src/version.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/version.cpp b/src/version.cpp
index d86caa3ac2..8311041ed2 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -4,7 +4,10 @@
#include "version.h"
+#include "tinyformat.h"
+
#include <string>
+#include <boost/algorithm/string/join.hpp>
// Name of client reported in the 'version' message. Report the same name
// for both bitcoind and bitcoin-qt, to make it harder for attackers to
@@ -69,3 +72,28 @@ const std::string CLIENT_NAME("Satoshi");
const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE);
+
+static std::string FormatVersion(int nVersion)
+{
+ if (nVersion%100 == 0)
+ return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
+ else
+ return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
+}
+
+std::string FormatFullVersion()
+{
+ return CLIENT_BUILD;
+}
+
+// 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();
+}