当前位置: 首页>>代码示例>>C++>>正文


C++ CBlock::GetVersion方法代码示例

本文整理汇总了C++中CBlock::GetVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::GetVersion方法的具体用法?C++ CBlock::GetVersion怎么用?C++ CBlock::GetVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBlock的用法示例。


在下文中一共展示了CBlock::GetVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:polopoints,项目名称:polopoints,代码行数:31,代码来源:rpcblockchain.cpp

示例2: blockToJSON

Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
{
    Object result;
    result.push_back(Pair("hash", block.GetHash().GetHex()));
    CMerkleTx txGen(block.vtx[0]);
    txGen.SetMerkleBranch(&block);
    result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
    result.push_back(Pair("size", (int)blockindex->nSize));
    result.push_back(Pair("chainsize", blockindex->nChainSize));
    if (chainActive.Contains(blockindex))
        result.push_back(Pair("maxsize", (int)chainActive.MaxBlockSize(blockindex->nHeight)));
    result.push_back(Pair("height", blockindex->nHeight));
    
    result.push_back(Pair("version", (uint64_t)block.GetVersion()));
    result.push_back(Pair("ispok", block.IsPoKBlock()));
    if (block.IsPoKBlock())
        result.push_back(Pair("pok", (uint64_t)block.GetPoK()));
    result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
    result.push_back(Pair("time", block.GetBlockTime()));
    result.push_back(Pair("bits", HexBits(block.nBits)));
    result.push_back(Pair("nonce", (uint64_t)block.nNonce));
    Array txs;
    BOOST_FOREACH(const CTransaction&tx, block.vtx)
        txs.push_back(tx.GetHash().GetHex());
    result.push_back(Pair("tx", txs));
    result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
    result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
    result.push_back(Pair("ntx", (int64_t)blockindex->nTx));
    result.push_back(Pair("nchaintx", (int64_t)blockindex->nChainTx));
    
    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;
}
开发者ID:ZiftrCOIN,项目名称:ziftrcoin,代码行数:37,代码来源:rpcblockchain.cpp


注:本文中的CBlock::GetVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。