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


C++ ValidateSyncCheckpoint函数代码示例

本文整理汇总了C++中ValidateSyncCheckpoint函数的典型用法代码示例。如果您正苦于以下问题:C++ ValidateSyncCheckpoint函数的具体用法?C++ ValidateSyncCheckpoint怎么用?C++ ValidateSyncCheckpoint使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: AcceptPendingSyncCheckpoint

  bool AcceptPendingSyncCheckpoint()
  {
    LOCK(cs_hashSyncCheckpoint);
    if(hashPendingCheckpoint != 0 && mapBlockIndex.count(hashPendingCheckpoint))
    {
      if(!ValidateSyncCheckpoint(hashPendingCheckpoint))
      {
        hashPendingCheckpoint = 0;
        checkpointMessagePending.SetNull();
        return false;
      }

      CTxDB txdb;
      CBlockIndex *pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint];
      if(!pindexCheckpoint->IsInMainChain())
      {
        CBlock block;
        if(!block.ReadFromDisk(pindexCheckpoint))
          return error("AcceptPendingSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s",
                       hashPendingCheckpoint.ToString().c_str());
        if(!block.SetBestChain(txdb, pindexCheckpoint))
        {
          hashInvalidCheckpoint = hashPendingCheckpoint;
          return error("AcceptPendingSyncCheckpoint: SetBestChain failed for sync checkpoint %s",
                       hashPendingCheckpoint.ToString().c_str());
        }
      }
      txdb.Close();

      if(!WriteSyncCheckpoint(hashPendingCheckpoint))
        return error("AcceptPendingSyncCheckpoint(): failed to write sync checkpoint %s",
                     hashPendingCheckpoint.ToString().c_str());

      hashPendingCheckpoint = 0;
      checkpointMessage = checkpointMessagePending;
      checkpointMessagePending.SetNull();
      printf("AcceptPendingSyncCheckpoint : sync-checkpoint at %s\n", hashSyncCheckpoint.ToString().c_str());
      // relay the checkpoint
      if(!checkpointMessage.IsNull())
      {
        BOOST_FOREACH(CNode* pnode, vNodes)
          checkpointMessage.RelayTo(pnode);
      }
      return true;
    }
    return false;
  }
开发者ID:TGCproject,项目名称:ThirdGenerationCoin,代码行数:47,代码来源:checkpoints.cpp

示例2: AcceptPendingSyncCheckpoint

    bool AcceptPendingSyncCheckpoint()
    {
        LOCK(cs_hashSyncCheckpoint);
        if (hashPendingCheckpoint != 0 && mapBlockIndex.count(hashPendingCheckpoint))
        {
            if (!ValidateSyncCheckpoint(hashPendingCheckpoint))
            {
                hashPendingCheckpoint = 0;
                checkpointMessagePending.SetNull();
                LogPrintf("AcceptPendingSyncCheckpoint: FAIL1\n");
                return false;
            }

            CBlockIndex* pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint];
            if (IsSyncCheckpointEnforced() && !pindexCheckpoint->IsInMainChain())
            {
                CBlock block;
                if (!ReadBlockFromDisk(block, pindexCheckpoint))
                    return error("AcceptPendingSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
                CValidationState state;
                LogPrintf("AcceptPendingSyncCheckpoint: ConnectTip\n");
                // if (!SetBestChain(state, pindexCheckpoint))
                if (!ConnectTip(state, pindexCheckpoint))
                {
                    hashInvalidCheckpoint = hashPendingCheckpoint;
                    return error("AcceptPendingSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
                }
            }

            if (!WriteSyncCheckpoint(hashPendingCheckpoint))
                return error("AcceptPendingSyncCheckpoint(): failed to write sync checkpoint %s", hashPendingCheckpoint.ToString().c_str());
            hashPendingCheckpoint = 0;
            checkpointMessage = checkpointMessagePending;
            checkpointMessagePending.SetNull();
            LogPrintf("AcceptPendingSyncCheckpoint : sync-checkpoint at %s\n", hashSyncCheckpoint.ToString().c_str());
            // relay the checkpoint
            if (!checkpointMessage.IsNull())
            {
                BOOST_FOREACH(CNode* pnode, vNodes)
                    checkpointMessage.RelayTo(pnode);
            }
            return true;
        }
        return false;
    }
开发者ID:riftdotspace,项目名称:LAB,代码行数:45,代码来源:checkpoints.cpp


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