本文整理汇总了C++中ledger::ref::getdividendbaseledger方法的典型用法代码示例。如果您正苦于以下问题:C++ ref::getdividendbaseledger方法的具体用法?C++ ref::getdividendbaseledger怎么用?C++ ref::getdividendbaseledger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ledger::ref
的用法示例。
在下文中一共展示了ref::getdividendbaseledger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doapplyvalidation
void doapplyvalidation(ledger::ref lastclosedledger, stobject& basevalidation) override
{
dividendmaster::pointer dividendmaster = getapp().getops().getdividendmaster();
if (dividendmaster->trylock())
{
if (dividendmaster->isready())
{
uint32_t dividendledger = lastclosedledger->getdividendbaseledger();
if (dividendledger == dividendmaster->getledgerseq())
{
basevalidation.setfieldu32 (sfdividendledger, dividendledger);
basevalidation.setfieldh256 (sfdividendresulthash, dividendmaster->getresulthash());
if (m_journal.info)
m_journal.info << "voting for a dividend apply based " << dividendledger << " with hash "<< dividendmaster->getresulthash() << " in " << lastclosedledger->gethash();
}
else
{
if (m_journal.warning)
m_journal.warning << "wrong base ledger " << dividendmaster->getledgerseq() << " want "<< dividendledger;
}
}
dividendmaster->unlock();
}
}
示例2: doapplyvoting
bool doapplyvoting(ledger::ref lastclosedledger, shamap::ref initialposition) override
{
uint32_t dividendledger = lastclosedledger->getdividendbaseledger();
int weight = 0;
std::map<uint256, int> votes;
// get validations for validation ledger
validationset const set = getapp().getvalidations ().getvalidations (lastclosedledger->gethash ());
for (auto const& e : set)
{
stvalidation const& val = *e.second;
if (val.istrusted ())
{
if (val.isfieldpresent (sfdividendledger) &&
val.isfieldpresent (sfdividendresulthash))
{
uint32_t ledgerseq = val.getfieldu32 (sfdividendledger);
if (ledgerseq != dividendledger)
continue;
const uint256 & dividendhash = val.getfieldh256 (sfdividendresulthash);
++votes[dividendhash];
// if (ledgerseq != dividendledger || dividendhash != dividendresulthash) {
if (m_journal.debug)
m_journal.debug << "recv dividend apply vote based " << ledgerseq << " hash " << dividendhash << " from validator " << val.getnodeid() << " in " << lastclosedledger->gethash();
// continue;
// }
// ++weight;
}
}
}
uint256 dividendresulthash;
for (auto const& v : votes)
{
if (v.second > weight)
{
dividendresulthash = v.first;
weight = v.second;
}
}
dividendmaster::pointer dividendmaster = getapp().getops().getdividendmaster();
if (!dividendmaster->trylock())
{
if (weight >=getapp().getledgermaster().getminvalidations())
return false;
else
return true;
}
if (!dividendmaster->isready() ||
dividendledger != dividendmaster->getledgerseq() ||
dividendresulthash != dividendmaster->getresulthash())
{
if (dividendmaster->isready())
m_journal.warning << "we got mismatch dividend apply based " << dividendledger << " hash " << dividendresulthash << " ours " << dividendmaster->getresulthash() << " based " << dividendmaster->getledgerseq() << " in " << lastclosedledger->gethash();
dividendmaster->unlock();
if (weight >=getapp().getledgermaster().getminvalidations())
return false;
else
return true;
}
if (weight >= getapp().getledgermaster().getminvalidations())
{
m_journal.warning << "we are voting for a dividend apply based " << dividendledger << " hash " << dividendresulthash << " with " << weight << " same votes in " << lastclosedledger->gethash();
dividendmaster->filldivresult(initialposition);
dividendmaster->filldivready(initialposition);
dividendmaster->setready(false);
}
else
{
m_journal.warning << "we are cancelling a dividend apply with only " << weight << " same votes in " << lastclosedledger->gethash();
dividendmaster->settotaldividend(0);
dividendmaster->settotaldividendvbc(0);
dividendmaster->setsumvrank(0);
dividendmaster->setsumvspd(0);
dividendmaster->setresulthash(uint256());
dividendmaster->filldivready(initialposition);
dividendmaster->setready(false);
}
dividendmaster->unlock();
return true;
}