本文整理汇总了C++中CBlock::IsProofOfStake方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::IsProofOfStake方法的具体用法?C++ CBlock::IsProofOfStake怎么用?C++ CBlock::IsProofOfStake使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlock
的用法示例。
在下文中一共展示了CBlock::IsProofOfStake方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blockToJSON
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPrintTransactionDetail)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
CMerkleTx txGen(block.vtx[0]);
txGen.SetMerkleBranch(&block);
result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
result.push_back(Pair("mint", ValueFromAmount(blockindex->nMint)));
result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime()));
result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
result.push_back(Pair("bits", HexBits(block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("blocktrust", leftTrim(blockindex->GetBlockTrust().GetHex(), '0')));
result.push_back(Pair("chaintrust", leftTrim(blockindex->nChainTrust.GetHex(), '0')));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
if (blockindex->pnext)
result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex()));
result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
if (!blockindex->IsProofOfStake() && block.vtx[0].vout.size() > 1)
result.push_back(Pair("extraflags", "proof-of-transaction"));
else
result.push_back(Pair("extraflags", "none"));
result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex()));
result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
result.push_back(Pair("modifier", strprintf("%016"PRI64x, blockindex->nStakeModifier)));
result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
Array txinfo;
BOOST_FOREACH (const CTransaction& tx, block.vtx)
{
if (fPrintTransactionDetail)
{
Object entry;
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
TxToJSON(tx, 0, entry);
txinfo.push_back(entry);
}
else
txinfo.push_back(tx.GetHash().GetHex());
}
result.push_back(Pair("tx", txinfo));
if ( block.IsProofOfStake() || !fTestNet )
result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end())));
return result;
}
示例2: blockToJSON
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPrintTransactionDetail)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
int confirmations = -1;
// Only report confirmations if the block is on the main chain
if (blockindex->IsInMainChain())
confirmations = nBestHeight - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
result.push_back(Pair("mint", ValueFromAmount(blockindex->nMint)));
result.push_back(Pair("moneysupply", ValueFromAmount(blockindex->nMoneySupply)));
result.push_back(Pair("digsupply", ValueFromAmount(blockindex->nDigsupply)));
result.push_back(Pair("stakesupply", ValueFromAmount(blockindex->nStakeSupply)));
result.push_back(Pair("activesupply", ValueFromAmount(blockindex->nDigsupply + blockindex->nStakeSupply)));
result.push_back(Pair("time", (int64_t)block.GetBlockTime()));
result.push_back(Pair("nonce", (uint64_t)block.nNonce));
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("blocktrust", leftTrim(blockindex->GetBlockTrust().GetHex(), '0')));
result.push_back(Pair("chaintrust", leftTrim(blockindex->nChainTrust.GetHex(), '0')));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
if (blockindex->pnext)
result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex()));
result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
result.push_back(Pair("proofhash", blockindex->hashProof.GetHex()));
result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
result.push_back(Pair("modifier", strprintf("%016x", blockindex->nStakeModifier)));
Array txinfo;
BOOST_FOREACH (const CTransaction& tx, block.vtx)
{
if (fPrintTransactionDetail)
{
Object entry;
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
TxToJSON(tx, 0, entry);
txinfo.push_back(entry);
}
else
txinfo.push_back(tx.GetHash().GetHex());
}
result.push_back(Pair("tx", txinfo));
if (block.IsProofOfStake())
result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end())));
return result;
}
示例3: blockToJSON
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
int confirmations = -1;
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->nHeight + 1;
result.push_back(Pair("confirmations", confirmations));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion.GetFullVersion()));
result.push_back(Pair("proof_type", block.IsProofOfStake() ? "PoS" : "PoW"));
if (block.IsProofOfStake())
result.push_back(Pair("stake_source", COutPoint(block.stakePointer.txid, block.stakePointer.nPos).ToString()));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
Array txs;
BOOST_FOREACH(const CTransaction&tx, block.vtx)
{
if(txDetails)
{
Object objTx;
TxToJSON(tx, uint256(), objTx);
txs.push_back(objTx);
}
else
txs.push_back(tx.GetHash().GetHex());
}
result.push_back(Pair("tx", txs));
result.push_back(Pair("time", block.GetBlockTime()));
result.push_back(Pair("nonce", (uint64_t)block.nNonce));
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
result.push_back(Pair("block_witnesses", (int64_t)g_proofTracker->GetWitnessCount(block.GetHash())));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
CBlockIndex *pnext = chainActive.Next(blockindex);
if (pnext)
result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex()));
return result;
}
示例4: loadStakeChart
void ProfitExplorerPage::loadStakeChart(bool firstRun)
{
if(fShutdown)
return;
nTimeData.clear();
netStakeData.clear();
myStakeData.clear();
difficultyData.clear();
velTimeData.clear();
velAmountData.clear();
// go back this many blocks max
int max = ui->spinBox->value();
int i = 0;
//BOOST_REVERSE_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& b, mapBlockIndex)
//{
// if(i >= max)
// break;
CBlockIndex* pindex = pindexBest;
while(i < max && pindex != NULL)
{
//CBlockIndex* pindex = b.second;
if(pindex->IsProofOfStake())
{
nTimeData.append(pindex->nTime);
netStakeData.append(pindex->nMint / COIN);
// Read the block in and check if the coinstake is ours
CBlock block;
block.ReadFromDisk(pindex, true);
if(block.IsProofOfStake()) // this should always be true here
{
velTimeData.append(pindex->nTime);
double blockOutAmount = 0;
for(int j=0; j<block.vtx.size(); j++)
{
blockOutAmount += block.vtx[j].GetValueOut() / COIN;
}
velAmountData.append(blockOutAmount);
difficultyData.append(GetDifficulty(pindex));
if(pwalletMain->IsMine(block.vtx[1]))
{
myStakeData.append(pindex->nMint / COIN);
}
else
{
myStakeData.append(0);
}
}
else
{
myStakeData.append(0); // should never happen
}
i = i + 1;
}
pindex = pindex->pprev;
//++i;
}
if(!firstRun)
{
uint64_t nMinWeight = 0, nMaxWeight = 0, nWeight = 0;
pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight);
uint64_t nNetworkWeight = 0;
if(pindexBest)
nNetworkWeight = GetPoSKernelPS();
bool staking = nLastCoinStakeSearchInterval && nWeight;
int nExpectedTime = staking ? (nTargetSpacing * nNetworkWeight / nWeight) : -1;
ui->stakingLabel->setText(staking ? "Enabled" : "Disabled");
if(pindexBest)
ui->difficultyLabel->setText(QString::number(GetDifficulty(GetLastBlockIndex(pindexBest, true))));
ui->weightLabel->setText(QString::number(nWeight));
ui->netWeightLabel->setText(QString::number(nNetworkWeight));
ui->timeToStakeLabel->setText(QString::number(nExpectedTime) + " secs");
}
//qDebug() << "Stake blocks processed:";
//qDebug() << i;
ui->customPlot->clearPlottables();
ui->customPlot->clearGraphs();
ui->customPlot->clearItems();
ui->customPlot->addGraph();
ui->customPlot->graph(0)->setPen(QPen(QColor(206, 206, 206))); // line color green for first graph
ui->customPlot->graph(0)->setBrush(QBrush(QColor(206, 206, 206, 20))); // first graph will be filled with translucent green
ui->customPlot->addGraph();
ui->customPlot->graph(1)->setPen(QPen(QColor(76, 255, 0))); // line color red for second graph
ui->customPlot->graph(1)->setBrush(QBrush(QColor(76, 255, 0, 20)));
if(ui->networkCheckBox->isChecked())
ui->customPlot->graph(0)->setData(nTimeData, netStakeData);
ui->customPlot->graph(1)->setData(nTimeData, myStakeData);
//ui->customPlot->xAxis->setRangeLower(nTimeData.first());
//ui->customPlot->xAxis->setRangeUpper(nTimeData.last());
QLinearGradient plotGradient;
//.........这里部分代码省略.........