Move fields from Ledger to LedgerInfo.

This commit is contained in:
Tom Ritchford
2015-07-08 12:12:48 -04:00
committed by Vinnie Falco
parent 1b6c707abb
commit c7ebe7205c
33 changed files with 548 additions and 593 deletions

View File

@@ -65,10 +65,6 @@ public:
return mMap;
}
int getLedgerSeq () const
{
return mLedger->getLedgerSeq ();
}
int getTxnCount () const
{
return mMap.size ();

View File

@@ -36,7 +36,7 @@ AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, SerialIter& sit)
mTxn = std::make_shared<STTx> (std::ref (txnIt));
mRawMeta = sit.getVL ();
mMeta = std::make_shared<TxMeta> (mTxn->getTransactionID (),
ledger->getLedgerSeq (), mRawMeta);
ledger->info().seq, mRawMeta);
mAffected = mMeta->getAffectedAccounts ();
mResult = mMeta->getResultTER ();
buildJson ();

View File

@@ -137,10 +137,7 @@ makeGenesisAccount (AccountID const& id,
//
Ledger::Ledger (AccountID const& masterAccountID,
std::uint64_t balanceInDrops)
: mTotCoins (balanceInDrops)
, mCloseResolution (ledgerDefaultTimeResolution)
, mCloseFlags (0)
, mImmutable (false)
: mImmutable (false)
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
getApp().family(), deprecatedLogs().journal("SHAMap")))
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE,
@@ -150,6 +147,8 @@ Ledger::Ledger (AccountID const& masterAccountID,
{
// first ledger
info_.seq = 1;
info_.drops = balanceInDrops;
info_.closeTimeResolution = ledgerDefaultTimeResolution;
auto const sle = makeGenesisAccount(
masterAccountID, balanceInDrops);
WriteLog (lsTRACE, Ledger)
@@ -161,20 +160,14 @@ Ledger::Ledger (AccountID const& masterAccountID,
Ledger::Ledger (uint256 const& parentHash,
uint256 const& transHash,
uint256 const& accountHash,
std::uint64_t totCoins,
std::uint64_t totDrops,
std::uint32_t closeTime,
std::uint32_t parentCloseTime,
int closeFlags,
int closeResolution,
std::uint32_t ledgerSeq,
bool& loaded)
: mParentHash (parentHash)
, mTransHash (transHash)
, mAccountHash (accountHash)
, mTotCoins (totCoins)
, mCloseResolution (closeResolution)
, mCloseFlags (closeFlags)
, mImmutable (true)
: mImmutable (true)
, txMap_ (std::make_shared <SHAMap> (
SHAMapType::TRANSACTION, transHash, getApp().family(),
deprecatedLogs().journal("SHAMap")))
@@ -186,19 +179,23 @@ Ledger::Ledger (uint256 const& parentHash,
info_.seq = ledgerSeq;
info_.parentCloseTime = parentCloseTime;
info_.closeTime = closeTime;
updateHash ();
info_.drops = totDrops;
info_.txHash = transHash;
info_.accountHash = accountHash;
info_.parentHash = parentHash;
info_.closeTimeResolution = closeResolution;
info_.closeFlags = closeFlags;
loaded = true;
if (mTransHash.isNonZero () &&
!txMap_->fetchRoot (mTransHash, nullptr))
if (info_.txHash.isNonZero () &&
!txMap_->fetchRoot (info_.txHash, nullptr))
{
loaded = false;
WriteLog (lsWARNING, Ledger) << "Don't have TX root for ledger";
}
if (mAccountHash.isNonZero () &&
!stateMap_->fetchRoot (mAccountHash, nullptr))
if (info_.accountHash.isNonZero () &&
!stateMap_->fetchRoot (info_.accountHash, nullptr))
{
loaded = false;
WriteLog (lsWARNING, Ledger) << "Don't have AS root for ledger";
@@ -211,13 +208,7 @@ Ledger::Ledger (uint256 const& parentHash,
// Create a new ledger that's a snapshot of this one
Ledger::Ledger (Ledger const& ledger,
bool isMutable)
: mParentHash (ledger.mParentHash)
, mTotCoins (ledger.mTotCoins)
, mCloseResolution (ledger.mCloseResolution)
, mCloseFlags (ledger.mCloseFlags)
, mValidated (ledger.mValidated)
, mAccepted (ledger.mAccepted)
, mImmutable (!isMutable)
: mImmutable (!isMutable)
, txMap_ (ledger.txMap_->snapShot (isMutable))
, stateMap_ (ledger.stateMap_->snapShot (isMutable))
// VFALCO Needs audit
@@ -230,10 +221,7 @@ Ledger::Ledger (Ledger const& ledger,
// Create a new open ledger that follows this one
Ledger::Ledger (bool /* dummy */,
Ledger& prevLedger)
: mTotCoins (prevLedger.mTotCoins)
, mCloseResolution (prevLedger.mCloseResolution)
, mCloseFlags (0)
, mImmutable (false)
: mImmutable (false)
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
getApp().family(), deprecatedLogs().journal("SHAMap")))
, stateMap_ (prevLedger.stateMap_->snapShot (true))
@@ -245,31 +233,42 @@ Ledger::Ledger (bool /* dummy */,
info_.parentCloseTime =
prevLedger.info_.closeTime;
info_.hash = prevLedger.info().hash + uint256(1);
info_.drops = prevLedger.info().drops;
info_.closeTimeResolution = prevLedger.info_.closeTimeResolution;
prevLedger.updateHash ();
// VFALCO TODO Require callers to update the hash
mParentHash = prevLedger.getHash ();
info_.parentHash = prevLedger.getHash ();
assert (mParentHash.isNonZero ());
assert (info_.parentHash.isNonZero ());
mCloseResolution = getNextLedgerTimeResolution (prevLedger.mCloseResolution,
prevLedger.getCloseAgree (), info_.seq);
info_.closeTimeResolution = getNextLedgerTimeResolution (
prevLedger.info_.closeTimeResolution,
getCloseAgree(prevLedger.info()), info_.seq);
if (prevLedger.info_.closeTime == 0)
{
info_.closeTime = roundCloseTime (
getApp().getOPs ().getCloseTimeNC (), mCloseResolution);
getApp().getOPs ().getCloseTimeNC (), info_.closeTimeResolution);
}
else
{
info_.closeTime =
prevLedger.info_.closeTime + mCloseResolution;
prevLedger.info_.closeTime + info_.closeTimeResolution;
}
}
Ledger::Ledger (void const* data,
std::size_t size, bool hasPrefix)
: mImmutable (true)
, txMap_ (std::make_shared <SHAMap> (
SHAMapType::TRANSACTION, getApp().family(),
deprecatedLogs().journal("SHAMap")))
, stateMap_ (std::make_shared <SHAMap> (
SHAMapType::STATE, getApp().family(),
deprecatedLogs().journal("SHAMap")))
{
SerialIter sit (data, size);
setRaw (sit, hasPrefix);
@@ -277,10 +276,7 @@ Ledger::Ledger (void const* data,
}
Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
: mTotCoins (0)
, mCloseResolution (ledgerDefaultTimeResolution)
, mCloseFlags (0)
, mImmutable (false)
: mImmutable (false)
, txMap_ (std::make_shared <SHAMap> (
SHAMapType::TRANSACTION, getApp().family(),
deprecatedLogs().journal("SHAMap")))
@@ -291,8 +287,8 @@ Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
, fees_(getFees(*this, getConfig()))
{
info_.seq = ledgerSeq;
info_.parentCloseTime = 0;
info_.closeTime = closeTime;
info_.closeTimeResolution = ledgerDefaultTimeResolution;
}
//------------------------------------------------------------------------------
@@ -319,28 +315,28 @@ void Ledger::updateHash()
if (! mImmutable)
{
if (txMap_)
mTransHash = txMap_->getHash ();
info_.txHash = txMap_->getHash ();
else
mTransHash.zero ();
info_.txHash.zero ();
if (stateMap_)
mAccountHash = stateMap_->getHash ();
info_.accountHash = stateMap_->getHash ();
else
mAccountHash.zero ();
info_.accountHash.zero ();
}
// VFALCO This has to match addRaw
// VFALCO This has to match addRaw in View.h.
info_.hash = sha512Half(
HashPrefix::ledgerMaster,
std::uint32_t(info_.seq),
std::uint64_t(mTotCoins),
mParentHash,
mTransHash,
mAccountHash,
std::uint64_t(info_.drops),
info_.parentHash,
info_.txHash,
info_.accountHash,
std::uint32_t(info_.parentCloseTime),
std::uint32_t(info_.closeTime),
std::uint8_t(mCloseResolution),
std::uint8_t(mCloseFlags));
std::uint8_t(info_.closeTimeResolution),
std::uint8_t(info_.closeFlags));
mValidHash = true;
}
@@ -349,33 +345,25 @@ void Ledger::setRaw (SerialIter& sit, bool hasPrefix)
if (hasPrefix)
sit.get32 ();
info_.seq = sit.get32 ();
mTotCoins = sit.get64 ();
mParentHash = sit.get256 ();
mTransHash = sit.get256 ();
mAccountHash = sit.get256 ();
info_.parentCloseTime = sit.get32 ();
info_.closeTime = sit.get32 ();
mCloseResolution = sit.get8 ();
mCloseFlags = sit.get8 ();
info_.seq = sit.get32 ();
info_.drops = sit.get64 ();
info_.parentHash = sit.get256 ();
info_.txHash = sit.get256 ();
info_.accountHash = sit.get256 ();
info_.parentCloseTime = sit.get32 ();
info_.closeTime = sit.get32 ();
info_.closeTimeResolution = sit.get8 ();
info_.closeFlags = sit.get8 ();
updateHash ();
txMap_ = std::make_shared<SHAMap> (SHAMapType::TRANSACTION, mTransHash,
txMap_ = std::make_shared<SHAMap> (SHAMapType::TRANSACTION, info_.txHash,
getApp().family(), deprecatedLogs().journal("SHAMap"));
stateMap_ = std::make_shared<SHAMap> (SHAMapType::STATE, mAccountHash,
stateMap_ = std::make_shared<SHAMap> (SHAMapType::STATE, info_.accountHash,
getApp().family(), deprecatedLogs().journal("SHAMap"));
}
void Ledger::addRaw (Serializer& s) const
{
s.add32 (info_.seq);
s.add64 (mTotCoins);
s.add256 (mParentHash);
s.add256 (mTransHash);
s.add256 (mAccountHash);
s.add32 (info_.parentCloseTime);
s.add32 (info_.closeTime);
s.add8 (mCloseResolution);
s.add8 (mCloseFlags);
ripple::addRaw(info_, s);
}
void Ledger::setAccepted (
@@ -383,13 +371,13 @@ void Ledger::setAccepted (
{
// Used when we witnessed the consensus. Rounds the close time, updates the
// hash, and sets the ledger accepted and immutable.
assert (closed() && !mAccepted);
assert (closed() && !info_.accepted);
info_.closeTime = correctCloseTime
? roundCloseTime (closeTime, closeResolution)
: closeTime;
mCloseResolution = closeResolution;
mCloseFlags = correctCloseTime ? 0 : sLCF_NoConsensusTime;
mAccepted = true;
info_.closeTimeResolution = closeResolution;
info_.closeFlags = correctCloseTime ? 0 : sLCF_NoConsensusTime;
info_.accepted = true;
setImmutable ();
}
@@ -397,12 +385,12 @@ void Ledger::setAccepted ()
{
// used when we acquired the ledger
// TODO: re-enable a test like the following:
// assert(closed() && (info_.closeTime != 0) && (mCloseResolution != 0));
if ((mCloseFlags & sLCF_NoConsensusTime) == 0)
// assert(closed() && (info_.closeTime != 0) && (info_.closeTimeResolution != 0));
if ((info_.closeFlags & sLCF_NoConsensusTime) == 0)
info_.closeTime = roundCloseTime(
info_.closeTime, mCloseResolution);
info_.closeTime, info_.closeTimeResolution);
mAccepted = true;
info_.accepted = true;
setImmutable ();
}
@@ -446,7 +434,7 @@ getTransaction (Ledger const& ledger,
if (txn->getStatus () == NEW)
{
txn->setStatus (
ledger.isClosed() ? COMMITTED : INCLUDED, ledger.getLedgerSeq());
ledger.info().open ? INCLUDED : COMMITTED, ledger.info().seq);
}
cache.canonicalize (&txn);
@@ -495,7 +483,7 @@ getTransaction (Ledger const& ledger,
return false;
if (txn->getStatus () == NEW)
txn->setStatus (ledger.isClosed() ? COMMITTED : INCLUDED, ledger.seq());
txn->setStatus (ledger.info().open ? INCLUDED : COMMITTED, ledger.seq());
cache.canonicalize (&txn);
return true;
@@ -534,7 +522,7 @@ bool Ledger::saveValidatedLedger (bool current)
// TODO(tom): Fix this hard-coded SQL!
WriteLog (lsTRACE, Ledger)
<< "saveValidatedLedger "
<< (current ? "" : "fromAcquire ") << getLedgerSeq ();
<< (current ? "" : "fromAcquire ") << info().seq;
static boost::format deleteLedger (
"DELETE FROM Ledgers WHERE LedgerSeq = %u;");
static boost::format deleteTrans1 (
@@ -554,23 +542,23 @@ bool Ledger::saveValidatedLedger (bool current)
"CloseTimeRes,CloseFlags,AccountSetHash,TransSetHash) VALUES "
"('%s','%u','%s','%s','%u','%u','%d','%u','%s','%s');");
if (!getAccountHash ().isNonZero ())
if (!info().accountHash.isNonZero ())
{
WriteLog (lsFATAL, Ledger) << "AH is zero: "
<< getJson (*this);
assert (false);
}
if (getAccountHash () != stateMap_->getHash ())
if (info().accountHash != stateMap_->getHash ())
{
WriteLog (lsFATAL, Ledger) << "sAL: " << getAccountHash ()
WriteLog (lsFATAL, Ledger) << "sAL: " << info().accountHash
<< " != " << stateMap_->getHash ();
WriteLog (lsFATAL, Ledger) << "saveAcceptedLedger: seq="
<< info_.seq << ", current=" << current;
assert (false);
}
assert (getTransHash () == txMap_->getHash ());
assert (info().txHash == txMap_->getHash ());
// Save the ledger header in the hashed object store
{
@@ -592,7 +580,7 @@ bool Ledger::saveValidatedLedger (bool current)
getApp().getLedgerMaster().failedSave(info_.seq, info_.hash);
// Clients can now trust the database for information about this
// ledger sequence.
getApp().pendingSaves().erase(getLedgerSeq());
getApp().pendingSaves().erase(info().seq);
return false;
}
@@ -606,17 +594,17 @@ bool Ledger::saveValidatedLedger (bool current)
soci::transaction tr(*db);
*db << boost::str (deleteTrans1 % getLedgerSeq ());
*db << boost::str (deleteTrans2 % getLedgerSeq ());
*db << boost::str (deleteTrans1 % info().seq);
*db << boost::str (deleteTrans2 % info().seq);
std::string const ledgerSeq (std::to_string (getLedgerSeq ()));
std::string const ledgerSeq (std::to_string (info().seq));
for (auto const& vt : aLedger->getMap ())
{
uint256 transactionID = vt.second->getTransactionID ();
getApp().getMasterTransaction ().inLedger (
transactionID, getLedgerSeq ());
transactionID, info().seq);
std::string const txnId (to_string (transactionID));
std::string const txnSeq (std::to_string (vt.second->getTxnSeq ()));
@@ -671,7 +659,7 @@ bool Ledger::saveValidatedLedger (bool current)
*db <<
(STTx::getMetaSQLInsertReplaceHeader () +
vt.second->getTxn ()->getMetaSQL (
getLedgerSeq (), vt.second->getEscMeta ()) + ";");
info().seq, vt.second->getEscMeta ()) + ";");
}
tr.commit ();
@@ -683,15 +671,16 @@ bool Ledger::saveValidatedLedger (bool current)
// TODO(tom): ARG!
*db << boost::str (
addLedger %
to_string (getHash ()) % info_.seq % to_string (mParentHash) %
beast::lexicalCastThrow <std::string> (mTotCoins) % info_.closeTime %
info_.parentCloseTime % mCloseResolution % mCloseFlags %
to_string (mAccountHash) % to_string (mTransHash));
to_string (getHash ()) % info_.seq % to_string (info_.parentHash) %
std::to_string (info_.drops) % info_.closeTime %
info_.parentCloseTime % info_.closeTimeResolution %
info_.closeFlags % to_string (info_.accountHash) %
to_string (info_.txHash));
}
// Clients can now trust the database for
// information about this ledger sequence.
getApp().pendingSaves().erase(getLedgerSeq());
getApp().pendingSaves().erase(info().seq);
return true;
}
@@ -746,7 +735,7 @@ loadLedgerHelper(std::string const& sqlSuffix)
boost::optional<std::string> sLedgerHash, sPrevHash, sAccountHash,
sTransHash;
boost::optional<std::uint64_t> totCoins, closingTime, prevClosingTime,
boost::optional<std::uint64_t> totDrops, closingTime, prevClosingTime,
closeResolution, closeFlags, ledgerSeq64;
std::string const sql =
@@ -762,7 +751,7 @@ loadLedgerHelper(std::string const& sqlSuffix)
soci::into(sPrevHash),
soci::into(sAccountHash),
soci::into(sTransHash),
soci::into(totCoins),
soci::into(totDrops),
soci::into(closingTime),
soci::into(prevClosingTime),
soci::into(closeResolution),
@@ -788,7 +777,7 @@ loadLedgerHelper(std::string const& sqlSuffix)
ledger = std::make_shared<Ledger>(prevHash,
transHash,
accountHash,
totCoins.value_or(0),
totDrops.value_or(0),
closingTime.value_or(0),
prevClosingTime.value_or(0),
closeFlags.value_or(0),
@@ -810,7 +799,7 @@ void finishLoadByIndexOrHash(Ledger::pointer& ledger)
ledger->setClosed ();
ledger->setImmutable ();
if (getApp ().getLedgerMaster ().haveLedger (ledger->getLedgerSeq ()))
if (getApp ().getLedgerMaster ().haveLedger ((ledger->info().seq)))
ledger->setAccepted ();
WriteLog (lsTRACE, Ledger)
@@ -1220,10 +1209,10 @@ bool Ledger::walkLedger () const
std::vector <SHAMapMissingNode> missingNodes2;
if (stateMap_->getHash().isZero() &&
! mAccountHash.isZero() &&
! stateMap_->fetchRoot (mAccountHash, nullptr))
! info_.accountHash.isZero() &&
! stateMap_->fetchRoot (info_.accountHash, nullptr))
{
missingNodes1.emplace_back (SHAMapType::STATE, mAccountHash);
missingNodes1.emplace_back (SHAMapType::STATE, info_.accountHash);
}
else
{
@@ -1239,10 +1228,10 @@ bool Ledger::walkLedger () const
}
if (txMap_->getHash().isZero() &&
mTransHash.isNonZero() &&
! txMap_->fetchRoot (mTransHash, nullptr))
info_.txHash.isNonZero() &&
! txMap_->fetchRoot (info_.txHash, nullptr))
{
missingNodes2.emplace_back (SHAMapType::TRANSACTION, mTransHash);
missingNodes2.emplace_back (SHAMapType::TRANSACTION, info_.txHash);
}
else
{
@@ -1263,19 +1252,19 @@ bool Ledger::walkLedger () const
bool Ledger::assertSane ()
{
if (info_.hash.isNonZero () &&
mAccountHash.isNonZero () &&
info_.accountHash.isNonZero () &&
stateMap_ &&
txMap_ &&
(mAccountHash == stateMap_->getHash ()) &&
(mTransHash == txMap_->getHash ()))
(info_.accountHash == stateMap_->getHash ()) &&
(info_.txHash == txMap_->getHash ()))
{
return true;
}
Json::Value j = getJson (*this);
j [jss::accountTreeHash] = to_string (mAccountHash);
j [jss::transTreeHash] = to_string (mTransHash);
j [jss::accountTreeHash] = to_string (info_.accountHash);
j [jss::transTreeHash] = to_string (info_.txHash);
WriteLog (lsFATAL, Ledger) << "ledger is not sane" << j;
@@ -1314,7 +1303,7 @@ void Ledger::updateSkipList ()
}
assert (hashes.size () <= 256);
hashes.push_back (mParentHash);
hashes.push_back (info_.parentHash);
sle->setFieldV256 (sfHashes, STVector256 (hashes));
sle->setFieldU32 (sfLastLedgerSequence, prevIndex);
if (created)
@@ -1342,7 +1331,7 @@ void Ledger::updateSkipList ()
assert (hashes.size () <= 256);
if (hashes.size () == 256)
hashes.erase (hashes.begin ());
hashes.push_back (mParentHash);
hashes.push_back (info_.parentHash);
sle->setFieldV256 (sfHashes, STVector256 (hashes));
sle->setFieldU32 (sfLastLedgerSequence, prevIndex);
if (created)
@@ -1358,16 +1347,16 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent)
{
if (!getApp().getHashRouter ().setFlag (getHash (), SF_SAVED))
{
WriteLog (lsDEBUG, Ledger) << "Double pend save for " << getLedgerSeq();
WriteLog (lsDEBUG, Ledger) << "Double pend save for " << info().seq;
return true;
}
assert (isImmutable ());
if (!getApp().pendingSaves().insert(getLedgerSeq()))
if (!getApp().pendingSaves().insert(info().seq))
{
WriteLog (lsDEBUG, Ledger)
<< "Pend save with seq in pending saves " << getLedgerSeq();
<< "Pend save with seq in pending saves " << info().seq;
return true;
}
@@ -1463,10 +1452,10 @@ std::vector<uint256> Ledger::getNeededTransactionHashes (
{
std::vector<uint256> ret;
if (mTransHash.isNonZero ())
if (info_.txHash.isNonZero ())
{
if (txMap_->getHash ().isZero ())
ret.push_back (mTransHash);
ret.push_back (info_.txHash);
else
ret = txMap_->getNeededHashes (max, filter);
}
@@ -1479,10 +1468,10 @@ std::vector<uint256> Ledger::getNeededAccountStateHashes (
{
std::vector<uint256> ret;
if (mAccountHash.isNonZero ())
if (info_.accountHash.isNonZero ())
{
if (stateMap_->getHash ().isZero ())
ret.push_back (mAccountHash);
ret.push_back (info_.accountHash);
else
ret = stateMap_->getNeededHashes (max, filter);
}
@@ -1511,7 +1500,7 @@ hashOfSeq (Ledger& ledger, LedgerIndex seq,
if (seq == ledger.seq())
return ledger.getHash();
if (seq == (ledger.seq() - 1))
return ledger.getParentHash();
return ledger.info().parentHash;
// Within 256...
{

View File

@@ -174,7 +174,7 @@ public:
void
rawDestroyXRP (std::uint64_t feeDrops) override
{
mTotCoins -= feeDrops;
info_.drops -= feeDrops;
}
//
@@ -208,7 +208,7 @@ public:
void setValidated()
{
mValidated = true;
info_.validated = true;
}
void setAccepted (std::uint32_t closeTime,
@@ -218,27 +218,11 @@ public:
void setImmutable ();
// DEPRECATED use closed()
bool isClosed () const
{
return closed();
}
bool isAccepted () const
{
return mAccepted;
}
bool isValidated () const
{
return mValidated;
}
bool isImmutable () const
{
return mImmutable;
}
// Indicates that all ledger entries
// are available locally. For example,
// all in the NodeStore and memory.
@@ -258,57 +242,9 @@ public:
uint256 const&
getHash();
uint256 const& getParentHash () const
void setTotalCoins (std::uint64_t totDrops)
{
return mParentHash;
}
uint256 const& getTransHash () const
{
return mTransHash;
}
uint256 const& getAccountHash () const
{
return mAccountHash;
}
std::uint64_t getTotalCoins () const
{
return mTotCoins;
}
void setTotalCoins (std::uint64_t totCoins)
{
mTotCoins = totCoins;
}
// DEPRECATED
std::uint32_t getCloseTimeNC () const
{
return info_.closeTime;
}
// DEPRECATED Use parentCloseTime()
std::uint32_t getParentCloseTimeNC () const
{
return info_.parentCloseTime;
}
// DEPRECATED Use seq()
std::uint32_t getLedgerSeq () const
{
return info_.seq;
}
int getCloseResolution () const
{
return mCloseResolution;
}
bool getCloseAgree () const
{
return (mCloseFlags & sLCF_NoConsensusTime) == 0;
info_.drops = totDrops;
}
// close time functions
@@ -322,21 +258,6 @@ public:
boost::posix_time::ptime getCloseTime () const;
// VFALCO NOTE We should ensure that there are
// always valid state and tx maps
// and get rid of these functions.
bool
haveStateMap() const
{
return stateMap_ != nullptr;
}
bool
haveTxMap() const
{
return txMap_ != nullptr;
}
SHAMap const&
stateMap() const
{
@@ -444,9 +365,6 @@ private:
}
bool saveValidatedLedger (bool current);
// ledger close flags
static const std::uint32_t sLCF_NoConsensusTime = 1;
std::shared_ptr<SLE>
peek (Keylet const& k) const;
@@ -461,19 +379,8 @@ private:
void deprecatedUpdateCachedFees() const;
// The basic Ledger structure, can be opened, closed, or synching
uint256 mParentHash;
uint256 mTransHash;
uint256 mAccountHash;
std::uint64_t mTotCoins;
// the resolution for this ledger close time (2-120 seconds)
int mCloseResolution;
// flags indicating how this ledger close took place
std::uint32_t mCloseFlags;
bool mValidated = false;
bool mValidHash = false;
bool mAccepted = false;
bool mImmutable;
std::shared_ptr<SHAMap> txMap_;

View File

@@ -58,7 +58,7 @@ bool LedgerHistory::addLedger (Ledger::pointer ledger, bool validated)
const bool alreadyHad = m_ledgers_by_hash.canonicalize (ledger->getHash(), ledger, true);
if (validated)
mLedgersByIndex[ledger->getLedgerSeq()] = ledger->getHash();
mLedgersByIndex[ledger->info().seq] = ledger->getHash();
return alreadyHad;
}
@@ -93,7 +93,7 @@ Ledger::pointer LedgerHistory::getLedgerBySeq (LedgerIndex index)
if (!ret)
return ret;
assert (ret->getLedgerSeq () == index);
assert (ret->info().seq == index);
{
// Add this ledger to the local tracking by index
@@ -101,8 +101,8 @@ Ledger::pointer LedgerHistory::getLedgerBySeq (LedgerIndex index)
assert (ret->isImmutable ());
m_ledgers_by_hash.canonicalize (ret->getHash (), ret);
mLedgersByIndex[ret->getLedgerSeq ()] = ret->getHash ();
return (ret->getLedgerSeq () == index) ? ret : Ledger::pointer ();
mLedgersByIndex[ret->info().seq] = ret->getHash ();
return (ret->info().seq == index) ? ret : Ledger::pointer ();
}
}
@@ -304,19 +304,19 @@ void LedgerHistory::handleMismatch (LedgerHash const& built, LedgerHash const& v
return;
}
assert (builtLedger->getLedgerSeq() == validLedger->getLedgerSeq());
assert (builtLedger->info().seq == validLedger->info().seq);
// Determine the mismatch reason
// Distinguish Byzantine failure from transaction processing difference
if (builtLedger->getParentHash() != validLedger->getParentHash())
if (builtLedger->info().parentHash != validLedger->info().parentHash)
{
// Disagreement over prior ledger indicates sync issue
WriteLog (lsERROR, LedgerMaster) << "MISMATCH on prior ledger";
return;
}
if (builtLedger->getCloseTimeNC() != validLedger->getCloseTimeNC())
if (builtLedger->info().closeTime != validLedger->info().closeTime)
{
// Disagreement over close time indicates Byzantine failure
WriteLog (lsERROR, LedgerMaster) << "MISMATCH on close time";
@@ -373,7 +373,7 @@ void LedgerHistory::handleMismatch (LedgerHash const& built, LedgerHash const& v
void LedgerHistory::builtLedger (Ledger::ref ledger)
{
LedgerIndex index = ledger->getLedgerSeq();
LedgerIndex index = ledger->info().seq;
LedgerHash hash = ledger->getHash();
assert (!hash.isZero());
ConsensusValidated::ScopedLockType sl (
@@ -397,7 +397,7 @@ void LedgerHistory::builtLedger (Ledger::ref ledger)
void LedgerHistory::validatedLedger (Ledger::ref ledger)
{
LedgerIndex index = ledger->getLedgerSeq();
LedgerIndex index = ledger->info().seq;
LedgerHash hash = ledger->getHash();
assert (!hash.isZero());
ConsensusValidated::ScopedLockType sl (
@@ -445,7 +445,7 @@ void LedgerHistory::clearLedgerCachePrior (LedgerIndex seq)
{
for (LedgerHash it: m_ledgers_by_hash.getKeys())
{
if (getLedgerByHash (it)->getLedgerSeq() < seq)
if (getLedgerByHash (it)->info().seq < seq)
m_ledgers_by_hash.del (it, false);
}
}

View File

@@ -33,7 +33,7 @@ namespace ripple {
struct LedgerFill
{
LedgerFill (Ledger& l,
LedgerFill (ReadView const& l,
int o = 0,
RPC::Callback const& y = {},
RPC::YieldStrategy const& ys = {})
@@ -47,18 +47,37 @@ struct LedgerFill
enum Options {
dumpTxrp = 1, dumpState = 2, expand = 4, full = 8, binary = 16};
Ledger& ledger;
ReadView const& ledger;
int options;
RPC::Callback yield;
RPC::YieldStrategy yieldStrategy;
};
/** Add Json to an existing generic Object. */
void addJson(Json::Object&, LedgerFill const&);
/** Given a Ledger and options, fill a Json::Object or Json::Value with a
description of the ledger.
*/
void addJson(Json::Value&, LedgerFill const&);
void addJson(Json::Object&, LedgerFill const&);
Json::Value getJson(LedgerFill const&);
/** Return a new Json::Value representing the ledger with given options.*/
Json::Value getJson (LedgerFill const&);
/** Serialize an object to a blob. */
template <class Object>
Blob serializeBlob(Object const& o)
{
Serializer s;
o.add(s);
return s.peekData();
}
/** Serialize an object to a hex string. */
template <class Object>
std::string serializeHex(Object const& o)
{
return strHex(serializeBlob(o));
}
} // ripple
#endif

View File

@@ -44,7 +44,7 @@ void OrderBookDB::setup (Ledger::ref ledger)
{
{
ScopedLockType sl (mLock);
auto seq = ledger->getLedgerSeq ();
auto seq = ledger->info().seq;
// Do a full update every 256 ledgers
if (mSeq != 0)

View File

@@ -186,7 +186,7 @@ bool InboundLedger::tryLocal ()
if (!mHaveTransactions)
{
if (mLedger->getTransHash ().isZero ())
if (mLedger->info().txHash.isZero ())
{
if (m_journal.trace) m_journal.trace <<
"No TXNs to fetch";
@@ -197,7 +197,7 @@ bool InboundLedger::tryLocal ()
TransactionStateSF filter;
if (mLedger->txMap().fetchRoot (
mLedger->getTransHash (), &filter))
mLedger->info().txHash, &filter))
{
auto h (mLedger->getNeededTransactionHashes (1, &filter));
@@ -213,7 +213,7 @@ bool InboundLedger::tryLocal ()
if (!mHaveState)
{
if (mLedger->getAccountHash ().isZero ())
if (mLedger->info().accountHash.isZero ())
{
if (m_journal.fatal) m_journal.fatal <<
"We are acquiring a ledger with a zero account hash";
@@ -225,7 +225,7 @@ bool InboundLedger::tryLocal ()
AccountStateSF filter;
if (mLedger->stateMap().fetchRoot (
mLedger->getAccountHash (), &filter))
mLedger->info().accountHash, &filter))
{
auto h (mLedger->getNeededAccountStateHashes (1, &filter));
@@ -506,7 +506,7 @@ void InboundLedger::trigger (Peer::ptr const& peer)
}
if (mLedger)
tmGL.set_ledgerseq (mLedger->getLedgerSeq ());
tmGL.set_ledgerseq (mLedger->info().seq);
// If the peer has high latency, query extra deep
if (peer && peer->isHighLatency ())
@@ -672,7 +672,7 @@ void InboundLedger::trigger (Peer::ptr const& peer)
if (m_journal.debug) m_journal.debug <<
"Done:" << (mComplete ? " complete" : "") <<
(mFailed ? " failed " : " ") <<
mLedger->getLedgerSeq ();
mLedger->info().seq;
sl.unlock ();
done ();
}
@@ -784,10 +784,10 @@ bool InboundLedger::takeHeader (std::string const& data)
progress ();
if (mLedger->getTransHash ().isZero ())
if (mLedger->info().txHash.isZero ())
mHaveTransactions = true;
if (mLedger->getAccountHash ().isZero ())
if (mLedger->info().accountHash.isZero ())
mHaveState = true;
mLedger->setAcquiring ();
@@ -823,7 +823,7 @@ bool InboundLedger::takeTxNode (const std::vector<SHAMapNodeID>& nodeIDs,
if (nodeIDit->isRoot ())
{
san += mLedger->txMap().addRootNode (
mLedger->getTransHash (), *nodeDatait, snfWIRE, &tFilter);
mLedger->info().txHash, *nodeDatait, snfWIRE, &tFilter);
if (!san.isGood())
return false;
}
@@ -890,7 +890,7 @@ bool InboundLedger::takeAsNode (const std::vector<SHAMapNodeID>& nodeIDs,
if (nodeIDit->isRoot ())
{
san += mLedger->stateMap().addRootNode (
mLedger->getAccountHash (), *nodeDatait, snfWIRE, &tFilter);
mLedger->info().accountHash, *nodeDatait, snfWIRE, &tFilter);
if (!san.isGood ())
{
if (m_journal.warning) m_journal.warning <<
@@ -949,7 +949,7 @@ bool InboundLedger::takeAsRootNode (Blob const& data, SHAMapAddNode& san)
AccountStateSF tFilter;
san += mLedger->stateMap().addRootNode (
mLedger->getAccountHash (), data, snfWIRE, &tFilter);
mLedger->info().accountHash, data, snfWIRE, &tFilter);
return san.isGood();
}
@@ -973,7 +973,7 @@ bool InboundLedger::takeTxRootNode (Blob const& data, SHAMapAddNode& san)
TransactionStateSF tFilter;
san += mLedger->txMap().addRootNode (
mLedger->getTransHash (), data, snfWIRE, &tFilter);
mLedger->info().txHash, data, snfWIRE, &tFilter);
return san.isGood();
}

View File

@@ -259,9 +259,9 @@ public:
catch (SHAMapMissingNode &)
{
m_journal.warning <<
"Node missing from ledger " << ledger->getLedgerSeq();
"Node missing from ledger " << ledger->info().seq;
getApp().getInboundLedgers().acquire (
ledger->getHash(), ledger->getLedgerSeq(), InboundLedger::fcGENERIC);
ledger->getHash(), ledger->info().seq, InboundLedger::fcGENERIC);
}
return hash ? *hash : zero; // kludge
}
@@ -291,7 +291,7 @@ public:
Ledger::pointer dbLedger = Ledger::loadByIndex(ledgerIndex);
if (! dbLedger ||
(dbLedger->getHash() != ledgerHash) ||
(dbLedger->getParentHash() != nodeLedger->getParentHash()))
(dbLedger->info().parentHash != nodeLedger->info().parentHash))
{
// Ideally we'd also check for more than one ledger with that index
m_journal.debug <<
@@ -333,7 +333,7 @@ public:
{
LedgerHash ledgerHash;
if (!referenceLedger || (referenceLedger->getLedgerSeq() < ledgerIndex))
if (!referenceLedger || (referenceLedger->info().seq < ledgerIndex))
{
referenceLedger = getApp().getLedgerMaster().getValidatedLedger();
if (!referenceLedger)
@@ -343,7 +343,7 @@ public:
}
}
if (referenceLedger->getLedgerSeq() >= ledgerIndex)
if (referenceLedger->info().seq >= ledgerIndex)
{
// See if the hash for the ledger we need is in the reference ledger
ledgerHash = getLedgerHash(referenceLedger, ledgerIndex);

View File

@@ -236,13 +236,13 @@ LedgerConsensusImp::LedgerConsensusImp (
assert (mPreviousMSeconds);
inboundTransactions_.newRound (mPreviousLedger->getLedgerSeq());
inboundTransactions_.newRound (mPreviousLedger->info().seq);
// Adapt close time resolution to recent network conditions
mCloseResolution = getNextLedgerTimeResolution (
mPreviousLedger->getCloseResolution (),
mPreviousLedger->getCloseAgree (),
mPreviousLedger->getLedgerSeq () + 1);
mPreviousLedger->info().closeTimeResolution,
getCloseAgree (mPreviousLedger->info()),
mPreviousLedger->info().seq + 1);
if (mValPublic.isSet () && mValPrivate.isSet ()
&& !getApp().getOPs ().isNeedNetworkLedger ())
@@ -297,7 +297,7 @@ Json::Value LedgerConsensusImp::getJson (bool full)
if (mHaveCorrectLCL)
{
ret["synched"] = true;
ret["ledger_seq"] = mPreviousLedger->getLedgerSeq () + 1;
ret["ledger_seq"] = mPreviousLedger->info().seq + 1;
ret["close_granularity"] = mCloseResolution;
}
else
@@ -518,7 +518,7 @@ void LedgerConsensusImp::checkLCL ()
uint256 priorLedger;
if (mHaveCorrectLCL)
priorLedger = mPreviousLedger->getParentHash (); // don't jump back
priorLedger = mPreviousLedger->info().parentHash; // don't jump back
// Get validators that are on our ledger, or "close" to being on
// our ledger.
@@ -642,7 +642,7 @@ void LedgerConsensusImp::handleLCL (uint256 const& lclHash)
return;
}
assert (newLCL->isClosed () && newLCL->isImmutable ());
assert (!newLCL->info().open && newLCL->isImmutable ());
assert (newLCL->getHash () == lclHash);
mPreviousLedger = newLCL;
mPrevLedgerHash = lclHash;
@@ -652,9 +652,9 @@ void LedgerConsensusImp::handleLCL (uint256 const& lclHash)
mHaveCorrectLCL = true;
mCloseResolution = getNextLedgerTimeResolution (
mPreviousLedger->getCloseResolution (),
mPreviousLedger->getCloseAgree (),
mPreviousLedger->getLedgerSeq () + 1);
mPreviousLedger->info().closeTimeResolution,
getCloseAgree(mPreviousLedger->info()),
mPreviousLedger->info().seq + 1);
}
void LedgerConsensusImp::timerEntry ()
@@ -718,12 +718,12 @@ void LedgerConsensusImp::statePreClose ()
int sinceClose;
int idleInterval = 0;
if (mHaveCorrectLCL && mPreviousLedger->getCloseAgree ())
if (mHaveCorrectLCL && getCloseAgree(mPreviousLedger->info()))
{
// we can use consensus timing
sinceClose = 1000 * (getApp().getOPs ().getCloseTimeNC ()
- mPreviousLedger->getCloseTimeNC ());
idleInterval = 2 * mPreviousLedger->getCloseResolution ();
- mPreviousLedger->info().closeTime);
idleInterval = 2 * mPreviousLedger->info().closeTimeResolution;
if (idleInterval < LEDGER_IDLE_INTERVAL)
idleInterval = LEDGER_IDLE_INTERVAL;
@@ -737,7 +737,7 @@ void LedgerConsensusImp::statePreClose ()
}
idleInterval = std::max (idleInterval, LEDGER_IDLE_INTERVAL);
idleInterval = std::max (idleInterval, 2 * mPreviousLedger->getCloseResolution ());
idleInterval = std::max (idleInterval, 2 * mPreviousLedger->info().closeTimeResolution);
// Decide if we should close the ledger
if (shouldCloseLedger (anyTransactions
@@ -945,7 +945,7 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
// put our set where others can get it later
if (set->getHash ().isNonZero ())
consensus_.takePosition (mPreviousLedger->getLedgerSeq (), set);
consensus_.takePosition (mPreviousLedger->info().seq, set);
assert (set->getHash () == mOurPosition->getCurrentHash ());
// these are now obsolete
@@ -960,7 +960,7 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
{
// we agreed to disagree
closeTimeCorrect = false;
closeTime = mPreviousLedger->getCloseTimeNC () + 1;
closeTime = mPreviousLedger->info().closeTime + 1;
}
WriteLog (lsDEBUG, LedgerConsensus)
@@ -970,7 +970,7 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
<< " fail=" << (mConsensusFail ? "yes" : "no");
WriteLog (lsDEBUG, LedgerConsensus)
<< "Report: Prev = " << mPrevLedgerHash
<< ":" << mPreviousLedger->getLedgerSeq ();
<< ":" << mPreviousLedger->info().seq;
WriteLog (lsDEBUG, LedgerConsensus)
<< "Report: TxSt = " << set->getHash ()
<< ", close " << closeTime << (closeTimeCorrect ? "" : "X");
@@ -1009,9 +1009,9 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
newLCL->updateSkipList ();
int asf = newLCL->stateMap().flushDirty (
hotACCOUNT_NODE, newLCL->getLedgerSeq());
hotACCOUNT_NODE, newLCL->info().seq);
int tmf = newLCL->txMap().flushDirty (
hotTRANSACTION_NODE, newLCL->getLedgerSeq());
hotTRANSACTION_NODE, newLCL->info().seq);
WriteLog (lsDEBUG, LedgerConsensus) << "Flushed " << asf << " accounts and " <<
tmf << " transaction nodes";
@@ -1031,8 +1031,8 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
uint256 const newLCLHash = newLCL->getHash ();
WriteLog (lsDEBUG, LedgerConsensus)
<< "Report: NewL = " << newLCLHash
<< ":" << newLCL->getLedgerSeq ();
<< "Report: NewL = " << newLCL->getHash ()
<< ":" << newLCL->info().seq;
// Tell directly connected peers that we have a new LCL
statusChange (protocol::neACCEPTED_LEDGER, *newLCL);
@@ -1042,10 +1042,10 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
auto v = std::make_shared<STValidation> (newLCLHash,
consensus_.validationTimestamp (getApp().getOPs ().getNetworkTimeNC ()),
mValPublic, mProposing);
v->setFieldU32 (sfLedgerSequence, newLCL->getLedgerSeq ());
v->setFieldU32 (sfLedgerSequence, newLCL->info().seq);
addLoad(v); // Our network load
if (((newLCL->getLedgerSeq () + 1) % 256) == 0)
if (((newLCL->info().seq + 1) % 256) == 0)
// next ledger is flag ledger
{
// Suggest fee changes and new features
@@ -1352,10 +1352,10 @@ void LedgerConsensusImp::statusChange (protocol::NodeEvent event, Ledger& ledger
else
s.set_newevent (event);
s.set_ledgerseq (ledger.getLedgerSeq ());
s.set_ledgerseq (ledger.info().seq);
s.set_networktime (getApp().getOPs ().getNetworkTimeNC ());
s.set_ledgerhashprevious(ledger.getParentHash ().begin (),
std::decay_t<decltype(ledger.getParentHash ())>::bytes);
s.set_ledgerhashprevious(ledger.info().parentHash.begin (),
std::decay_t<decltype(ledger.info().parentHash)>::bytes);
s.set_ledgerhash (ledger.getHash ().begin (),
std::decay_t<decltype(ledger.getHash ())>::bytes);
@@ -1385,13 +1385,13 @@ void LedgerConsensusImp::takeInitialPosition (Ledger& initialLedger)
std::shared_ptr<SHAMap> initialSet;
if ((getConfig ().RUN_STANDALONE || (mProposing && mHaveCorrectLCL))
&& ((mPreviousLedger->getLedgerSeq () % 256) == 0))
&& ((mPreviousLedger->info().seq % 256) == 0))
{
// previous ledger was flag ledger
std::shared_ptr<SHAMap> preSet
= initialLedger.txMap().snapShot (true);
ValidationSet parentSet = getApp().getValidations().getValidations (
mPreviousLedger->getParentHash ());
mPreviousLedger->info().parentHash);
m_feeVote.doVoting (mPreviousLedger, parentSet, preSet);
getApp().getAmendmentTable ().doVoting (mPreviousLedger, parentSet, preSet);
initialSet = preSet->snapShot (false);
@@ -1400,14 +1400,14 @@ void LedgerConsensusImp::takeInitialPosition (Ledger& initialLedger)
initialSet = initialLedger.txMap().snapShot (false);
// Tell the ledger master not to acquire the ledger we're probably building
ledgerMaster_.setBuildingLedger (mPreviousLedger->getLedgerSeq () + 1);
ledgerMaster_.setBuildingLedger (mPreviousLedger->info().seq + 1);
uint256 txSet = initialSet->getHash ();
WriteLog (lsINFO, LedgerConsensus) << "initial position " << txSet;
mapCompleteInternal (txSet, initialSet, false);
mOurPosition = std::make_shared<LedgerProposal>
(mValPublic, initialLedger.getParentHash (), txSet, mCloseTime);
(mValPublic, initialLedger.info().parentHash, txSet, mCloseTime);
for (auto& it : mDisputes)
{
@@ -1569,7 +1569,7 @@ void LedgerConsensusImp::updateOurPositions ()
, end = closeTimes.end (); it != end; ++it)
{
WriteLog (lsDEBUG, LedgerConsensus) << "CCTime: seq"
<< mPreviousLedger->getLedgerSeq () + 1 << ": "
<< mPreviousLedger->info().seq + 1 << ": "
<< it->first << " has " << it->second << ", "
<< threshVote << " required";
@@ -1671,7 +1671,7 @@ void LedgerConsensusImp::checkOurValidation ()
if (lastValidation)
{
if (lastValidation->getFieldU32 (sfLedgerSequence)
== mPreviousLedger->getLedgerSeq ())
== mPreviousLedger->info().seq)
{
return;
}
@@ -1822,7 +1822,6 @@ void applyTransactions (
// The transaction isn't in the check ledger, try to apply it
WriteLog (lsDEBUG, LedgerConsensus) <<
"Processing candidate transaction: " << item.key();
std::shared_ptr<STTx const> txn;
try
{

View File

@@ -155,7 +155,7 @@ public:
LedgerIndex getCurrentLedgerIndex ()
{
return mCurrentLedger.get ()->getLedgerSeq ();
return mCurrentLedger.get ()->info().seq;
}
LedgerIndex getValidLedgerIndex ()
@@ -172,7 +172,7 @@ public:
return 999999;
}
std::int64_t ret = getApp().getOPs ().getCloseTimeNC ();
std::int64_t ret = getApp().getOPs().getCloseTimeNC();
ret -= static_cast<std::int64_t> (pubClose);
ret = (ret > 0) ? ret : 0;
@@ -189,7 +189,7 @@ public:
return 999999;
}
std::int64_t ret = getApp().getOPs ().getCloseTimeNC ();
std::int64_t ret = getApp().getOPs().getCloseTimeNC();
ret -= static_cast<std::int64_t> (valClose);
ret = (ret > 0) ? ret : 0;
@@ -235,28 +235,28 @@ public:
}
else
{
signTime = l->getCloseTimeNC();
signTime = l->info().closeTime;
}
mValidLedger.set (l);
mValidLedgerSign = signTime;
mValidLedgerSeq = l->getLedgerSeq();
mValidLedgerSeq = l->info().seq;
getApp().getOPs().updateLocalTx (l);
getApp().getSHAMapStore().onLedgerClosed (getValidatedLedger());
mLedgerHistory.validatedLedger (l);
getApp().getAmendmentTable().doValidatedLedger (l);
#if RIPPLE_HOOK_VALIDATORS
getApp().getValidators().onLedgerClosed (l->getLedgerSeq(),
l->getHash(), l->getParentHash());
getApp().getValidators().onLedgerClosed (l->info().seq,
l->getHash(), l->info().parentHash);
#endif
}
void setPubLedger(Ledger::ref l)
{
mPubLedger = l;
mPubLedgerClose = l->getCloseTimeNC();
mPubLedgerSeq = l->getLedgerSeq();
mPubLedgerClose = l->info().closeTime;
mPubLedgerSeq = l->info().seq;
}
void addHeldTransaction (Transaction::ref transaction)
@@ -297,9 +297,8 @@ public:
void pushLedger (Ledger::pointer newLCL, Ledger::pointer newOL)
{
assert (newLCL->isClosed () && newLCL->isAccepted ());
assert (!newOL->isClosed () && !newOL->isAccepted ());
assert (! newLCL->info().open && newLCL->info().accepted);
assert (newOL->info().open && !newOL->info().accepted);
{
ScopedLockType ml (m_mutex);
@@ -331,7 +330,7 @@ public:
mCurrentLedger.set (current);
mClosedLedger.set (lastClosed);
assert (!current->isClosed ());
assert (current->info().open);
}
checkAccept (lastClosed);
}
@@ -518,7 +517,7 @@ public:
{
// The earliest ledger we will let people fetch is ledger zero,
// unless that creates a larger range than allowed
std::uint32_t e = getClosedLedger()->getLedgerSeq();
std::uint32_t e = getClosedLedger()->info().seq;
if (e > fetch_depth_)
e -= fetch_depth_;
@@ -529,13 +528,13 @@ public:
void tryFill (Job& job, Ledger::pointer ledger)
{
std::uint32_t seq = ledger->getLedgerSeq ();
uint256 prevHash = ledger->getParentHash ();
std::uint32_t seq = ledger->info().seq;
uint256 prevHash = ledger->info().parentHash;
std::map< std::uint32_t, std::pair<uint256, uint256> > ledgerHashes;
std::uint32_t minHas = ledger->getLedgerSeq ();
std::uint32_t maxHas = ledger->getLedgerSeq ();
std::uint32_t minHas = ledger->info().seq;
std::uint32_t maxHas = ledger->info().seq;
while (! job.shouldCancel() && seq > 0)
{
@@ -638,7 +637,7 @@ public:
int invalidate = 0;
boost::optional<uint256> hash;
for (std::uint32_t lSeq = ledger->getLedgerSeq () - 1; lSeq > 0; --lSeq)
for (std::uint32_t lSeq = ledger->info().seq - 1; lSeq > 0; --lSeq)
{
if (haveLedger (lSeq))
{
@@ -682,7 +681,7 @@ public:
void setFullLedger (Ledger::pointer ledger, bool isSynchronous, bool isCurrent)
{
// A new ledger has been accepted as part of the trusted chain
WriteLog (lsDEBUG, LedgerMaster) << "Ledger " << ledger->getLedgerSeq () << " accepted :" << ledger->getHash ();
WriteLog (lsDEBUG, LedgerMaster) << "Ledger " << ledger->info().seq << " accepted :" << ledger->getHash ();
assert (ledger->stateMap().getHash ().isNonZero ());
ledger->setValidated();
@@ -697,12 +696,12 @@ public:
{
ScopedLockType ml (mCompleteLock);
mCompleteLedgers.setValue (ledger->getLedgerSeq ());
mCompleteLedgers.setValue (ledger->info().seq);
}
ScopedLockType ml (m_mutex);
if (ledger->getLedgerSeq() > mValidLedgerSeq)
if (ledger->info().seq > mValidLedgerSeq)
setValidLedger(ledger);
if (!mPubLedger)
{
@@ -710,12 +709,12 @@ public:
getApp().getOrderBookDB().setup(ledger);
}
if ((ledger->getLedgerSeq () != 0) && haveLedger (ledger->getLedgerSeq () - 1))
if ((ledger->info().seq != 0) && haveLedger (ledger->info().seq - 1))
{
// we think we have the previous ledger, double check
Ledger::pointer prevLedger = getLedgerBySeq (ledger->getLedgerSeq () - 1);
Ledger::pointer prevLedger = getLedgerBySeq (ledger->info().seq - 1);
if (!prevLedger || (prevLedger->getHash () != ledger->getParentHash ()))
if (!prevLedger || (prevLedger->getHash () != ledger->info().parentHash))
{
WriteLog (lsWARNING, LedgerMaster) << "Acquired ledger invalidates previous ledger: " <<
(prevLedger ? "hashMismatch" : "missingLedger");
@@ -797,13 +796,13 @@ public:
void checkAccept (Ledger::ref ledger)
{
if (ledger->getLedgerSeq() <= mValidLedgerSeq)
if (ledger->info().seq <= mValidLedgerSeq)
return;
// Can we advance the last fully-validated ledger? If so, can we publish?
ScopedLockType ml (m_mutex);
if (ledger->getLedgerSeq() <= mValidLedgerSeq)
if (ledger->info().seq <= mValidLedgerSeq)
return;
int minVal = getNeededValidations();
@@ -814,10 +813,10 @@ public:
return;
}
WriteLog (lsINFO, LedgerMaster) << "Advancing accepted ledger to " << ledger->getLedgerSeq() << " with >= " << minVal << " validations";
WriteLog (lsINFO, LedgerMaster) << "Advancing accepted ledger to " << ledger->info().seq << " with >= " << minVal << " validations";
mLastValidateHash = ledger->getHash();
mLastValidateSeq = ledger->getLedgerSeq();
mLastValidateSeq = ledger->info().seq;
ledger->setValidated();
ledger->setFull();
@@ -832,7 +831,7 @@ public:
std::uint64_t const base = getApp().getFeeTrack().getLoadBase();
auto fees = getApp().getValidations().fees (ledger->getHash(), base);
{
auto fees2 = getApp().getValidations().fees (ledger->getParentHash(), base);
auto fees2 = getApp().getValidations().fees (ledger->info().parentHash, base);
fees.reserve (fees.size() + fees2.size());
std::copy (fees2.begin(), fees2.end(), std::back_inserter(fees));
}
@@ -863,18 +862,18 @@ public:
if (standalone_)
return;
if (ledger->getLedgerSeq() <= mValidLedgerSeq)
if (ledger->info().seq <= mValidLedgerSeq)
{
WriteLog (lsINFO, LedgerConsensus)
<< "Consensus built old ledger: "
<< ledger->getLedgerSeq() << " <= " << mValidLedgerSeq;
<< ledger->info().seq << " <= " << mValidLedgerSeq;
return;
}
// See if this ledger can be the new fully-validated ledger
checkAccept (ledger);
if (ledger->getLedgerSeq() <= mValidLedgerSeq)
if (ledger->info().seq <= mValidLedgerSeq)
{
WriteLog (lsDEBUG, LedgerConsensus)
<< "Consensus ledger fully validated";
@@ -928,7 +927,7 @@ public:
{
Ledger::pointer ledger = getLedgerByHash (v.first);
if (ledger)
v.second.ledgerSeq_ = ledger->getLedgerSeq();
v.second.ledgerSeq_ = ledger->info().seq;
}
if (v.second.ledgerSeq_ > maxSeq)
@@ -972,7 +971,7 @@ public:
// Try to get the hash of a ledger we need to fetch for history
boost::optional<LedgerHash> ret;
if (mHistLedger && (mHistLedger->getLedgerSeq() >= index))
if (mHistLedger && (mHistLedger->info().seq >= index))
{
ret = hashOfSeq(*mHistLedger, index, m_journal);
if (! ret)
@@ -1028,7 +1027,7 @@ public:
std::uint32_t pubSeq = mPubLedgerSeq + 1; // Next sequence to publish
Ledger::pointer valLedger = mValidLedger.get ();
std::uint32_t valSeq = valLedger->getLedgerSeq ();
std::uint32_t valSeq = valLedger->info().seq;
ScopedUnlockType sul(m_mutex);
try
@@ -1064,7 +1063,7 @@ public:
*hash, seq, InboundLedger::fcGENERIC);
// Did we acquire the next ledger we need to publish?
if (ledger && (ledger->getLedgerSeq() == pubSeq))
if (ledger && (ledger->info().seq == pubSeq))
{
ledger->setValidated();
ret.push_back (ledger);
@@ -1101,7 +1100,7 @@ public:
// VFALCO NOTE This should return boost::optional<uint256>
uint256 getLedgerHash(std::uint32_t desiredSeq, Ledger::ref knownGoodLedger)
{
assert(desiredSeq < knownGoodLedger->getLedgerSeq());
assert(desiredSeq < knownGoodLedger->info().seq);
auto hash = hashOfSeq(*knownGoodLedger, desiredSeq, m_journal);
@@ -1151,7 +1150,7 @@ public:
ScopedLockType ml (m_mutex);
if (!mValidLedger.empty() &&
(!mPathLedger || (mPathLedger->getLedgerSeq() != mValidLedgerSeq)))
(!mPathLedger || (mPathLedger->info().seq != mValidLedgerSeq)))
{ // We have a new valid ledger since the last full pathfinding
mPathLedger = mValidLedger.get ();
lastLedger = mPathLedger;
@@ -1170,7 +1169,7 @@ public:
if (!standalone_)
{ // don't pathfind with a ledger that's more than 60 seconds old
std::int64_t age = getApp().getOPs().getCloseTimeNC();
age -= static_cast<std::int64_t> (lastLedger->getCloseTimeNC());
age -= static_cast<std::int64_t> (lastLedger->info().closeTime);
if (age > 60)
{
WriteLog (lsDEBUG, LedgerMaster) << "Published ledger too old for updating paths";
@@ -1186,7 +1185,7 @@ public:
catch (SHAMapMissingNode&)
{
WriteLog (lsINFO, LedgerMaster) << "Missing node detected during pathfinding";
getApp().getInboundLedgers().acquire(lastLedger->getHash (), lastLedger->getLedgerSeq (),
getApp().getInboundLedgers().acquire(lastLedger->getHash (), lastLedger->info().seq,
InboundLedger::fcGENERIC);
}
}
@@ -1314,7 +1313,7 @@ public:
// VFALCO NOTE This should return boost::optional<uint256>
uint256 walkHashBySeq (std::uint32_t index, Ledger::ref referenceLedger)
{
if (!referenceLedger || (referenceLedger->getLedgerSeq() < index))
if (!referenceLedger || (referenceLedger->info().seq < index))
{
// Nothing we can do. No validated ledger.
return zero;
@@ -1370,7 +1369,7 @@ public:
auto valid = mValidLedger.get ();
if (valid)
{
if (valid->getLedgerSeq() == index)
if (valid->info().seq == index)
return valid;
try
@@ -1391,11 +1390,11 @@ public:
return ret;
ret = mCurrentLedger.get ();
if (ret && (ret->getLedgerSeq () == index))
if (ret && (ret->info().seq == index))
return ret;
ret = mClosedLedger.get ();
if (ret && (ret->getLedgerSeq () == index))
if (ret && (ret->info().seq == index))
return ret;
clearLedger (index);
@@ -1529,7 +1528,8 @@ void LedgerMasterImp::doAdvance ()
std::uint32_t missing;
{
ScopedLockType sl (mCompleteLock);
missing = mCompleteLedgers.prevMissing(mPubLedger->getLedgerSeq());
missing = mCompleteLedgers.prevMissing(
mPubLedger->info().seq);
}
WriteLog (lsTRACE, LedgerMaster) << "tryAdvance discovered missing " << missing;
if ((missing != RangeSet::absent) && (missing > 0) &&
@@ -1566,15 +1566,20 @@ void LedgerMasterImp::doAdvance ()
}
if (ledger)
{
assert(ledger->getLedgerSeq() == missing);
WriteLog (lsTRACE, LedgerMaster) << "tryAdvance acquired " << ledger->getLedgerSeq();
auto seq = ledger->info().seq;
assert(seq == missing);
WriteLog (lsTRACE, LedgerMaster)
<< "tryAdvance acquired "
<< ledger->info().seq;
setFullLedger(ledger, false, false);
mHistLedger = ledger;
if ((mFillInProgress == 0) && (Ledger::getHashByIndex(ledger->getLedgerSeq() - 1) == ledger->getParentHash()))
auto& parent = ledger->info().parentHash;
if (mFillInProgress == 0 &&
Ledger::getHashByIndex(seq - 1) == parent)
{
// Previous ledger is in DB
ScopedLockType lock (m_mutex);
mFillInProgress = ledger->getLedgerSeq();
mFillInProgress = ledger->info().seq;
getApp().getJobQueue().addJob(jtADVANCE, "tryFill", std::bind (
&LedgerMasterImp::tryFill, this,
std::placeholders::_1, ledger));
@@ -1632,7 +1637,7 @@ void LedgerMasterImp::doAdvance ()
{
ScopedUnlockType sul (m_mutex);
WriteLog(lsDEBUG, LedgerMaster) <<
"tryAdvance publishing seq " << ledger->getLedgerSeq();
"tryAdvance publishing seq " << ledger->info().seq;
setFullLedger(ledger, true, true);
getApp().getOPs().pubLedger(ledger);
@@ -1718,7 +1723,7 @@ void LedgerMasterImp::makeFetchPack (
return;
}
if (!haveLedger->isClosed ())
if (haveLedger->info().open)
{
m_journal.warning
<< "Peer requests fetch pack from open ledger: "
@@ -1727,14 +1732,14 @@ void LedgerMasterImp::makeFetchPack (
return;
}
if (haveLedger->getLedgerSeq() < getEarliestFetch())
if (haveLedger->info().seq < getEarliestFetch())
{
m_journal.debug << "Peer requests fetch pack that is too early";
peer->charge (Resource::feeInvalidRequest);
return;
}
auto wantLedger = getLedgerByHash (haveLedger->getParentHash ());
auto wantLedger = getLedgerByHash (haveLedger->info().parentHash);
if (!wantLedger)
{
@@ -1780,7 +1785,7 @@ void LedgerMasterImp::makeFetchPack (
// the same process adding the previous ledger to the FetchPack.
do
{
std::uint32_t lSeq = wantLedger->getLedgerSeq ();
std::uint32_t lSeq = wantLedger->info().seq;
protocol::TMIndexedObject& newObj = *reply.add_objects ();
newObj.set_hash (wantLedger->getHash ().begin (), 256 / 8);
@@ -1795,7 +1800,7 @@ void LedgerMasterImp::makeFetchPack (
std::bind (fpAppender, &reply, lSeq, std::placeholders::_1,
std::placeholders::_2));
if (wantLedger->getTransHash ().isNonZero ())
if (wantLedger->info().txHash.isNonZero ())
wantLedger->txMap().getFetchPack (
nullptr, true, 512,
std::bind (fpAppender, &reply, lSeq, std::placeholders::_1,
@@ -1806,7 +1811,7 @@ void LedgerMasterImp::makeFetchPack (
// move may save a ref/unref
haveLedger = std::move (wantLedger);
wantLedger = getLedgerByHash (haveLedger->getParentHash ());
wantLedger = getLedgerByHash (haveLedger->info().parentHash);
}
while (wantLedger &&
UptimeTimer::getInstance ().getElapsedSeconds () <= uUptime + 1);

View File

@@ -18,182 +18,166 @@
//==============================================================================
#include <ripple/app/ledger/LedgerToJson.h>
#include <ripple/basics/base_uint.h>
namespace ripple {
template <typename Object>
void fillJson (Object& json, LedgerFill const& fill)
namespace {
bool isFull(LedgerFill const& fill)
{
using namespace ripple::RPC;
return fill.options & LedgerFill::full;
}
auto& ledger = fill.ledger;
bool isExpanded(LedgerFill const& fill)
{
return isFull(fill) || (fill.options & LedgerFill::expand);
}
bool const bFull (fill.options & LedgerFill::full);
bool const bExpand (fill.options & LedgerFill::expand);
bool const bBinary (fill.options & LedgerFill::binary);
bool isBinary(LedgerFill const& fill)
{
return fill.options & LedgerFill::binary;
}
// DEPRECATED
json[jss::seqNum] = to_string (ledger.getLedgerSeq());
json[jss::parent_hash] = to_string (ledger.getParentHash());
json[jss::ledger_index] = to_string (ledger.getLedgerSeq());
template <class Object>
void fillJson(Object& json, LedgerInfo const& info, bool bFull)
{
json[jss::parent_hash] = to_string (info.parentHash);
json[jss::ledger_index] = to_string (info.seq);
json[jss::seqNum] = to_string (info.seq); // DEPRECATED
if (ledger.isClosed() || bFull)
if (! info.open)
{
if (ledger.isClosed())
json[jss::closed] = true;
// DEPRECATED
json[jss::hash] = to_string (ledger.getHash());
// DEPRECATED
json[jss::totalCoins] = to_string (ledger.getTotalCoins());
json[jss::ledger_hash] = to_string (ledger.getHash());
json[jss::transaction_hash] = to_string (ledger.getTransHash());
json[jss::account_hash] = to_string (ledger.getAccountHash());
json[jss::accepted] = ledger.isAccepted();
json[jss::total_coins] = to_string (ledger.getTotalCoins());
auto closeTime = ledger.getCloseTimeNC();
if (closeTime != 0)
{
json[jss::close_time] = closeTime;
json[jss::close_time_human]
= boost::posix_time::to_simple_string (
ptFromSeconds (closeTime));
json[jss::close_time_resolution] = ledger.getCloseResolution();
if (!ledger.getCloseAgree())
json[jss::close_time_estimated] = true;
}
json[jss::closed] = true;
}
else
else if (!bFull)
{
json[jss::closed] = false;
return;
}
if (ledger.haveTxMap() && (bFull || fill.options & LedgerFill::dumpTxrp))
json[jss::ledger_hash] = to_string (info.hash);
json[jss::transaction_hash] = to_string (info.txHash);
json[jss::account_hash] = to_string (info.accountHash);
json[jss::total_coins] = to_string (info.drops);
// These next three are DEPRECATED.
json[jss::hash] = to_string (info.hash);
json[jss::totalCoins] = to_string (info.drops);
json[jss::accepted] = ! info.open;
if (auto closeTime = info.closeTime)
{
auto const& txMap = ledger.txMap();
auto&& txns = setArray (json, jss::transactions);
SHAMapTreeNode::TNType type;
json[jss::close_time] = closeTime;
json[jss::close_time_human] = boost::posix_time::to_simple_string (
ptFromSeconds (closeTime));
json[jss::close_time_resolution] = info.closeTimeResolution;
CountedYield count (
fill.yieldStrategy.transactionYieldCount, fill.yield);
for (auto item = txMap.peekFirstItem (type); item;
item = txMap.peekNextItem (item->key(), type))
{
count.yield();
if (bFull || bExpand)
{
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
{
if (bBinary)
{
auto&& obj = appendObject (txns);
obj[jss::tx_blob] = strHex (item->peekData ());
}
else
{
SerialIter sit (item->slice ());
STTx txn (sit);
txns.append (txn.getJson (0));
}
}
else if (type == SHAMapTreeNode::tnTRANSACTION_MD)
{
if (bBinary)
{
SerialIter sit (item->slice ());
auto&& obj = appendObject (txns);
obj[jss::tx_blob] = strHex (sit.getVL ());
obj[jss::meta] = strHex (sit.getVL ());
}
else
{
// VFALCO This is making a needless copy
SerialIter sit (item->slice ());
auto const vl = sit.getVL();
SerialIter tsit (makeSlice(vl));
STTx txn (tsit);
TxMeta meta (
item->key(), ledger.getLedgerSeq(), sit.getVL ());
auto&& txJson = appendObject (txns);
copyFrom(txJson, txn.getJson (0));
txJson[jss::metaData] = meta.getJson (0);
}
}
else
{
auto&& error = appendObject (txns);
error[to_string (item->key())] = (int) type;
}
}
else
{
txns.append (to_string (item->key()));
}
}
}
if (ledger.haveStateMap() && (bFull || fill.options & LedgerFill::dumpState))
{
auto const& stateMap = ledger.stateMap();
auto&& array = Json::setArray (json, jss::accountState);
RPC::CountedYield count (
fill.yieldStrategy.accountYieldCount, fill.yield);
if (bFull || bExpand)
{
if (bBinary)
{
stateMap.visitLeaves (
[&array] (std::shared_ptr<SHAMapItem const> const& smi)
{
auto&& obj = appendObject (array);
obj[jss::hash] = to_string(smi->key());
obj[jss::tx_blob] = strHex(smi->peekData ());
});
}
else
{
ledger.visitStateItems (
[&array, &count] (SLE::ref sle)
{
count.yield();
array.append (sle->getJson(0));
});
}
}
else
{
stateMap.visitLeaves(
[&array, &count] (std::shared_ptr<SHAMapItem const> const& smi)
{
count.yield();
array.append (to_string(smi->key()));
});
}
if (! getCloseAgree(info))
json[jss::close_time_estimated] = true;
}
}
/** Add Json to an existing generic Object. */
template <class Object>
void addJsonImpl (Object& json, LedgerFill const& fill)
void fillJsonTx (Object& json, LedgerFill const& fill)
{
auto&& txns = setArray (json, jss::transactions);
auto bBinary = isBinary(fill);
auto bExpanded = isExpanded(fill);
RPC::CountedYield count (
fill.yieldStrategy.transactionYieldCount, fill.yield);
try
{
using value_type = ReadView::txs_type::value_type;
forEachTx(fill.ledger, [&] (value_type const& i) {
count.yield();
if (! bExpanded)
{
txns.append(to_string(i.first->getTransactionID()));
return true;
}
auto&& txJson = appendObject (txns);
if (bBinary)
{
txJson[jss::tx_blob] = serializeHex(*i.first);
if (i.second)
txJson[jss::meta] = serializeHex(*i.second);
}
else
{
copyFrom(txJson, i.first->getJson(0));
if (i.second)
txJson[jss::metaData] = i.second->getJson(0);
}
return true;
});
}
catch (...)
{
// Nothing the user can do about this.
}
}
template <class Object>
void fillJsonState(Object& json, LedgerFill const& fill)
{
auto& ledger = fill.ledger;
auto&& array = Json::setArray (json, jss::accountState);
RPC::CountedYield count (
fill.yieldStrategy.accountYieldCount, fill.yield);
auto expanded = isExpanded(fill);
auto binary = isBinary(fill);
forEachSLE(ledger, [&] (SLE const& sle) {
count.yield();
if (binary)
{
auto&& obj = appendObject(array);
obj[jss::hash] = to_string(sle.key());
obj[jss::tx_blob] = serializeHex(sle);
}
else if (expanded)
array.append(sle.getJson(0));
else
array.append(to_string(sle.key()));
return true;
});
}
template <class Object>
void fillJson (Object& json, LedgerFill const& fill)
{
// TODO: what happens if bBinary and bExtracted are both set?
// Is there a way to report this back?
auto bFull = isFull(fill);
fillJson(json, fill.ledger.info(), bFull);
if (bFull || fill.options & LedgerFill::dumpTxrp)
fillJsonTx(json, fill);
if (bFull || fill.options & LedgerFill::dumpState)
fillJsonState(json, fill);
}
} // namespace
void addJson (Json::Object& json, LedgerFill const& fill)
{
auto&& object = Json::addObject (json, jss::ledger);
fillJson (object, fill);
}
void addJson(Json::Object& object, LedgerFill const& fill)
void addJson (Json::Value& json, LedgerFill const& fill)
{
addJsonImpl (object, fill);
}
auto&& object = Json::addObject (json, jss::ledger);
fillJson (object, fill);
void addJson(Json::Value& object, LedgerFill const& fill)
{
addJsonImpl (object, fill);
}
Json::Value getJson (LedgerFill const& fill)

View File

@@ -452,9 +452,9 @@ close_and_advance(Ledger::pointer& ledger, std::shared_ptr<Ledger const>& LCL)
newLCL->updateSkipList();
newLCL->setClosed();
newLCL->stateMap().flushDirty(
hotACCOUNT_NODE, newLCL->getLedgerSeq());
hotACCOUNT_NODE, newLCL->info().seq);
newLCL->txMap().flushDirty(
hotTRANSACTION_NODE, newLCL->getLedgerSeq());
hotTRANSACTION_NODE, newLCL->info().seq);
using namespace std::chrono;
auto const epoch_offset = days(10957); // 2000-01-01
std::uint32_t closeTime = time_point_cast<seconds> // now

View File

@@ -1073,7 +1073,7 @@ void ApplicationImp::startNewLedger ()
secondLedger->setClosed ();
secondLedger->setAccepted ();
m_networkOPs->setLastCloseTime (secondLedger->getCloseTimeNC ());
m_networkOPs->setLastCloseTime (secondLedger->info().closeTime);
openLedger_.emplace(secondLedger, getConfig(),
cachedSLEs_, deprecatedLogs().journal("OpenLedger"));
m_ledgerMaster->pushLedger (secondLedger, std::make_shared<Ledger> (true, std::ref (*secondLedger)));
@@ -1277,14 +1277,14 @@ bool ApplicationImp::loadOldLedger (
m_journal.info << "Loading parent ledger";
loadLedger = Ledger::loadByHash (replayLedger->getParentHash ());
loadLedger = Ledger::loadByHash (replayLedger->info().parentHash);
if (!loadLedger)
{
m_journal.info << "Loading parent ledger from node store";
// Try to build the ledger from the back end
auto il = std::make_shared <InboundLedger> (
replayLedger->getParentHash(), 0, InboundLedger::fcGENERIC,
replayLedger->info().parentHash, 0, InboundLedger::fcGENERIC,
stopwatch());
if (il->checkLocal ())
loadLedger = il->getLedger ();
@@ -1300,9 +1300,9 @@ bool ApplicationImp::loadOldLedger (
loadLedger->setClosed ();
m_journal.info << "Loading ledger " << loadLedger->getHash () << " seq:" << loadLedger->getLedgerSeq ();
m_journal.info << "Loading ledger " << loadLedger->getHash () << " seq:" << loadLedger->info().seq;
if (loadLedger->getAccountHash ().isZero ())
if (loadLedger->info().accountHash.isZero ())
{
m_journal.fatal << "Ledger is empty.";
assert (false);
@@ -1323,12 +1323,12 @@ bool ApplicationImp::loadOldLedger (
return false;
}
m_ledgerMaster->setLedgerRangePresent (loadLedger->getLedgerSeq (), loadLedger->getLedgerSeq ());
m_ledgerMaster->setLedgerRangePresent (loadLedger->info().seq, loadLedger->info().seq);
Ledger::pointer openLedger = std::make_shared<Ledger> (false, std::ref (*loadLedger));
m_ledgerMaster->switchLedgers (loadLedger, openLedger);
m_ledgerMaster->forceValid(loadLedger);
m_networkOPs->setLastCloseTime (loadLedger->getCloseTimeNC ());
m_networkOPs->setLastCloseTime (loadLedger->info().closeTime);
openLedger_.emplace(loadLedger, getConfig(),
cachedSLEs_, deprecatedLogs().journal("OpenLedger"));

View File

@@ -408,7 +408,7 @@ AmendmentTableImpl::doVoting (
ValidationSet const& valSet)
{
// LCL must be flag ledger
//assert((lastClosedLedger->getLedgerSeq () % 256) == 0);
//assert((lastClosedLedger->info().seq % 256) == 0);
AmendmentSet amendmentSet (closeTime);

View File

@@ -150,7 +150,7 @@ FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger,
std::shared_ptr<SHAMap> const& initialPosition)
{
// LCL must be flag ledger
assert ((lastClosedLedger->getLedgerSeq () % 256) == 0);
assert ((lastClosedLedger->info().seq % 256) == 0);
detail::VotableInteger<std::uint64_t> baseFeeVote (
lastClosedLedger->getBaseFee (), target_.reference_fee);

View File

@@ -1197,7 +1197,7 @@ void NetworkOPsImp::tryStartConsensus ()
// Note: Do not go to omFULL if we don't have the previous ledger
// check if the ledger is bad enough to go to omCONNECTED -- TODO
if (getApp().getOPs ().getNetworkTimeNC () <
m_ledgerMaster.getCurrentLedger ()->getCloseTimeNC ())
m_ledgerMaster.getCurrentLedger ()->info().closeTime)
{
setMode (omFULL);
}
@@ -1223,7 +1223,7 @@ bool NetworkOPsImp::checkLastClosedLedger (
return false;
uint256 closedLedger = ourClosed->getHash ();
uint256 prevClosedLedger = ourClosed->getParentHash ();
uint256 prevClosedLedger = ourClosed->info().parentHash;
m_journal.trace << "OurClosed: " << closedLedger;
m_journal.trace << "PrevClosed: " << prevClosedLedger;
@@ -1398,9 +1398,9 @@ void NetworkOPsImp::switchLastClosedLedger (
protocol::TMStatusChange s;
s.set_newevent (protocol::neSWITCHED_LEDGER);
s.set_ledgerseq (newLCL->getLedgerSeq ());
s.set_ledgerseq (newLCL->info().seq);
s.set_networktime (getApp().getOPs ().getNetworkTimeNC ());
uint256 hash = newLCL->getParentHash ();
uint256 hash = newLCL->info().parentHash;
s.set_ledgerhashprevious (hash.begin (), hash.size ());
hash = newLCL->getHash ();
s.set_ledgerhash (hash.begin (), hash.size ());
@@ -1413,11 +1413,11 @@ bool NetworkOPsImp::beginConsensus (
uint256 const& networkClosed, Ledger::pointer closingLedger)
{
if (m_journal.info) m_journal.info <<
"Consensus time for #" << closingLedger->getLedgerSeq () <<
" with LCL " << closingLedger->getParentHash ();
"Consensus time for #" << closingLedger->info().seq <<
" with LCL " << closingLedger->info().parentHash;
auto prevLedger = m_ledgerMaster.getLedgerByHash (
closingLedger->getParentHash ());
closingLedger->info().parentHash);
if (!prevLedger)
{
@@ -1431,8 +1431,8 @@ bool NetworkOPsImp::beginConsensus (
return false;
}
assert (prevLedger->getHash () == closingLedger->getParentHash ());
assert (closingLedger->getParentHash () ==
assert (prevLedger->getHash () == closingLedger->info().parentHash);
assert (closingLedger->info().parentHash ==
m_ledgerMaster.getClosedLedger ()->getHash ());
// Create a consensus object to get consensus on this ledger
@@ -1445,7 +1445,7 @@ bool NetworkOPsImp::beginConsensus (
m_ledgerMaster,
networkClosed,
prevLedger,
m_ledgerMaster.getCurrentLedger ()->getCloseTimeNC ());
m_ledgerMaster.getCurrentLedger ()->info().closeTime);
m_journal.debug << "Initiating consensus engine";
return true;
@@ -1535,7 +1535,7 @@ NetworkOPsImp::mapComplete (uint256 const& hash,
void NetworkOPsImp::endConsensus (bool correctLCL)
{
uint256 deadLedger = m_ledgerMaster.getClosedLedger ()->getParentHash ();
uint256 deadLedger = m_ledgerMaster.getClosedLedger ()->info().parentHash;
// Why do we make a copy of the peer list here?
std::vector <Peer::ptr> peerList = getApp().overlay ().getActivePeers ();
@@ -2036,7 +2036,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
std::uint64_t baseFee = lpClosed->getBaseFee ();
std::uint64_t baseRef = lpClosed->getReferenceFeeUnits ();
Json::Value l (Json::objectValue);
l[jss::seq] = Json::UInt (lpClosed->getLedgerSeq ());
l[jss::seq] = Json::UInt (lpClosed->info().seq);
l[jss::hash] = to_string (lpClosed->getHash ());
if (!human)
@@ -2046,7 +2046,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
l[jss::reserve_inc] =
Json::Value::UInt (lpClosed->getReserveInc ());
l[jss::close_time] =
Json::Value::UInt (lpClosed->getCloseTimeNC ());
Json::Value::UInt (lpClosed->info().closeTime);
}
else
{
@@ -2066,7 +2066,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
if (std::abs (offset) >= 60)
l[jss::system_time_offset] = offset;
std::uint32_t lCloseTime (lpClosed->getCloseTimeNC ());
std::uint32_t lCloseTime (lpClosed->info().closeTime);
if (std::abs (mCloseTimeOffset) >= 60)
l[jss::close_time_offset] = mCloseTimeOffset;
@@ -2087,8 +2087,8 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin)
Ledger::pointer lpPublished = m_ledgerMaster.getPublishedLedger ();
if (!lpPublished)
info[jss::published_ledger] = "none";
else if (lpPublished->getLedgerSeq() != lpClosed->getLedgerSeq())
info[jss::published_ledger] = lpPublished->getLedgerSeq();
else if (lpPublished->info().seq != lpClosed->info().seq)
info[jss::published_ledger] = lpPublished->info().seq;
}
return info;
@@ -2149,10 +2149,10 @@ void NetworkOPsImp::pubLedger (Ledger::ref accepted)
Json::Value jvObj (Json::objectValue);
jvObj[jss::type] = "ledgerClosed";
jvObj[jss::ledger_index] = lpAccepted->getLedgerSeq ();
jvObj[jss::ledger_index] = lpAccepted->info().seq;
jvObj[jss::ledger_hash] = to_string (lpAccepted->getHash ());
jvObj[jss::ledger_time]
= Json::Value::UInt (lpAccepted->getCloseTimeNC ());
= Json::Value::UInt (lpAccepted->info().closeTime);
jvObj[jss::fee_ref]
= Json::UInt (lpAccepted->getReferenceFeeUnits ());
@@ -2219,9 +2219,9 @@ Json::Value NetworkOPsImp::transJson(
if (bValidated)
{
jvObj[jss::ledger_index] = lpCurrent->getLedgerSeq ();
jvObj[jss::ledger_index] = lpCurrent->info().seq;
jvObj[jss::ledger_hash] = to_string (lpCurrent->getHash ());
jvObj[jss::transaction][jss::date] = lpCurrent->getCloseTimeNC ();
jvObj[jss::transaction][jss::date] = lpCurrent->info().closeTime;
jvObj[jss::validated] = true;
// WRITEME: Put the account next seq here
@@ -2230,7 +2230,7 @@ Json::Value NetworkOPsImp::transJson(
else
{
jvObj[jss::validated] = false;
jvObj[jss::ledger_current_index] = lpCurrent->getLedgerSeq ();
jvObj[jss::ledger_current_index] = lpCurrent->info().seq;
}
jvObj[jss::status] = bValidated ? "closed" : "proposed";
@@ -2497,7 +2497,7 @@ std::uint32_t NetworkOPsImp::acceptLedger ()
m_ledgerMaster.getClosedLedger ()->getHash (),
m_ledgerMaster.getCurrentLedger ());
mLedgerConsensus->simulate ();
return m_ledgerMaster.getCurrentLedger ()->getLedgerSeq ();
return m_ledgerMaster.getCurrentLedger ()->info().seq;
}
// <-- bool: true=added, false=already there
@@ -2507,10 +2507,10 @@ bool NetworkOPsImp::subLedger (InfoSub::ref isrListener, Json::Value& jvResult)
if (lpClosed)
{
jvResult[jss::ledger_index] = lpClosed->getLedgerSeq ();
jvResult[jss::ledger_index] = lpClosed->info().seq;
jvResult[jss::ledger_hash] = to_string (lpClosed->getHash ());
jvResult[jss::ledger_time]
= Json::Value::UInt (lpClosed->getCloseTimeNC ());
= Json::Value::UInt (lpClosed->info().closeTime);
jvResult[jss::fee_ref]
= Json::UInt (lpClosed->getReferenceFeeUnits ());
jvResult[jss::fee_base] = Json::UInt (lpClosed->getBaseFee ());

View File

@@ -291,7 +291,7 @@ SHAMapStoreImp::run()
continue;
}
LedgerIndex validatedSeq = validatedLedger_->getLedgerSeq();
LedgerIndex validatedSeq = validatedLedger_->info().seq;
if (!lastRotated)
{
lastRotated = validatedSeq;

View File

@@ -122,7 +122,7 @@ public:
bool can_remove (LocalTx& txn, Ledger::ref ledger)
{
if (txn.isExpired (ledger->getLedgerSeq ()))
if (txn.isExpired (ledger->info().seq))
return true;
if (ledger->txExists(txn.getID()))
return true;

View File

@@ -182,7 +182,7 @@ Json::Value Transaction::getJson (int options, bool binary) const
auto ledger = getApp().getLedgerMaster ().
getLedgerBySeq (mInLedger);
if (ledger)
ret[jss::date] = ledger->getCloseTimeNC ();
ret[jss::date] = ledger->info().closeTime;
}
}

View File

@@ -73,12 +73,24 @@ struct LedgerInfo
// Fields for closed ledgers
// Closed means "tx set already determined"
uint256 hash = zero;
//uint256 txHash;
uint256 txHash = zero;
uint256 accountHash = zero;
uint256 parentHash = zero;
//uint256 stateHash;
//uint256 parentHash;
//std::uint64_t coins = 0;
//bool validated = false;
//int closeTimeRes = 0;
std::uint64_t drops = 0;
// If validated is false, it means "not yet validated."
// Once validated is true, it will never be set false at a later time.
mutable
bool validated = false;
bool accepted = false;
// flags indicating how this ledger close took place
int closeFlags = 0;
// the resolution for this ledger close time (2-120 seconds)
int closeTimeResolution = 0;
// For closed ledgers, the time the ledger
// closed. For open ledgers, the time the ledger
@@ -87,6 +99,19 @@ struct LedgerInfo
std::uint32_t closeTime = 0;
};
// ledger close flags
static
std::uint32_t const sLCF_NoConsensusTime = 1;
inline
bool getCloseAgree (LedgerInfo const& info)
{
return (info.closeFlags & sLCF_NoConsensusTime) == 0;
}
void addRaw (LedgerInfo const&, Serializer&);
//------------------------------------------------------------------------------
/** A view into a ledger.
@@ -285,6 +310,29 @@ public:
digest (key_type const& key) const = 0;
};
/** Run a functor on each SLE in a ReadView starting from the key start,
as long as the functor returns true.
*/
template <class Functor>
void forEachSLE(ReadView const& view, Functor func, uint256 const& start = {})
{
for (auto k = view.succ(start); k; k = view.succ(*k))
if (auto sle = view.read(keylet::unchecked(*k)))
if (! func(*sle))
break;
}
/** Run a functor on each transaction in a ReadView, as long as the functor
returns true. Might throw an exception if the ledger is corrupt. */
template <class Functor>
void forEachTx(ReadView const& view, Functor func)
{
for (auto i = view.txs.begin(); i != view.txs.begin(); ++i)
if (i->first)
if (! func(*i))
break;
}
} // ripple
#include <ripple/ledger/detail/ReadViewFwdRange.ipp>

View File

@@ -41,7 +41,6 @@
#include <vector>
namespace ripple {
//------------------------------------------------------------------------------
//
// Observers
@@ -255,7 +254,7 @@ accountSend (ApplyView& view,
AccountID const& to,
const STAmount & saAmount);
TER
TER
issueIOU (ApplyView& view,
AccountID const& account,
STAmount const& amount,

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/ledger/ReadView.h>
#include <ripple/ledger/View.h>
#include <ripple/basics/contract.h>
#include <ripple/basics/Log.h>
@@ -73,6 +74,19 @@ getFees (ReadView const& view,
//------------------------------------------------------------------------------
void addRaw (LedgerInfo const& info, Serializer& s)
{
s.add32 (info.seq);
s.add64 (info.drops);
s.add256 (info.parentHash);
s.add256 (info.txHash);
s.add256 (info.accountHash);
s.add32 (info.parentCloseTime);
s.add32 (info.closeTime);
s.add8 (info.closeTimeResolution);
s.add8 (info.closeFlags);
}
bool
isGlobalFrozen (ReadView const& view,
AccountID const& issuer)
@@ -349,7 +363,7 @@ cdirFirst (ReadView const& view,
return cdirNext (view, uRootIndex, sleNode, uDirEntry, uEntryIndex);
}
bool
bool
cdirNext (ReadView const& view,
uint256 const& uRootIndex, // --> Root of directory
std::shared_ptr<SLE const>& sleNode, // <-> current node
@@ -476,7 +490,7 @@ dirFirst (ApplyView& view,
return dirNext (view, uRootIndex, sleNode, uDirEntry, uEntryIndex);
}
bool
bool
dirNext (ApplyView& view,
uint256 const& uRootIndex, // --> Root of directory
std::shared_ptr<SLE>& sleNode, // <-> current node

View File

@@ -2028,9 +2028,9 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
{
ledger = getApp().getLedgerMaster ().getClosedLedger ();
if (ledger && !ledger->isClosed ())
if (ledger && ledger->info().open)
ledger = getApp().getLedgerMaster ().getLedgerBySeq (
ledger->getLedgerSeq () - 1);
ledger->info().seq - 1);
}
else
{
@@ -2041,7 +2041,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
}
if ((!ledger) || (packet.has_ledgerseq () && (
packet.ledgerseq () != ledger->getLedgerSeq ())))
packet.ledgerseq () != ledger->info().seq)))
{
charge (Resource::feeInvalidRequest);
@@ -2052,7 +2052,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
return;
}
if (!packet.has_ledgerseq() && (ledger->getLedgerSeq() <
if (!packet.has_ledgerseq() && (ledger->info().seq <
getApp().getLedgerMaster().getEarliestFetch()))
{
if (p_journal_.debug) p_journal_.debug <<
@@ -2063,7 +2063,7 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
// Fill out the reply
uint256 lHash = ledger->getHash ();
reply.set_ledgerhash (lHash.begin (), lHash.size ());
reply.set_ledgerseq (ledger->getLedgerSeq ());
reply.set_ledgerseq (ledger->info().seq);
reply.set_type (packet.itype ());
if (packet.itype () == protocol::liBASE)
@@ -2076,31 +2076,28 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
reply.add_nodes ()->set_nodedata (
nData.getDataPtr (), nData.getLength ());
if (ledger->haveStateMap())
auto const& stateMap = ledger->stateMap ();
if (stateMap.getHash() != zero)
{
auto const& stateMap = ledger->stateMap ();
if (stateMap.getHash() != zero)
// return account state root node if possible
Serializer rootNode (768);
if (stateMap.getRootNode(rootNode, snfWIRE))
{
// return account state root node if possible
Serializer rootNode (768);
if (stateMap.getRootNode(rootNode, snfWIRE))
reply.add_nodes ()->set_nodedata (
rootNode.getDataPtr (), rootNode.getLength ());
if (ledger->info().txHash != zero)
{
reply.add_nodes ()->set_nodedata (
rootNode.getDataPtr (), rootNode.getLength ());
auto const& txMap = ledger->txMap ();
if (ledger->getTransHash () != zero && ledger->haveTxMap ())
if (txMap.getHash() != zero)
{
auto const& txMap = ledger->txMap ();
rootNode.erase ();
if (txMap.getHash() != zero)
{
rootNode.erase ();
if (txMap.getRootNode (rootNode, snfWIRE))
reply.add_nodes ()->set_nodedata (
rootNode.getDataPtr (),
rootNode.getLength ());
}
if (txMap.getRootNode (rootNode, snfWIRE))
reply.add_nodes ()->set_nodedata (
rootNode.getDataPtr (),
rootNode.getLength ());
}
}
}
@@ -2114,14 +2111,12 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
if (packet.itype () == protocol::liTX_NODE)
{
assert (ledger->haveTxMap ());
map = &ledger->txMap ();
logMe += " TX:";
logMe += to_string (map->getHash ());
}
else if (packet.itype () == protocol::liAS_NODE)
{
assert (ledger->haveStateMap ());
map = &ledger->stateMap ();
logMe += " AS:";
logMe += to_string (map->getHash ());

View File

@@ -130,11 +130,11 @@ buildHello (uint256 const& sharedValue, Application& app)
auto const closedLedger = app.getLedgerMaster().getClosedLedger();
if (closedLedger && closedLedger->isClosed ())
if (closedLedger && !closedLedger->info().open)
{
uint256 hash = closedLedger->getHash ();
h.set_ledgerclosed (hash.begin (), hash.size ());
hash = closedLedger->getParentHash ();
hash = closedLedger->info().parentHash;
h.set_ledgerprevious (hash.begin (), hash.size ());
}

View File

@@ -89,7 +89,7 @@ Json::Value doAccountTx (RPC::Context& context)
if (! ledger)
return ret;
uLedgerMin = uLedgerMax = ledger->getLedgerSeq ();
uLedgerMin = uLedgerMax = ledger->info().seq;
}
Json::Value resumeToken;

View File

@@ -109,7 +109,7 @@ Json::Value doAccountTxOld (RPC::Context& context)
if (!ledger)
return ret;
uLedgerMin = uLedgerMax = ledger->getLedgerSeq ();
uLedgerMin = uLedgerMax = ledger->info().seq;
}
int count = 0;

View File

@@ -76,7 +76,7 @@ Json::Value doCanDelete (RPC::Context& context)
if (!ledger)
return RPC::make_error(rpcLGR_NOT_FOUND, "ledgerNotFound");
canDeleteSeq = ledger->getLedgerSeq();
canDeleteSeq = ledger->info().seq;
}
else
{

View File

@@ -27,7 +27,7 @@ Json::Value doLedgerClosed (RPC::Context& context)
assert (ledger);
Json::Value jvResult;
jvResult[jss::ledger_index] = ledger->getLedgerSeq ();
jvResult[jss::ledger_index] = ledger->info().seq;
jvResult[jss::ledger_hash] = to_string (ledger->getHash ());
return jvResult;

View File

@@ -72,7 +72,7 @@ Json::Value doLedgerData (RPC::Context& context)
limit = maxLimit;
jvResult[jss::ledger_hash] = to_string (lpLedger->getHash());
jvResult[jss::ledger_index] = std::to_string( lpLedger->getLedgerSeq ());
jvResult[jss::ledger_index] = std::to_string( lpLedger->info().seq);
Json::Value& nodes = (jvResult[jss::state] = Json::arrayValue);
auto& map = lpLedger->stateMap();

View File

@@ -62,7 +62,7 @@ Json::Value doLedgerRequest (RPC::Context& context)
auto ledgerIndex = jsonIndex.asInt();
auto ledger = ledgerMaster.getValidatedLedger();
if (ledgerIndex >= ledger->getLedgerSeq())
if (ledgerIndex >= ledger->info().seq)
return RPC::make_param_error("Ledger index too large");
auto const j = deprecatedLogs().journal("RPCHandler");
@@ -108,7 +108,7 @@ Json::Value doLedgerRequest (RPC::Context& context)
{
// We already have the ledger they want
Json::Value jvResult;
jvResult[jss::ledger_index] = ledger->getLedgerSeq();
jvResult[jss::ledger_index] = ledger->info().seq;
addJson (jvResult, {*ledger, 0});
return jvResult;
}

View File

@@ -50,7 +50,7 @@ isValidated (RPC::Context& context, std::uint32_t seq, uint256 const& hash)
if (!context.ledgerMaster.haveLedger (seq))
return false;
if (seq > context.ledgerMaster.getValidatedLedger ()->getLedgerSeq ())
if (seq > context.ledgerMaster.getValidatedLedger ()->info().seq)
return false;
return context.ledgerMaster.getHashBySeq (seq) == hash;
@@ -109,7 +109,7 @@ Json::Value doTx (RPC::Context& context)
if (okay)
ret[jss::validated] = isValidated (
context, lgr->getLedgerSeq (), lgr->getHash ());
context, lgr->info().seq, lgr->getHash ());
}
return ret;

View File

@@ -76,8 +76,8 @@ Status ledgerFromRequest (Ledger::pointer& ledger, Context& context)
if (ledger == nullptr)
return {rpcLGR_NOT_FOUND, "ledgerNotFound"};
if (ledger->getLedgerSeq () > ledgerMaster.getValidLedgerIndex () &&
isValidatedOld (ledgerMaster))
if (ledger->info().seq > ledgerMaster.getValidLedgerIndex() &&
isValidatedOld(ledgerMaster))
{
ledger.reset();
return {rpcNO_NETWORK, "InsufficientNetworkMode"};
@@ -95,19 +95,19 @@ Status ledgerFromRequest (Ledger::pointer& ledger, Context& context)
if (ledger == nullptr)
return {rpcNO_NETWORK, "InsufficientNetworkMode"};
assert (ledger->isClosed ());
assert (! ledger->info().open);
}
else
{
if (index.empty () || index == "current")
{
ledger = ledgerMaster.getCurrentLedger ();
assert (! ledger->isClosed ());
assert (ledger->info().open);
}
else if (index == "closed")
{
ledger = ledgerMaster.getClosedLedger ();
assert (ledger->isClosed ());
assert (! ledger->info().open);
}
else
{
@@ -117,7 +117,7 @@ Status ledgerFromRequest (Ledger::pointer& ledger, Context& context)
if (ledger == nullptr)
return {rpcNO_NETWORK, "InsufficientNetworkMode"};
if (ledger->getLedgerSeq () + minSequenceGap <
if (ledger->info().seq + minSequenceGap <
ledgerMaster.getValidLedgerIndex ())
{
ledger.reset ();
@@ -133,13 +133,13 @@ Status ledgerFromRequest (Ledger::pointer& ledger, Context& context)
bool isValidated (LedgerMaster& ledgerMaster, Ledger& ledger)
{
if (ledger.isValidated ())
if (ledger.info().validated)
return true;
if (!ledger.isClosed ())
if (ledger.info().open)
return false;
auto seq = ledger.getLedgerSeq();
auto seq = ledger.info().seq;
try
{
// Use the skip list in the last validated ledger to see if ledger
@@ -188,14 +188,14 @@ Status lookupLedger (
if (auto status = ledgerFromRequest (ledger, context))
return status;
if (ledger->isClosed ())
if (! ledger->info().open)
{
result[jss::ledger_hash] = to_string (ledger->getHash());
result[jss::ledger_index] = ledger->getLedgerSeq();
result[jss::ledger_index] = ledger->info().seq;
}
else
{
result[jss::ledger_current_index] = ledger->getLedgerSeq();
result[jss::ledger_current_index] = ledger->info().seq;
}
result[jss::validated] = isValidated (context.ledgerMaster, *ledger);