trb

trb
Log | Files | Refs

commit 41aa0587f3ca62fa7ccf915adc0eaca697818e7d
parent 9e5001af551a55646652cf2af3ddb3a26d22b323
Author: Shinoa-Fores <btcinfo@sdf.org>
Date:   Wed, 13 Jan 2021 17:32:03 -0500

programmable-versionstring.vpatch

Diffstat:
Mbitcoin/src/init.cpp | 12++++++++++++
Abitcoin/src/knobs.h | 7+++++++
Mbitcoin/src/main.cpp | 2++
Mbitcoin/src/makefile.unix | 1+
Mbitcoin/src/net.h | 2+-
Mbitcoin/src/serialize.h | 7++++---
Mbitcoin/src/util.cpp | 17+++++++++++------
Mbitcoin/src/util.h | 2++
8 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/bitcoin/src/init.cpp b/bitcoin/src/init.cpp @@ -175,6 +175,8 @@ bool AppInit2(int argc, char* argv[]) " -debug \t\t " + _("Output extra debugging information\n") + " -caneat \t\t " + _("Permit the use of 'eatblock'\n") + " -verifyall \t\t " + _("Forbid the skipping of ECDSA signature verification between checkpoints.\n") + + " -setverstring \t\t " + _("Set a custom version string.\n") + + " -setvernum \t\t " + _("Set a custom version number.\n") + " -logtimestamps \t " + _("Prepend debug output with timestamp\n") + " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") + " -rpcuser=<user> \t " + _("Username for JSON-RPC connections\n") + @@ -199,6 +201,16 @@ bool AppInit2(int argc, char* argv[]) fCanEat = GetBoolArg("-caneat"); fVerifyAll = GetBoolArg("-verifyall"); + if (mapArgs.count("-setverstring")) + { + CLIENT_NAME = mapArgs["-setverstring"]; + } + + if (mapArgs.count("-setvernum")) + { + VERSION = atoi(mapArgs["-setvernum"]); + } + if (fDaemon) fServer = true; else diff --git a/bitcoin/src/knobs.h b/bitcoin/src/knobs.h @@ -0,0 +1,7 @@ +#ifndef KNOBS_H +#define KNOBS_H + +#define DEFAULT_CLIENT_NAME "therealbitcoin.org" +#define DEFAULT_CLIENT_VERSION 99999 /* 50400 */ + +#endif diff --git a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp @@ -17,6 +17,8 @@ using namespace boost; // Global state // +int VERSION = DEFAULT_CLIENT_VERSION; + CCriticalSection cs_setpwalletRegistered; set<CWallet*> setpwalletRegistered; diff --git a/bitcoin/src/makefile.unix b/bitcoin/src/makefile.unix @@ -81,6 +81,7 @@ HEADERS = \ init.h \ key.h \ keystore.h \ + knobs.h \ main.h \ net.h \ noui.h \ diff --git a/bitcoin/src/net.h b/bitcoin/src/net.h @@ -360,7 +360,7 @@ public: CAddress addrMe = (fUseProxy || !addrLocalHost.IsRoutable() ? CAddress("0.0.0.0") : addrLocalHost); RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, - nLocalHostNonce, std::string(pszSubVer), nBestHeight); + nLocalHostNonce, FormatSubVersion(CLIENT_NAME, VERSION), nBestHeight); } diff --git a/bitcoin/src/serialize.h b/bitcoin/src/serialize.h @@ -24,6 +24,9 @@ typedef unsigned long long uint64; #include <sys/mman.h> #include <limits.h> + +#include "knobs.h" + /* This comes from limits.h if it's not defined there set a sane default */ #ifndef PAGESIZE #include <unistd.h> @@ -41,9 +44,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 50400; -static const char* pszSubVer = ""; -static const bool VERSION_IS_BETA = true; +extern int VERSION; // Used to bypass the rule against non-const reference to temporary // where it makes sense with wrappers such as CFlatData or CTxDB diff --git a/bitcoin/src/util.cpp b/bitcoin/src/util.cpp @@ -2,6 +2,7 @@ // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. +#include "knobs.h" #include "headers.h" #include "strlcpy.h" #include <boost/program_options/detail/config_file.hpp> @@ -32,7 +33,7 @@ string strMiscWarning; bool fNoListen = false; bool fLogTimestamps = false; - +std::string CLIENT_NAME(DEFAULT_CLIENT_NAME); // Workaround for "multiple definition of `_tls_used'" @@ -889,14 +890,18 @@ string FormatVersion(int nVersion) string FormatFullVersion() { - string s = FormatVersion(VERSION) + pszSubVer; - if (VERSION_IS_BETA) { - s += "-"; - s += _("beta"); - } + string s = FormatVersion(VERSION); return s; } +std::string FormatSubVersion(const std::string& name, int nClientVersion) +{ + std::ostringstream ss; + ss << "/"; + ss << name << ":" << FormatVersion(nClientVersion); + ss << "/"; + return ss.str(); +} diff --git a/bitcoin/src/util.h b/bitcoin/src/util.h @@ -121,6 +121,7 @@ extern bool fCommandLine; extern std::string strMiscWarning; extern bool fNoListen; extern bool fLogTimestamps; +extern std::string CLIENT_NAME; void RandAddSeed(); void RandAddSeedPerfmon(); @@ -161,6 +162,7 @@ void SetMockTime(int64 nMockTimeIn); int64 GetAdjustedTime(); void AddTimeData(unsigned int ip, int64 nTime); std::string FormatFullVersion(); +std::string FormatSubVersion(const std::string& name, int nClientVersion);