本文整理汇总了C++中CBlock::GetBits方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::GetBits方法的具体用法?C++ CBlock::GetBits怎么用?C++ CBlock::GetBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlock
的用法示例。
在下文中一共展示了CBlock::GetBits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blockToJSON
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
CMerkleTx txGen(block.vptx[0]);
txGen.SetMerkleBranch(&block);
result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.GetVersion()));
result.push_back(Pair("merkleroot", block.GetHashMerkleRoot().GetHex()));
result.push_back(Pair("txnumber", (int)block.vptx.size()));
Array txs;
for (const auto& ptx : block.vptx)
// txs.push_back(TxToJSON(ptx.get()));
txs.push_back(ptx->GetHash().GetHex());
result.push_back(Pair("tx", txs));
result.push_back(Pair("time", block.GetBlockTime()));
result.push_back(Pair("nonce", (uint64_t)block.GetNonce()));
result.push_back(Pair("bits", HexBits(block.GetBits())));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
result.push_back(Pair("fuel", blockindex->nFuel));
result.push_back(Pair("fuelrate", blockindex->nFuelRate));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));
return result;
}