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


C++ CBlockIndex::GetProofOfBurn方法代码示例

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


在下文中一共展示了CBlockIndex::GetProofOfBurn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadBlockIndex

bool CTxDB::LoadBlockIndex()
{
    // Get database cursor
    Dbc* pcursor = GetCursor();
    if (!pcursor)
        return false;

    // Load mapBlockIndex
    unsigned int fFlags = DB_SET_RANGE;
  for(;;)
    {
        // Read next record
        CDataStream ssKey(SER_DISK, CLIENT_VERSION);
        if (fFlags == DB_SET_RANGE)
            ssKey << make_pair(string("blockindex"), uint256(0));
        CDataStream ssValue(SER_DISK, CLIENT_VERSION);
        int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
        fFlags = DB_NEXT;
        if (ret == DB_NOTFOUND)
            break;
        else if (ret != 0)
            return false;

        // Unserialize

        try {
        string strType;
        ssKey >> strType;
        if (strType == "blockindex" && !fRequestShutdown)
        {
            CDiskBlockIndex diskindex;
            ssValue >> diskindex;

            uint256 blockHash = diskindex.GetBlockHash();

            // Construct block index object
            CBlockIndex* pindexNew    = InsertBlockIndex(blockHash);
            pindexNew->pprev          = InsertBlockIndex(diskindex.hashPrev);
            pindexNew->pnext          = InsertBlockIndex(diskindex.hashNext);
            pindexNew->nFile          = diskindex.nFile;
            pindexNew->nBlockPos      = diskindex.nBlockPos;
            pindexNew->nHeight        = diskindex.nHeight;
            pindexNew->nMint          = diskindex.nMint;
            pindexNew->nMoneySupply   = diskindex.nMoneySupply;
            pindexNew->nFlags         = diskindex.nFlags;
            pindexNew->nStakeModifier = diskindex.nStakeModifier;
            pindexNew->prevoutStake   = diskindex.prevoutStake;
            pindexNew->nStakeTime     = diskindex.nStakeTime;
            pindexNew->hashProofOfStake = diskindex.hashProofOfStake;
            pindexNew->nVersion       = diskindex.nVersion;
            pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
            pindexNew->nTime          = diskindex.nTime;
            pindexNew->nBits          = diskindex.nBits;
            pindexNew->nNonce         = diskindex.nNonce;

            //Load Proof of Burn switch and indexes
            pindexNew->fProofOfBurn   = diskindex.fProofOfBurn;
            pindexNew->burnHash       = diskindex.burnHash;
            pindexNew->burnBlkHeight  = diskindex.burnBlkHeight;
            pindexNew->burnCTx        = diskindex.burnCTx;
            pindexNew->burnCTxOut     = diskindex.burnCTxOut;
            pindexNew->nEffectiveBurnCoins = diskindex.nEffectiveBurnCoins;
            pindexNew->nBurnBits      = diskindex.nBurnBits;

            // Watch for genesis block
            if (pindexGenesisBlock == NULL && blockHash == hashGenesisBlock)
                pindexGenesisBlock = pindexNew;

            if (!pindexNew->CheckIndex())
                return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight);

            // ppcoin: build setStakeSeen
            if (pindexNew->IsProofOfStake())
                setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime));
            else if(pindexNew->IsProofOfBurn()) //build the setBurnSeen
                setBurnSeen.insert(pindexNew->GetProofOfBurn());
        }
        else
        {
            break; // if shutdown requested or finished loading block index
        }
        }    // try
        catch (std::exception &e) {
开发者ID:slimcoin-project,项目名称:Slimcoin,代码行数:83,代码来源:db.cpp


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