MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / preciousblock

Function preciousblock

src/rpc/blockchain.cpp:1491–1527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1489}
1490
1491static 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
1529UniValue finalizeblock(const JSONRPCRequest& request) {
1530 if (request.fHelp || request.params.size() != 1)

Callers

nothing calls this directly

Calls 10

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
uint256SFunction · 0.85
LookupBlockIndexFunction · 0.85
JSONRPCErrorFunction · 0.85
PreciousBlockFunction · 0.85
FormatStateMessageFunction · 0.85
ParamsClass · 0.50
sizeMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected