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


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

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


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

示例1:

void
CAuxpowBuilder::setCoinbase (const CScript& scr)
{
  CMutableTransaction mtx;
  mtx.vin.resize (1);
  mtx.vin[0].prevout.SetNull ();
  mtx.vin[0].scriptSig = scr;

  parentBlock.vtx.clear ();
  parentBlock.vtx.push_back (mtx);
  parentBlock.hashMerkleRoot = parentBlock.ComputeMerkleRoot ();
}
开发者ID:cryptocoinsourcecode,项目名称:namecoin-core,代码行数:12,代码来源:auxpow_tests.cpp

示例2:

/* This used to be in CBlock but was removed upstream.  We need it
   at least for unit testing, thus moved here.  */
static void
GetMerkleBranch (const CBlock& block, int nIndex,
                 std::vector<uint256>& vMerkleBranch)
{
  std::vector<uint256> vMerkleTree;
  block.ComputeMerkleRoot (vMerkleTree);
  int j = 0;
  for (int nSize = block.vtx.size (); nSize > 1; nSize = (nSize + 1) / 2)
    {
      const int i = std::min (nIndex ^ 1, nSize - 1);
      vMerkleBranch.push_back (vMerkleTree[j + i]);
      nIndex >>= 1;
      j += nSize;
    }
}
开发者ID:bankonme,项目名称:namecoin-core,代码行数:17,代码来源:auxpow.cpp

示例3: CreateGenesisBlock

static CBlock CreateGenesisBlock(const CScript& genesisInputScript, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    CMutableTransaction txNew;
    txNew.nVersion = 1;
    txNew.vin.resize(1);
    txNew.vout.resize(1);
    txNew.vin[0].scriptSig = genesisInputScript;
    txNew.vout[0].nValue = genesisReward;
    txNew.vout[0].scriptPubKey = genesisOutputScript;

    CBlock genesis;
    genesis.nTime    = nTime;
    genesis.nBits    = nBits;
    genesis.nNonce   = nNonce;
    genesis.nVersion.SetGenesisVersion(nVersion);
    genesis.vtx.push_back(txNew);
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = genesis.ComputeMerkleRoot();
    return genesis;
}
开发者ID:bamcdougall,项目名称:namecoin-core,代码行数:20,代码来源:chainparams.cpp

示例4: CreateGenesisBlock

static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    CMutableTransaction txNew;
    txNew.nVersion = 1;
    txNew.vin.resize(1);
    txNew.vout.resize(1);
    txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
    txNew.vout[0].nValue = genesisReward;
    txNew.vout[0].scriptPubKey = genesisOutputScript;

    CBlock genesis;
    genesis.nTime    = nTime;
    genesis.nBits    = nBits;
    genesis.nNonce   = nNonce;
    genesis.nVersion = nVersion;
    genesis.vtx.push_back(txNew);
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = genesis.ComputeMerkleRoot();
    return genesis;
}
开发者ID:jn2840,项目名称:bitcoin,代码行数:20,代码来源:chainparams.cpp


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