| 1489 | } |
| 1490 | |
| 1491 | static UniValue preciousblock(const JSONRPCRequest& request) |
| 1492 | { |
| 1493 | if (request.fHelp || request.params.size() != 1) |
| 1494 | throw std::runtime_error( |
| 1495 | "preciousblock \"blockhash\"\n" |
| 1496 | "\nTreats a block as if it were received before others with the same work.\n" |
| 1497 | "\nA later preciousblock call can override the effect of an earlier one.\n" |
| 1498 | "\nThe effects of preciousblock are not retained across restarts.\n" |
| 1499 | "\nArguments:\n" |
| 1500 | "1. \"blockhash\" (string, required) the hash of the block to mark as precious\n" |
| 1501 | "\nResult:\n" |
| 1502 | "\nExamples:\n" |
| 1503 | + HelpExampleCli("preciousblock", "\"blockhash\"") |
| 1504 | + HelpExampleRpc("preciousblock", "\"blockhash\"") |
| 1505 | ); |
| 1506 | |
| 1507 | std::string strHash = request.params[0].get_str(); |
| 1508 | uint256 hash(uint256S(strHash)); |
| 1509 | CBlockIndex* pblockindex; |
| 1510 | |
| 1511 | { |
| 1512 | LOCK(cs_main); |
| 1513 | pblockindex = LookupBlockIndex(hash); |
| 1514 | if (!pblockindex) { |
| 1515 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
| 1516 | } |
| 1517 | } |
| 1518 | |
| 1519 | CValidationState state; |
| 1520 | PreciousBlock(state, Params(), pblockindex); |
| 1521 | |
| 1522 | if (!state.IsValid()) { |
| 1523 | throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state)); |
| 1524 | } |
| 1525 | |
| 1526 | return NullUniValue; |
| 1527 | } |
| 1528 | |
| 1529 | UniValue finalizeblock(const JSONRPCRequest& request) { |
| 1530 | if (request.fHelp || request.params.size() != 1) |
nothing calls this directly
no test coverage detected