本文整理汇总了C++中ledger::ref::getLedgerSeq方法的典型用法代码示例。如果您正苦于以下问题:C++ ref::getLedgerSeq方法的具体用法?C++ ref::getLedgerSeq怎么用?C++ ref::getLedgerSeq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ledger::ref
的用法示例。
在下文中一共展示了ref::getLedgerSeq方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void OrderBookDB::setup (Ledger::ref ledger)
{
{
ScopedLockType sl (mLock);
auto seq = ledger->getLedgerSeq ();
// Do a full update every 256 ledgers
if (mSeq != 0)
{
if (seq == mSeq)
return;
if ((seq > mSeq) && ((seq - mSeq) < 256))
return;
if ((seq < mSeq) && ((mSeq - seq) < 16))
return;
}
WriteLog (lsDEBUG, OrderBookDB)
<< "Advancing from " << mSeq << " to " << seq;
mSeq = seq;
}
if (getConfig().RUN_STANDALONE)
update(ledger);
else
getApp().getJobQueue().addJob(jtUPDATE_PF, "OrderBookDB::update",
std::bind(&OrderBookDB::update, this, ledger));
}
示例2: validatedLedger
void LedgerHistory::validatedLedger (Ledger::ref ledger)
{
LedgerIndex index = ledger->getLedgerSeq();
LedgerHash hash = ledger->getHash();
assert (!hash.isZero());
ConsensusValidated::ScopedLockType sl (
m_consensus_validated.peekMutex());
std::shared_ptr< std::pair< LedgerHash, LedgerHash > > entry = std::make_shared<std::pair< LedgerHash, LedgerHash >>();
m_consensus_validated.canonicalize(index, entry, false);
if (entry->second != hash)
{
bool mismatch (false);
if (entry->second.isNonZero() && (entry->second != hash))
{
WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index << " validated:" << entry->second << " then:" << hash;
mismatch = true;
}
if (entry->first.isNonZero() && (entry->first != hash))
{
WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index << " built:" << entry->first << " validated:" << hash;
mismatch = true;
}
if (mismatch)
handleMismatch (entry->second, hash);
entry->second = hash;
}
}
示例3: amendmentSet
void
AmendmentTableImpl::doVoting (Ledger::ref lastClosedLedger,
SHAMap::ref initialPosition)
{
// LCL must be flag ledger
assert((lastClosedLedger->getLedgerSeq () % 256) == 0);
AmendmentSet amendmentSet (lastClosedLedger->getParentCloseTimeNC ());
// get validations for ledger before flag ledger
ValidationSet valSet = getApp().getValidations ().getValidations (lastClosedLedger->getParentHash ());
for (auto const& entry : valSet)
{
auto const& val = *entry.second;
if (val.isTrusted ())
{
amendmentSet.addVoter ();
if (val.isFieldPresent (sfAmendments))
{
for (auto const& amendment : val.getFieldV256 (sfAmendments))
{
amendmentSet.addVote (amendment);
}
}
}
}
reportValidations (amendmentSet);
amendmentList_t lAmendments = getToEnable (lastClosedLedger->getCloseTimeNC ());
for (auto const& uAmendment : lAmendments)
{
if (m_journal.warning) m_journal.warning <<
"Voting for amendment: " << uAmendment;
// Create the transaction to enable the amendment
STTx trans (ttAMENDMENT);
trans.setFieldAccount (sfAccount, Account ());
trans.setFieldH256 (sfAmendment, uAmendment);
uint256 txID = trans.getTransactionID ();
if (m_journal.warning) m_journal.warning <<
"Vote ID: " << txID;
// Inject the transaction into our initial proposal
Serializer s;
trans.add (s, true);
#if RIPPLE_PROPOSE_AMENDMENTS
SHAMapItem::pointer tItem = std::make_shared<SHAMapItem> (txID, s.peekData ());
if (!initialPosition->addGiveItem (tItem, true, false))
{
if (m_journal.warning) m_journal.warning <<
"Ledger already had amendment transaction";
}
#endif
}
}
示例4: setup
void OrderBookDB::setup (Ledger::ref ledger)
{
{
ScopedLockType sl (mLock, __FILE__, __LINE__);
// Do a full update every 256 ledgers
if (mSeq != 0)
{
if (ledger->getLedgerSeq () == mSeq)
return;
if ((ledger->getLedgerSeq () > mSeq) && ((ledger->getLedgerSeq () - mSeq) < 256))
return;
if ((ledger->getLedgerSeq () < mSeq) && ((mSeq - ledger->getLedgerSeq ()) < 16))
return;
}
WriteLog (lsDEBUG, OrderBookDB) << "Advancing from " << mSeq << " to " << ledger->getLedgerSeq();
mSeq = ledger->getLedgerSeq ();
}
if (getConfig().RUN_STANDALONE)
update(ledger);
else
getApp().getJobQueue().addJob(jtUPDATE_PF, "OrderBookDB::update",
BIND_TYPE(&OrderBookDB::update, this, ledger));
}
示例5: sit
AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
{
SHAMap& txSet = *ledger->peekTransactionMap ();
for (SHAMapItem::pointer item = txSet.peekFirstItem (); !!item; item = txSet.peekNextItem (item->getTag ()))
{
SerializerIterator sit (item->peekSerializer ());
insert (boost::make_shared<AcceptedLedgerTx> (ledger->getLedgerSeq (), boost::ref (sit)));
}
}
示例6: txnIt
AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, SerialIter& sit)
: mLedger (ledger)
{
// VFALCO This is making a needless copy
auto const vl = sit.getVL();
SerialIter txnIt (make_Slice(vl));
mTxn = std::make_shared<STTx> (std::ref (txnIt));
mRawMeta = sit.getVL ();
mMeta = std::make_shared<TransactionMetaSet> (mTxn->getTransactionID (),
ledger->getLedgerSeq (), mRawMeta);
mAffected = mMeta->getAffectedAccounts ();
mResult = mMeta->getResultTER ();
buildJson ();
}
示例7: switchLedgers
void LedgerMaster::switchLedgers(Ledger::ref lastClosed, Ledger::ref current)
{
assert(lastClosed && current);
{
boost::recursive_mutex::scoped_lock ml(mLock);
mFinalizedLedger = lastClosed;
mFinalizedLedger->setClosed();
mFinalizedLedger->setAccepted();
mCurrentLedger = current;
}
assert(!mCurrentLedger->isClosed());
mEngine.setLedger(mCurrentLedger);
checkAccept(lastClosed->getHash(), lastClosed->getLedgerSeq());
}
示例8: pushLedger
void LedgerMaster::pushLedger(Ledger::ref newLCL, Ledger::ref newOL, bool fromConsensus)
{
assert(newLCL->isClosed() && newLCL->isAccepted());
assert(!newOL->isClosed() && !newOL->isAccepted());
if (newLCL->isAccepted())
{
assert(newLCL->isClosed());
assert(newLCL->isImmutable());
mLedgerHistory.addAcceptedLedger(newLCL, fromConsensus);
cLog(lsINFO) << "StashAccepted: " << newLCL->getHash();
}
{
boost::recursive_mutex::scoped_lock ml(mLock);
mFinalizedLedger = newLCL;
mCurrentLedger = newOL;
mEngine.setLedger(newOL);
}
checkAccept(newLCL->getHash(), newLCL->getLedgerSeq());
}
示例9: validatedLedger
void LedgerHistory::validatedLedger (Ledger::ref ledger)
{
LedgerIndex index = ledger->getLedgerSeq();
LedgerHash hash = ledger->getHash();
assert (!hash.isZero());
TaggedCache::ScopedLockType sl(mConsensusValidated.peekMutex(), __FILE__, __LINE__);
boost::shared_ptr< std::pair< LedgerHash, LedgerHash > > entry = boost::make_shared<std::pair< LedgerHash, LedgerHash >>();
mConsensusValidated.canonicalize(index, entry, false);
if (entry->second != hash)
{
if (entry->second.isNonZero() && (entry->second != hash))
{
WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index << " validated:" << entry->second << " then:" << hash;
}
if (entry->first.isNonZero() && (entry->first != hash))
{
WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index << " built:" << entry->first << " validated:" << hash;
}
entry->second = hash;
}
}
示例10: trans
void
FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger,
std::shared_ptr<SHAMap> const& initialPosition)
{
// LCL must be flag ledger
assert ((lastClosedLedger->getLedgerSeq () % 256) == 0);
detail::VotableInteger<std::uint64_t> baseFeeVote (
lastClosedLedger->getBaseFee (), target_.reference_fee);
detail::VotableInteger<std::uint32_t> baseReserveVote (
lastClosedLedger->getReserve (0), target_.account_reserve);
detail::VotableInteger<std::uint32_t> incReserveVote (
lastClosedLedger->getReserveInc (), target_.owner_reserve);
// get validations for ledger before flag
ValidationSet const set =
getApp().getValidations ().getValidations (
lastClosedLedger->getParentHash ());
for (auto const& e : set)
{
STValidation const& val = *e.second;
if (val.isTrusted ())
{
if (val.isFieldPresent (sfBaseFee))
{
baseFeeVote.addVote (val.getFieldU64 (sfBaseFee));
}
else
{
baseFeeVote.noVote ();
}
if (val.isFieldPresent (sfReserveBase))
{
baseReserveVote.addVote (val.getFieldU32 (sfReserveBase));
}
else
{
baseReserveVote.noVote ();
}
if (val.isFieldPresent (sfReserveIncrement))
{
incReserveVote.addVote (val.getFieldU32 (sfReserveIncrement));
}
else
{
incReserveVote.noVote ();
}
}
}
// choose our positions
std::uint64_t const baseFee = baseFeeVote.getVotes ();
std::uint32_t const baseReserve = baseReserveVote.getVotes ();
std::uint32_t const incReserve = incReserveVote.getVotes ();
// add transactions to our position
if ((baseFee != lastClosedLedger->getBaseFee ()) ||
(baseReserve != lastClosedLedger->getReserve (0)) ||
(incReserve != lastClosedLedger->getReserveInc ()))
{
if (journal_.warning) journal_.warning <<
"We are voting for a fee change: " << baseFee <<
"/" << baseReserve <<
"/" << incReserve;
STTx trans (ttFEE);
trans.setFieldAccount (sfAccount, AccountID ());
trans.setFieldU64 (sfBaseFee, baseFee);
trans.setFieldU32 (sfReferenceFeeUnits, 10);
trans.setFieldU32 (sfReserveBase, baseReserve);
trans.setFieldU32 (sfReserveIncrement, incReserve);
uint256 txID = trans.getTransactionID ();
if (journal_.warning)
journal_.warning << "Vote: " << txID;
Serializer s;
trans.add (s);
auto tItem = std::make_shared<SHAMapItem> (txID, s.peekData ());
if (!initialPosition->addGiveItem (tItem, true, false))
{
if (journal_.warning) journal_.warning <<
"Ledger already had fee change";
}
}
}