Skip to content

Commit

Permalink
Merge bitcoin#8019: Remove state arg from ReconsiderBlock, rename to …
Browse files Browse the repository at this point in the history
…ResetBlockFailureFlags

657e07e Rename ReconsiderBlock func to reflect real behavior (instagibbs)
addb9d2 Remove state arg from ReconsiderBlock (instagibbs)
  • Loading branch information
laanwj committed May 10, 2016
2 parents 5767e80 + 657e07e commit f7a21da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3008,7 +3008,7 @@ bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, C
return true;
}

bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) {
bool ResetBlockFailureFlags(CBlockIndex *pindex) {
AssertLockHeld(cs_main);

int nHeight = pindex->nHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex);

/** Remove invalidity status from a block and its descendants. */
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);
bool ResetBlockFailureFlags(CBlockIndex *pindex);

/** The currently-connected chain of blocks (protected by cs_main). */
extern CChain chainActive;
Expand Down
8 changes: 3 additions & 5 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,20 +973,18 @@ UniValue reconsiderblock(const UniValue& params, bool fHelp)

std::string strHash = params[0].get_str();
uint256 hash(uint256S(strHash));
CValidationState state;

{
LOCK(cs_main);
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");

CBlockIndex* pblockindex = mapBlockIndex[hash];
ReconsiderBlock(state, pblockindex);
ResetBlockFailureFlags(pblockindex);
}

if (state.IsValid()) {
ActivateBestChain(state, Params());
}
CValidationState state;
ActivateBestChain(state, Params());

if (!state.IsValid()) {
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
Expand Down

0 comments on commit f7a21da

Please sign in to comment.