Skip to content

Commit 1802dcc

Browse files
committed
Refactor softwareexpiry to use global variable
(Necessary to avoid indirect univalue inclusion via common/args, in clientversion)
1 parent 4fa0182 commit 1802dcc

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/bitcoind.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static bool ParseArgs(ArgsManager& args, int argc, char* argv[])
129129
}
130130
}
131131

132+
g_software_expiry = args.GetIntArg("-softwareexpiry", DEFAULT_SOFTWARE_EXPIRY);
132133
if (IsThisSoftwareExpired(GetTime())) {
133134
tfm::format(std::cerr, "This software is expired, and may be out of consensus. You must choose to upgrade or override this expiration.\n");
134135
exit(EXIT_FAILURE);

src/clientversion.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include <util/string.h>
99
#include <util/translation.h>
1010

11-
#include <common/args.h>
1211
#include <tinyformat.h>
13-
#include <util/time.h>
1412

1513
#include <string>
1614
#include <vector>
@@ -102,11 +100,12 @@ std::string LicenseInfo()
102100
"\n";
103101
}
104102

103+
int64_t g_software_expiry{DEFAULT_SOFTWARE_EXPIRY};
104+
105105
bool IsThisSoftwareExpired(int64_t nTime)
106106
{
107-
int64_t nSoftwareExpiry = gArgs.GetIntArg("-softwareexpiry", DEFAULT_SOFTWARE_EXPIRY);
108-
if (nSoftwareExpiry <= 0) {
109-
nSoftwareExpiry = std::numeric_limits<int64_t>::max();
107+
if (g_software_expiry <= 0) {
108+
return false;
110109
}
111-
return (nTime > nSoftwareExpiry);
110+
return (nTime > g_software_expiry);
112111
}

src/clientversion.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ std::string LicenseInfo();
4848
static const int64_t SECONDS_PER_YEAR = 31558060;
4949
static const int POSIX_EPOCH_YEAR = 1970;
5050
static const int64_t DEFAULT_SOFTWARE_EXPIRY = ((COPYRIGHT_YEAR - POSIX_EPOCH_YEAR) * SECONDS_PER_YEAR) + (SECONDS_PER_YEAR * 2);
51+
extern int64_t g_software_expiry;
5152

5253
bool IsThisSoftwareExpired(int64_t nTime);
5354

src/qt/bitcoin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ int GuiMain(int argc, char* argv[])
645645
// Re-initialize translations after changing application name (language in network-specific settings can be different)
646646
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
647647

648+
g_software_expiry = gArgs.GetIntArg("-softwareexpiry", DEFAULT_SOFTWARE_EXPIRY);
648649
if (IsThisSoftwareExpired(GetTime())) {
649650
QMessageBox::critical(nullptr, QObject::tr("Software expired"), QObject::tr("This software is expired, and may be out of consensus. You must choose to upgrade or override this expiration."));
650651
return EXIT_FAILURE;

0 commit comments

Comments
 (0)