| 374 | } |
| 375 | |
| 376 | Value reconsiderblock(const Array& params, bool fHelp) { |
| 377 | if (fHelp || params.size() < 1 || params.size() > 2) { |
| 378 | throw runtime_error( |
| 379 | "reconsiderblock \"hash\" [children]\n" |
| 380 | "\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n" |
| 381 | "This can be used to undo the effects of invalidateblock.\n" |
| 382 | "\nArguments:\n" |
| 383 | "1. hash (string, required) the hash of the block to reconsider\n" |
| 384 | "2. children (bool, optional) reconsider all children of the block, default is false" |
| 385 | "\nResult:\n" |
| 386 | "\nExamples:\n" |
| 387 | + HelpExampleRpc("reconsiderblock", "\"hash\" false")); |
| 388 | } |
| 389 | |
| 390 | std::string strHash = params[0].get_str(); |
| 391 | bool children = params.size() > 1 ? params[1].get_bool() : false; |
| 392 | uint256 hash(uint256S(strHash)); |
| 393 | CValidationState state; |
| 394 | |
| 395 | { |
| 396 | LOCK(cs_main); |
| 397 | if (mapBlockIndex.count(hash) == 0) |
| 398 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
| 399 | |
| 400 | CBlockIndex* pBlockIndex = mapBlockIndex[hash]; |
| 401 | ReconsiderBlock(state, pBlockIndex, children); |
| 402 | } |
| 403 | |
| 404 | if (state.IsValid()) { |
| 405 | ActivateBestChain(state); |
| 406 | } |
| 407 | |
| 408 | if (!state.IsValid()) { |
| 409 | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); |
| 410 | } |
| 411 | |
| 412 | Object obj; |
| 413 | obj.push_back(Pair("msg", "success")); |
| 414 | return obj; |
| 415 | } |
| 416 | |
| 417 | |
| 418 | class TpsTester { |
nothing calls this directly
no test coverage detected