Skip to content

Commit

Permalink
Remove -stop-block (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar authored Mar 13, 2024
1 parent d47709b commit ea107eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
7 changes: 2 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void SetupServerArgs()
// Hidden Options
std::vector<std::string> hidden_args = {
"-dbcrashratio", "-forcecompactdb",
"-interrupt-block=<hash|height>", "-stop-block=<hash|height>",
"-interrupt-block=<hash|height>",
"-mocknet", "-mocknet-blocktime=<secs>", "-mocknet-key=<pubkey>",
"-checkpoints-file",
// GUI args. These will be overwritten by SetupUIArgs for the GUI
Expand Down Expand Up @@ -1712,10 +1712,7 @@ bool SetupInterruptArg(const std::string &argName, std::string &hashStore, int &
}

void SetupInterrupts() {
auto isSet = false;
isSet = SetupInterruptArg("-interrupt-block", fInterruptBlockHash, fInterruptBlockHeight) || isSet;
isSet = SetupInterruptArg("-stop-block", fStopBlockHash, fStopBlockHeight) || isSet;
fStopOrInterrupt = isSet;
fInterrupt = SetupInterruptArg("-interrupt-block", fInterruptBlockHash, fInterruptBlockHeight);
}

bool AppInitMain(InitInterfaces& interfaces)
Expand Down
14 changes: 3 additions & 11 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@ bool fPruneMode = false;
bool fRequireStandard = true;
bool fCheckBlockIndex = false;

bool fStopOrInterrupt = false;
bool fInterrupt = false;
std::string fInterruptBlockHash = "";
int fInterruptBlockHeight = -1;
std::string fStopBlockHash = "";
int fStopBlockHeight = -1;

size_t nCoinCacheUsage = 5000 * 300;
size_t nCustomMemUsage = nDefaultDbCache << 10;
Expand Down Expand Up @@ -2583,21 +2581,15 @@ uint32_t GetNextAccPosition() {
}

bool StopOrInterruptConnect(const CBlockIndex *pIndex, CValidationState &state) {
if (!fStopOrInterrupt) {
if (!fInterrupt) {
return false;
}

const auto checkMatch = [](const CBlockIndex *index, const int height, const std::string &hash) {
return height == index->nHeight || (!hash.empty() && hash == index->phashBlock->ToString());
};

// Stop is processed first. So, if a block has both stop and interrupt
// stop will take priority.
if (checkMatch(pIndex, fStopBlockHeight, fStopBlockHash) ||
checkMatch(pIndex, fInterruptBlockHeight, fInterruptBlockHash)) {
if (pIndex->nHeight == fStopBlockHeight) {
StartShutdown();
}
if (checkMatch(pIndex, fInterruptBlockHeight, fInterruptBlockHash)) {
state.Invalid(
ValidationInvalidReason::CONSENSUS, error("%s: user interrupt", __func__), "user-interrupt-request");
return true;
Expand Down
4 changes: 1 addition & 3 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,9 @@ extern std::atomic_bool fReindex;
extern bool fRequireStandard;
extern bool fCheckBlockIndex;

extern bool fStopOrInterrupt;
extern bool fInterrupt;
extern std::string fInterruptBlockHash;
extern int fInterruptBlockHeight;
extern std::string fStopBlockHash;
extern int fStopBlockHeight;

extern size_t nCoinCacheUsage;
extern size_t nCustomMemUsage;
Expand Down

0 comments on commit ea107eb

Please sign in to comment.