Skip to content

Commit 4c3e3c5

Browse files
committed
refactor: shift CopyrightHolders() and LicenseInfo() to clientversion.cpp
1 parent c44e734 commit 4c3e3c5

File tree

7 files changed

+39
-37
lines changed

7 files changed

+39
-37
lines changed

src/clientversion.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <clientversion.h>
6+
#include <util/translation.h>
67

78
#include <tinyformat.h>
89

10+
#include <sstream>
11+
#include <string>
12+
#include <vector>
913

1014
/**
1115
* Name of client reported in the 'version' message. Report the same name
@@ -72,3 +76,32 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const
7276
ss << "/";
7377
return ss.str();
7478
}
79+
80+
std::string CopyrightHolders(const std::string& strPrefix)
81+
{
82+
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
83+
std::string strCopyrightHolders = strPrefix + copyright_devs;
84+
85+
// Make sure Bitcoin Core copyright is not removed by accident
86+
if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
87+
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
88+
}
89+
return strCopyrightHolders;
90+
}
91+
92+
std::string LicenseInfo()
93+
{
94+
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
95+
96+
return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
97+
"\n" +
98+
strprintf(_("Please contribute if you find %s useful. "
99+
"Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
100+
"\n" +
101+
strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
102+
"\n" +
103+
"\n" +
104+
_("This is experimental software.").translated + "\n" +
105+
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
106+
"\n";
107+
}

src/clientversion.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ extern const std::string CLIENT_NAME;
4141
std::string FormatFullVersion();
4242
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
4343

44+
std::string CopyrightHolders(const std::string& strPrefix);
45+
46+
/** Returns licensing information (for -version) */
47+
std::string LicenseInfo();
48+
4449
#endif // WINDRES_PREPROC
4550

4651
#endif // BITCOIN_CLIENTVERSION_H

src/init.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -594,25 +594,6 @@ void SetupServerArgs(ArgsManager& argsman)
594594
argsman.AddHiddenArgs(hidden_args);
595595
}
596596

597-
std::string LicenseInfo()
598-
{
599-
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
600-
601-
return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
602-
"\n" +
603-
strprintf(_("Please contribute if you find %s useful. "
604-
"Visit %s for further information about the software.").translated,
605-
PACKAGE_NAME, "<" PACKAGE_URL ">") +
606-
"\n" +
607-
strprintf(_("The source code is available from %s.").translated,
608-
URL_SOURCE_CODE) +
609-
"\n" +
610-
"\n" +
611-
_("This is experimental software.").translated + "\n" +
612-
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
613-
"\n";
614-
}
615-
616597
static bool fHaveGenesis = false;
617598
static Mutex g_genesis_wait_mutex;
618599
static std::condition_variable g_genesis_wait_cv;

src/init.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,4 @@ bool AppInitMain(node::NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip
7070
*/
7171
void SetupServerArgs(ArgsManager& argsman);
7272

73-
/** Returns licensing information (for -version) */
74-
std::string LicenseInfo();
75-
7673
#endif // BITCOIN_INIT_H

src/util/system.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,18 +1342,6 @@ int GetNumCores()
13421342
return std::thread::hardware_concurrency();
13431343
}
13441344

1345-
std::string CopyrightHolders(const std::string& strPrefix)
1346-
{
1347-
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
1348-
std::string strCopyrightHolders = strPrefix + copyright_devs;
1349-
1350-
// Make sure Bitcoin Core copyright is not removed by accident
1351-
if (copyright_devs.find("Bitcoin Core") == std::string::npos) {
1352-
strCopyrightHolders += "\n" + strPrefix + "The Bitcoin Core developers";
1353-
}
1354-
return strCopyrightHolders;
1355-
}
1356-
13571345
// Obtain the application startup time (used for uptime calculation)
13581346
int64_t GetStartupTime()
13591347
{

src/util/system.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,6 @@ std::string HelpMessageOpt(const std::string& option, const std::string& message
512512
*/
513513
int GetNumCores();
514514

515-
std::string CopyrightHolders(const std::string& strPrefix);
516-
517515
/**
518516
* On platforms that support it, tell the kernel the calling thread is
519517
* CPU-intensive and non-interactive. See SCHED_BATCH in sched(7) for details.

test/lint/lint-format-strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
("src/dbwrapper.cpp", "vsnprintf(p, limit - p, format, backup_ap)"),
1717
("src/index/base.cpp", "FatalError(const char* fmt, const Args&... args)"),
1818
("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char* fmt, const Args&... args)"),
19-
("src/util/system.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"),
19+
("src/clientversion.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"),
2020
("src/validationinterface.cpp", "LogPrint(BCLog::VALIDATION, fmt \"\\n\", __VA_ARGS__)"),
2121
("src/wallet/wallet.h", "WalletLogPrintf(std::string fmt, Params... parameters)"),
2222
("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"),

0 commit comments

Comments
 (0)