]> Git Repo - VerusCoin.git/blame - src/deprecation.cpp
Implement automatic shutdown of deprecated Zcash versions
[VerusCoin.git] / src / deprecation.cpp
CommitLineData
5b3bc971
JG
1// Copyright (c) 2017 The Zcash developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include "deprecation.h"
6
7#include "clientversion.h"
8#include "init.h"
9#include "ui_interface.h"
10#include "util.h"
11
12static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
13
14void EnforceNodeDeprecation(int nHeight, bool forceLogging) {
15 int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight;
16 bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR);
17 if (blocksToDeprecation <= 0) {
18 // In order to ensure we only log once per process when deprecation is
19 // disabled (to avoid log spam), we only need to log in two cases:
20 // - The deprecating block just arrived
21 // - This can be triggered more than once if a block chain reorg
22 // occurs, but that's an irregular event that won't cause spam.
23 // - The node is starting
24 if (blocksToDeprecation == 0 || forceLogging) {
25 auto msg = strprintf(_("This version has been deprecated as of block height %d."),
26 DEPRECATION_HEIGHT) + " " +
27 _("You should upgrade to the latest version of Zcash.");
28 if (!disableDeprecation) {
29 msg += " " + strprintf(_("To disable deprecation for this version, set %s%s."),
30 "-disabledeprecation=", CLIENT_VERSION_STR);
31 }
32 LogPrintf("*** %s\n", msg);
33 uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
34 }
35 if (!disableDeprecation) {
36 StartShutdown();
37 }
38 } else if (blocksToDeprecation == DEPRECATION_WARN_LIMIT ||
39 (blocksToDeprecation < DEPRECATION_WARN_LIMIT && forceLogging)) {
40 std::string msg;
41 if (disableDeprecation) {
42 msg = strprintf(_("This version will be deprecated at block height %d."),
43 DEPRECATION_HEIGHT) + " " +
44 _("You should upgrade to the latest version of Zcash.");
45 } else {
46 msg = strprintf(_("This version will be deprecated at block height %d, and will automatically shut down."),
47 DEPRECATION_HEIGHT) + " " +
48 _("You should upgrade to the latest version of Zcash.") + " " +
49 strprintf(_("To disable deprecation for this version, set %s%s."),
50 "-disabledeprecation=", CLIENT_VERSION_STR);
51 }
52 LogPrintf("*** %s\n", msg);
53 uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING);
54 }
55}
This page took 0.029863 seconds and 4 git commands to generate.