Call InvalidateBlock without cs_main held
This commit is contained in:
parent
241b2c74ac
commit
9b1ff5c742
3 changed files with 6 additions and 6 deletions
|
@ -1583,15 +1583,15 @@ static UniValue invalidateblock(const JSONRPCRequest& request)
|
||||||
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
uint256 hash(ParseHashV(request.params[0], "blockhash"));
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
|
|
||||||
|
CBlockIndex* pblockindex;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CBlockIndex* pblockindex = LookupBlockIndex(hash);
|
pblockindex = LookupBlockIndex(hash);
|
||||||
if (!pblockindex) {
|
if (!pblockindex) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateBlock(state, Params(), pblockindex);
|
|
||||||
}
|
}
|
||||||
|
InvalidateBlock(state, Params(), pblockindex);
|
||||||
|
|
||||||
if (state.IsValid()) {
|
if (state.IsValid()) {
|
||||||
ActivateBestChain(state, Params());
|
ActivateBestChain(state, Params());
|
||||||
|
|
|
@ -177,7 +177,7 @@ public:
|
||||||
|
|
||||||
// Manual block validity manipulation:
|
// Manual block validity manipulation:
|
||||||
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
|
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex* pindex) LOCKS_EXCLUDED(cs_main);
|
||||||
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex);
|
||||||
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
|
bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
|
||||||
|
@ -2789,7 +2789,7 @@ bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIn
|
||||||
|
|
||||||
bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex)
|
bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
// We first disconnect backwards and then mark the blocks as invalid.
|
// We first disconnect backwards and then mark the blocks as invalid.
|
||||||
// This prevents a case where pruned nodes may fail to invalidateblock
|
// This prevents a case where pruned nodes may fail to invalidateblock
|
||||||
|
|
|
@ -448,7 +448,7 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
|
||||||
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main);
|
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main);
|
||||||
|
|
||||||
/** Mark a block as invalid. */
|
/** Mark a block as invalid. */
|
||||||
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindex);
|
||||||
|
|
||||||
/** Remove invalidity status from a block and its descendants. */
|
/** Remove invalidity status from a block and its descendants. */
|
||||||
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
void ResetBlockFailureFlags(CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
Loading…
Reference in a new issue