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

@@ -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 ());