@@ -2929,22 +2929,7 @@ void ThreadScriptCheck() {
2929
2929
2930
2930
bool BitcoindRPCCheck (const bool init)
2931
2931
{
2932
- // First, we can clear out any blocks thatsomehow are now deemed valid
2933
- // eg reconsiderblock rpc call manually
2934
- std::vector<uint256> vblocksToReconsider;
2935
- pblocktree->ReadInvalidBlockQueue (vblocksToReconsider);
2936
- std::vector<uint256> vblocksToReconsiderAgain;
2937
- BOOST_FOREACH (uint256& blockhash, vblocksToReconsider) {
2938
- CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2939
- if ((pblockindex->nStatus & BLOCK_FAILED_MASK)) {
2940
- vblocksToReconsiderAgain.push_back (blockhash);
2941
- }
2942
- }
2943
- vblocksToReconsider = vblocksToReconsiderAgain;
2944
- vblocksToReconsiderAgain.clear ();
2945
- pblocktree->WriteInvalidBlockQueue (vblocksToReconsider);
2946
-
2947
- // Next, check for working rpc
2932
+ // Check for working rpc
2948
2933
if (GetBoolArg (" -validatepegin" , DEFAULT_VALIDATE_PEGIN)) {
2949
2934
// During init try until a non-RPC_IN_WARMUP result
2950
2935
while (true ) {
@@ -2979,35 +2964,46 @@ bool BitcoindRPCCheck(const bool init)
2979
2964
}
2980
2965
}
2981
2966
2967
+
2982
2968
// Sanity startup check won't reconsider queued blocks
2983
2969
if (init) {
2984
2970
return true ;
2985
2971
}
2986
2972
2987
- /* Getting this far means we either aren't validating pegins(so let's make sure that's why
2988
- it failed previously) or we successfully connected to bitcoind
2989
- Time to reconsider blocks
2990
- */
2991
- if (vblocksToReconsider.size () > 0 ) {
2992
- CValidationState state;
2993
- BOOST_FOREACH (const uint256& blockhash, vblocksToReconsider) {
2994
- {
2995
- LOCK (cs_main);
2996
- if (mapBlockIndex.count (blockhash) == 0 )
2997
- continue ;
2998
- CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2999
- ResetBlockFailureFlags (pblockindex);
3000
- }
3001
- }
2973
+ // First, we can clear out any blocks thatsomehow are now deemed valid
2974
+ // eg reconsiderblock rpc call manually
2975
+ std::vector<uint256> vblocksToReconsider;
2976
+ pblocktree->ReadInvalidBlockQueue (vblocksToReconsider);
3002
2977
3003
- // All blocks are now being reconsidered
3004
- ActivateBestChain (state, Params ());
3005
- // This simply checks for DB errors
3006
- if (!state.IsValid ()) {
3007
- // Something scary?
2978
+ BOOST_FOREACH (uint256& blockhash, vblocksToReconsider) {
2979
+ // Skip blocks that have been validated in meantime
2980
+ if (mapBlockIndex.count (blockhash) == 0 ) {
2981
+ continue ;
2982
+ }
2983
+ CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2984
+ if (!(pblockindex->nStatus & BLOCK_FAILED_MASK)) {
2985
+ continue ;
3008
2986
}
2987
+ {
2988
+ LOCK (cs_main);
2989
+ CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2990
+ ResetBlockFailureFlags (pblockindex);
2991
+ }
2992
+ }
2993
+
2994
+ CValidationState state;
2995
+ // All blocks are now being reconsidered
2996
+ ActivateBestChain (state, Params ());
2997
+ // This simply checks for DB errors
2998
+ if (!state.IsValid ()) {
2999
+ // Something scary?
3000
+ }
3009
3001
3010
- // Now to clear out now-valid blocks
3002
+ {
3003
+ // Clear out now-valid blocks in list
3004
+ LOCK (cs_main);
3005
+ std::vector<uint256> vblocksToReconsiderAgain;
3006
+ pblocktree->ReadInvalidBlockQueue (vblocksToReconsider);
3011
3007
BOOST_FOREACH (const uint256& blockhash, vblocksToReconsider) {
3012
3008
CBlockIndex* pblockindex = mapBlockIndex[blockhash];
3013
3009
@@ -3019,7 +3015,7 @@ bool BitcoindRPCCheck(const bool init)
3019
3015
3020
3016
// Write back remaining blocks
3021
3017
pblocktree->WriteInvalidBlockQueue (vblocksToReconsiderAgain);
3022
- }
3018
+ }
3023
3019
return true ;
3024
3020
}
3025
3021
0 commit comments