]> Git Repo - VerusCoin.git/blame - src/deprecation.cpp
Fix exception
[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"
e882e3c0 11#include "chainparams.h"
5b3bc971
JG
12
13static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
9edf27ec 14extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
5b3bc971
JG
15
16void EnforceNodeDeprecation(int nHeight, bool forceLogging) {
e882e3c0
BM
17
18 // Do not enforce deprecation in regtest or on testnet
19 std::string networkID = Params().NetworkIDString();
e70b1af2 20 if (networkID != "main" || ASSETCHAINS_SYMBOL[0] != 0 ) return;
e882e3c0 21
5b3bc971
JG
22 int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight;
23 bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR);
24 if (blocksToDeprecation <= 0) {
25 // In order to ensure we only log once per process when deprecation is
26 // disabled (to avoid log spam), we only need to log in two cases:
27 // - The deprecating block just arrived
28 // - This can be triggered more than once if a block chain reorg
29 // occurs, but that's an irregular event that won't cause spam.
30 // - The node is starting
31 if (blocksToDeprecation == 0 || forceLogging) {
32 auto msg = strprintf(_("This version has been deprecated as of block height %d."),
33 DEPRECATION_HEIGHT) + " " +
34 _("You should upgrade to the latest version of Zcash.");
35 if (!disableDeprecation) {
36 msg += " " + strprintf(_("To disable deprecation for this version, set %s%s."),
37 "-disabledeprecation=", CLIENT_VERSION_STR);
38 }
39 LogPrintf("*** %s\n", msg);
40 uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
41 }
42 if (!disableDeprecation) {
43 StartShutdown();
44 }
45 } else if (blocksToDeprecation == DEPRECATION_WARN_LIMIT ||
46 (blocksToDeprecation < DEPRECATION_WARN_LIMIT && forceLogging)) {
47 std::string msg;
48 if (disableDeprecation) {
49 msg = strprintf(_("This version will be deprecated at block height %d."),
50 DEPRECATION_HEIGHT) + " " +
51 _("You should upgrade to the latest version of Zcash.");
52 } else {
53 msg = strprintf(_("This version will be deprecated at block height %d, and will automatically shut down."),
54 DEPRECATION_HEIGHT) + " " +
55 _("You should upgrade to the latest version of Zcash.") + " " +
56 strprintf(_("To disable deprecation for this version, set %s%s."),
57 "-disabledeprecation=", CLIENT_VERSION_STR);
58 }
59 LogPrintf("*** %s\n", msg);
60 uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING);
61 }
e70b1af2 62}
This page took 0.104772 seconds and 4 git commands to generate.