Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | UniValue blockheaderToJSON(const CBlockIndex *blockindex) { | ||||
} | } | ||||
CBlockIndex *pnext = chainActive.Next(blockindex); | CBlockIndex *pnext = chainActive.Next(blockindex); | ||||
if (pnext) { | if (pnext) { | ||||
result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); | result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
UniValue blockToJSON(const Config &config, const CBlock &block, | UniValue blockToJSON(const CBlock &block, const CBlockIndex *blockindex, | ||||
const CBlockIndex *blockindex, bool txDetails) { | bool txDetails) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("hash", blockindex->GetBlockHash().GetHex()); | result.pushKV("hash", blockindex->GetBlockHash().GetHex()); | ||||
int confirmations = -1; | int confirmations = -1; | ||||
// Only report confirmations if the block is on the main chain | // Only report confirmations if the block is on the main chain | ||||
if (chainActive.Contains(blockindex)) { | if (chainActive.Contains(blockindex)) { | ||||
confirmations = chainActive.Height() - blockindex->nHeight + 1; | confirmations = chainActive.Height() - blockindex->nHeight + 1; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 792 Lines • ▼ Show 20 Lines | static UniValue getblock(const Config &config, const JSONRPCRequest &request) { | ||||
if (verbosity <= 0) { | if (verbosity <= 0) { | ||||
CDataStream ssBlock(SER_NETWORK, | CDataStream ssBlock(SER_NETWORK, | ||||
PROTOCOL_VERSION | RPCSerializationFlags()); | PROTOCOL_VERSION | RPCSerializationFlags()); | ||||
ssBlock << block; | ssBlock << block; | ||||
std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); | std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); | ||||
return strHex; | return strHex; | ||||
} | } | ||||
return blockToJSON(config, block, pblockindex, verbosity >= 2); | return blockToJSON(block, pblockindex, verbosity >= 2); | ||||
} | } | ||||
struct CCoinsStats { | struct CCoinsStats { | ||||
int nHeight; | int nHeight; | ||||
uint256 hashBlock; | uint256 hashBlock; | ||||
uint64_t nTransactions; | uint64_t nTransactions; | ||||
uint64_t nTransactionOutputs; | uint64_t nTransactionOutputs; | ||||
uint64_t nBogoSize; | uint64_t nBogoSize; | ||||
▲ Show 20 Lines • Show All 1,011 Lines • Show Last 20 Lines |