本文整理汇总了C++中CBlock::SetTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::SetTime方法的具体用法?C++ CBlock::SetTime怎么用?C++ CBlock::SetTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlock
的用法示例。
在下文中一共展示了CBlock::SetTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBlockWithAppointedAddr
uint256 CreateBlockWithAppointedAddr(CKeyID const &keyID)
{
if (SysCfg().NetworkID() == CBaseParams::REGTEST)
{
// unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
mempool.GetTransactionsUpdated();
CBlockIndex* pindexPrev = chainActive.Tip();
CAccountViewCache accview(*pAccountViewTip, true);
CTransactionDBCache txCache(*pTxCacheTip, true);
CScriptDBViewCache ScriptDbTemp(*pScriptDBTip, true);
shared_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(accview,txCache,ScriptDbTemp));
if (!pblocktemplate.get())
return uint256();
CBlock *pblock = &pblocktemplate.get()->block;
// int nBlockSize = pblock->GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION);
pblock->GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION);
// int64_t nStart = GetTime();
while (true) {
pblock->SetTime(max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()));
set<CKeyID> setCreateKey;
setCreateKey.clear();
setCreateKey.insert(keyID);
if (CreatePosTx(pindexPrev, pblock,setCreateKey,accview,txCache,ScriptDbTemp)) {
CheckWork(pblock, *pwalletMain);
// int nBlockSize = pblock->GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION);
}
if(setCreateKey.empty())
{
LogPrint("postx", "%s is not exist in the wallet\r\n",keyID.ToAddress());
break;
}
::MilliSleep(1);
if (pindexPrev != chainActive.Tip())
{
return chainActive.Tip()->GetBlockHash() ;
}
}
}
return uint256();
}