Browse Source

Move `*Version()` functions to version.h/cpp

0.10
Wladimir J. van der Laan 10 years ago
parent
commit
6e5fd003e0
  1. 1
      src/bitcoin-cli.cpp
  2. 2
      src/qt/utilitydialog.cpp
  3. 1
      src/rpcprotocol.cpp
  4. 1
      src/tinyformat.h
  5. 25
      src/util.cpp
  6. 2
      src/util.h
  7. 28
      src/version.cpp
  8. 4
      src/version.h

1
src/bitcoin-cli.cpp

@ -8,6 +8,7 @@
#include "rpcclient.h" #include "rpcclient.h"
#include "rpcprotocol.h" #include "rpcprotocol.h"
#include "chainparamsbase.h" #include "chainparamsbase.h"
#include "version.h"
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>

2
src/qt/utilitydialog.cpp

@ -10,9 +10,9 @@
#include "clientmodel.h" #include "clientmodel.h"
#include "guiutil.h" #include "guiutil.h"
#include "clientversion.h"
#include "init.h" #include "init.h"
#include "util.h" #include "util.h"
#include "version.h"
#include <QLabel> #include <QLabel>
#include <QRegExp> #include <QRegExp>

1
src/rpcprotocol.cpp

@ -6,6 +6,7 @@
#include "rpcprotocol.h" #include "rpcprotocol.h"
#include "util.h" #include "util.h"
#include "version.h"
#include <stdint.h> #include <stdint.h>

1
src/tinyformat.h

@ -121,6 +121,7 @@ namespace tfm = tinyformat;
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <stdexcept>
#ifndef TINYFORMAT_ERROR #ifndef TINYFORMAT_ERROR
# define TINYFORMAT_ERROR(reason) assert(0 && reason) # define TINYFORMAT_ERROR(reason) assert(0 && reason)

25
src/util.cpp

@ -13,7 +13,6 @@
#include "random.h" #include "random.h"
#include "sync.h" #include "sync.h"
#include "uint256.h" #include "uint256.h"
#include "version.h"
#include <stdarg.h> #include <stdarg.h>
@ -1116,30 +1115,6 @@ void SetMockTime(int64_t nMockTimeIn)
nMockTime = nMockTimeIn; nMockTime = nMockTimeIn;
} }
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);
}
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();
}
#ifdef WIN32 #ifdef WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)

2
src/util.h

@ -156,8 +156,6 @@ boost::filesystem::path GetTempPath();
void ShrinkDebugFile(); void ShrinkDebugFile();
int64_t GetTime(); int64_t GetTime();
void SetMockTime(int64_t nMockTimeIn); void SetMockTime(int64_t nMockTimeIn);
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
void runCommand(std::string strCommand); void runCommand(std::string strCommand);
inline std::string i64tostr(int64_t n) inline std::string i64tostr(int64_t n)

28
src/version.cpp

@ -4,7 +4,10 @@
#include "version.h" #include "version.h"
#include "tinyformat.h"
#include <string> #include <string>
#include <boost/algorithm/string/join.hpp>
// Name of client reported in the 'version' message. Report the same name // 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 // 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_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE); 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();
}

4
src/version.h

@ -7,6 +7,7 @@
#include "clientversion.h" #include "clientversion.h"
#include <string> #include <string>
#include <vector>
// //
// client versioning // client versioning
@ -48,4 +49,7 @@ static const int BIP0031_VERSION = 60000;
// "mempool" command, enhanced "getdata" behavior starts with this version // "mempool" command, enhanced "getdata" behavior starts with this version
static const int MEMPOOL_GD_VERSION = 60002; static const int MEMPOOL_GD_VERSION = 60002;
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
#endif #endif

Loading…
Cancel
Save