Switch some Ledger instances to ReadView instances

* Remove ltCURRENT
* Change getOwnerInfo
* Use ReadView in TransactionSign
* Change AcceptedLedger and ProposedTransaction to use ReadView
* Change RPC::accounts
This commit is contained in:
JoelKatz
2015-07-15 10:42:13 -07:00
committed by Edward Hennis
parent 2d02b46253
commit 36a62f110c
22 changed files with 126 additions and 256 deletions

View File

@@ -197,7 +197,8 @@ public:
//
Json::Value getOwnerInfo (
Ledger::pointer lpLedger, AccountID const& account) override;
std::shared_ptr<ReadView const> lpLedger,
AccountID const& account) override;
//
// Book functions.
@@ -334,7 +335,8 @@ public:
//
void pubLedger (Ledger::ref lpAccepted) override;
void pubProposedTransaction (
Ledger::ref lpCurrent, STTx::ref stTxn, TER terResult) override;
std::shared_ptr<ReadView const> const& lpCurrent,
STTx::ref stTxn, TER terResult) override;
//--------------------------------------------------------------------------
//
@@ -402,13 +404,13 @@ private:
Json::Value transJson (
const STTx& stTxn, TER terResult, bool bValidated,
Ledger::ref lpCurrent);
std::shared_ptr<ReadView const> const& lpCurrent);
bool haveConsensusObject ();
void pubValidatedTransaction (
Ledger::ref alAccepted, const AcceptedLedgerTx& alTransaction);
void pubAccountTransaction (
Ledger::ref lpCurrent, const AcceptedLedgerTx& alTransaction,
std::shared_ptr<ReadView const> const& lpCurrent, const AcceptedLedgerTx& alTransaction,
bool isAccepted);
void pubServer ();
@@ -1003,11 +1005,11 @@ void NetworkOPsImp::apply (std::unique_lock<std::mutex>& batchLock)
//
Json::Value NetworkOPsImp::getOwnerInfo (
Ledger::pointer lpLedger, AccountID const& account)
std::shared_ptr<ReadView const> lpLedger, AccountID const& account)
{
Json::Value jvObjects (Json::objectValue);
auto uRootIndex = getOwnerDirIndex (account);
auto sleNode = cachedRead(*lpLedger, uRootIndex, ltDIR_NODE);
auto sleNode = lpLedger->read (keylet::page (uRootIndex));
if (sleNode)
{
std::uint64_t uNodeDir;
@@ -1016,7 +1018,8 @@ Json::Value NetworkOPsImp::getOwnerInfo (
{
for (auto const& uDirEntry : sleNode->getFieldV256 (sfIndexes))
{
auto sleCur = cachedRead(*lpLedger, uDirEntry);
auto sleCur = lpLedger->read (keylet::child (uDirEntry));
assert (sleCur);
switch (sleCur->getType ())
{
@@ -1049,8 +1052,7 @@ Json::Value NetworkOPsImp::getOwnerInfo (
if (uNodeDir)
{
sleNode = cachedRead(*lpLedger, getDirNodeIndex(
uRootIndex, uNodeDir), ltDIR_NODE);
sleNode = lpLedger->read (keylet::page (uRootIndex, uNodeDir));
assert (sleNode);
}
}
@@ -2050,7 +2052,8 @@ Json::Value NetworkOPsImp::getLedgerFetchInfo ()
}
void NetworkOPsImp::pubProposedTransaction (
Ledger::ref lpCurrent, STTx::ref stTxn, TER terResult)
std::shared_ptr<ReadView const> const& lpCurrent,
STTx::ref stTxn, TER terResult)
{
Json::Value jvObj = transJson (*stTxn, terResult, false, lpCurrent);
@@ -2078,13 +2081,12 @@ void NetworkOPsImp::pubProposedTransaction (
pubAccountTransaction (lpCurrent, alt, false);
}
void NetworkOPsImp::pubLedger (Ledger::ref accepted)
void NetworkOPsImp::pubLedger (Ledger::ref lpAccepted)
{
// Ledgers are published only when they acquire sufficient validations
// Holes are filled across connection loss or other catastrophe
auto alpAccepted = AcceptedLedger::makeAcceptedLedger (accepted);
Ledger::ref lpAccepted = alpAccepted->getLedger ();
auto alpAccepted = AcceptedLedger::makeAcceptedLedger (lpAccepted);
{
ScopedLockType sl (mSubLock);
@@ -2151,7 +2153,7 @@ void NetworkOPsImp::reportFeeChange ()
// transactions.
Json::Value NetworkOPsImp::transJson(
const STTx& stTxn, TER terResult, bool bValidated,
Ledger::ref lpCurrent)
std::shared_ptr<ReadView const> const& lpCurrent)
{
Json::Value jvObj (Json::objectValue);
std::string sToken;
@@ -2165,8 +2167,8 @@ Json::Value NetworkOPsImp::transJson(
if (bValidated)
{
jvObj[jss::ledger_index] = lpCurrent->info().seq;
jvObj[jss::ledger_hash] = to_string (lpCurrent->getHash ());
jvObj[jss::transaction][jss::date] = lpCurrent->info().closeTime;
jvObj[jss::ledger_hash] = to_string (lpCurrent->info().hash);
jvObj[jss::transaction][jss::date] = lpCurrent->info().closeTime;
jvObj[jss::validated] = true;
// WRITEME: Put the account next seq here
@@ -2246,7 +2248,9 @@ void NetworkOPsImp::pubValidatedTransaction (
}
void NetworkOPsImp::pubAccountTransaction (
Ledger::ref lpCurrent, const AcceptedLedgerTx& alTx, bool bAccepted)
std::shared_ptr<ReadView const> const& lpCurrent,
const AcceptedLedgerTx& alTx,
bool bAccepted)
{
hash_set<InfoSub::pointer> notify;
int iProposed = 0;