| 336 | } |
| 337 | |
| 338 | Value invalidateblock(const Array& params, bool fHelp) { |
| 339 | if (fHelp || params.size() != 1) { |
| 340 | throw runtime_error( |
| 341 | "invalidateblock \"hash\"\n" |
| 342 | "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n" |
| 343 | "\nArguments:\n" |
| 344 | "1. \"hash\" (string, required) the hash of the block to mark as invalid\n" |
| 345 | "\nResult:\n" |
| 346 | "\nExamples:\n" |
| 347 | + HelpExampleRpc("invalidateblock", "\"hash\"")); |
| 348 | } |
| 349 | |
| 350 | std::string strHash = params[0].get_str(); |
| 351 | uint256 hash(uint256S(strHash)); |
| 352 | CValidationState state; |
| 353 | |
| 354 | { |
| 355 | LOCK(cs_main); |
| 356 | if (mapBlockIndex.count(hash) == 0) |
| 357 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
| 358 | |
| 359 | CBlockIndex* pBlockIndex = mapBlockIndex[hash]; |
| 360 | InvalidateBlock(state, pBlockIndex); |
| 361 | } |
| 362 | |
| 363 | if (state.IsValid()) { |
| 364 | ActivateBestChain(state); |
| 365 | } |
| 366 | |
| 367 | if (!state.IsValid()) { |
| 368 | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); |
| 369 | } |
| 370 | |
| 371 | Object obj; |
| 372 | obj.push_back(Pair("msg", "success")); |
| 373 | return obj; |
| 374 | } |
| 375 | |
| 376 | Value reconsiderblock(const Array& params, bool fHelp) { |
| 377 | if (fHelp || params.size() < 1 || params.size() > 2) { |
nothing calls this directly
no test coverage detected