本文整理汇总了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 ();
}
示例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;
}
}
示例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;
}
示例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;
}