@@ -1622,6 +1622,25 @@ static RPCHelpMan invalidateblock()
1622
1622
};
1623
1623
}
1624
1624
1625
+ void ReconsiderBlock (ChainstateManager& chainman, uint256 block_hash) {
1626
+ {
1627
+ LOCK (chainman.GetMutex ());
1628
+ CBlockIndex* pblockindex = chainman.m_blockman .LookupBlockIndex (block_hash);
1629
+ if (!pblockindex) {
1630
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found" );
1631
+ }
1632
+
1633
+ chainman.ActiveChainstate ().ResetBlockFailureFlags (pblockindex);
1634
+ }
1635
+
1636
+ BlockValidationState state;
1637
+ chainman.ActiveChainstate ().ActivateBestChain (state);
1638
+
1639
+ if (!state.IsValid ()) {
1640
+ throw JSONRPCError (RPC_DATABASE_ERROR, state.ToString ());
1641
+ }
1642
+ }
1643
+
1625
1644
static RPCHelpMan reconsiderblock ()
1626
1645
{
1627
1646
return RPCHelpMan{" reconsiderblock" ,
@@ -1640,22 +1659,7 @@ static RPCHelpMan reconsiderblock()
1640
1659
ChainstateManager& chainman = EnsureAnyChainman (request.context );
1641
1660
uint256 hash (ParseHashV (request.params [0 ], " blockhash" ));
1642
1661
1643
- {
1644
- LOCK (cs_main);
1645
- CBlockIndex* pblockindex = chainman.m_blockman .LookupBlockIndex (hash);
1646
- if (!pblockindex) {
1647
- throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Block not found" );
1648
- }
1649
-
1650
- chainman.ActiveChainstate ().ResetBlockFailureFlags (pblockindex);
1651
- }
1652
-
1653
- BlockValidationState state;
1654
- chainman.ActiveChainstate ().ActivateBestChain (state);
1655
-
1656
- if (!state.IsValid ()) {
1657
- throw JSONRPCError (RPC_DATABASE_ERROR, state.ToString ());
1658
- }
1662
+ ReconsiderBlock (chainman, hash);
1659
1663
1660
1664
return UniValue::VNULL;
1661
1665
},
0 commit comments