mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
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:
@@ -31,25 +31,34 @@ TaggedCache <uint256, AcceptedLedger> AcceptedLedger::s_cache (
|
||||
"AcceptedLedger", 4, 60, stopwatch(),
|
||||
deprecatedLogs().journal("TaggedCache"));
|
||||
|
||||
AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
|
||||
AcceptedLedger::AcceptedLedger (std::shared_ptr<ReadView const> const& ledger)
|
||||
: mLedger (ledger)
|
||||
{
|
||||
for (auto const& item : ledger->txMap())
|
||||
for (auto const& item : ledger->txs)
|
||||
{
|
||||
SerialIter sit (item.slice());
|
||||
insert (std::make_shared<AcceptedLedgerTx>(
|
||||
ledger, std::ref (sit)));
|
||||
ledger, item.first, item.second));
|
||||
}
|
||||
}
|
||||
|
||||
AcceptedLedger::pointer AcceptedLedger::makeAcceptedLedger (Ledger::ref ledger)
|
||||
AcceptedLedger::pointer AcceptedLedger::makeAcceptedLedger (
|
||||
std::shared_ptr<ReadView const> const& ledger)
|
||||
{
|
||||
AcceptedLedger::pointer ret = s_cache.fetch (ledger->getHash());
|
||||
AcceptedLedger::pointer ret;
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
if (ledger->closed ())
|
||||
{
|
||||
ret = s_cache.fetch (ledger->info().hash);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = AcceptedLedger::pointer (new AcceptedLedger (ledger));
|
||||
s_cache.canonicalize (ledger->getHash (), ret);
|
||||
|
||||
if (ledger->closed ())
|
||||
s_cache.canonicalize (ledger->info().hash, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ public:
|
||||
using const_iterator = map_t::const_iterator;
|
||||
|
||||
public:
|
||||
static pointer makeAcceptedLedger (Ledger::ref ledger);
|
||||
static pointer makeAcceptedLedger (std::shared_ptr<ReadView const> const& ledger);
|
||||
static void sweep ()
|
||||
{
|
||||
s_cache.sweep ();
|
||||
}
|
||||
|
||||
Ledger::ref getLedger () const
|
||||
std::shared_ptr<ReadView const> const& getLedger () const
|
||||
{
|
||||
return mLedger;
|
||||
}
|
||||
@@ -78,15 +78,15 @@ public:
|
||||
AcceptedLedgerTx::pointer getTxn (int) const;
|
||||
|
||||
private:
|
||||
explicit AcceptedLedger (Ledger::ref ledger);
|
||||
explicit AcceptedLedger (std::shared_ptr<ReadView const> const& ledger);
|
||||
|
||||
void insert (AcceptedLedgerTx::ref);
|
||||
|
||||
private:
|
||||
static TaggedCache <uint256, AcceptedLedger> s_cache;
|
||||
|
||||
Ledger::pointer mLedger;
|
||||
map_t mMap;
|
||||
std::shared_ptr<ReadView const> mLedger;
|
||||
map_t mMap;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -26,40 +26,36 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger, SerialIter& sit)
|
||||
: mLedger (ledger)
|
||||
{
|
||||
// VFALCO This is making a needless copy
|
||||
auto const vl = sit.getVL();
|
||||
SerialIter txnIt (makeSlice(vl));
|
||||
|
||||
mTxn = std::make_shared<STTx> (std::ref (txnIt));
|
||||
mRawMeta = sit.getVL ();
|
||||
mMeta = std::make_shared<TxMeta> (mTxn->getTransactionID (),
|
||||
ledger->info().seq, mRawMeta);
|
||||
mAffected = mMeta->getAffectedAccounts ();
|
||||
mResult = mMeta->getResultTER ();
|
||||
buildJson ();
|
||||
}
|
||||
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger,
|
||||
STTx::ref txn, TxMeta::ref met)
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
std::shared_ptr<STTx const> const& txn,
|
||||
std::shared_ptr<STObject const> const& met)
|
||||
: mLedger (ledger)
|
||||
, mTxn (txn)
|
||||
, mMeta (met)
|
||||
, mAffected (met->getAffectedAccounts ())
|
||||
, mMeta (std::make_shared<TxMeta> (
|
||||
txn->getTransactionID(), ledger->seq(), *met))
|
||||
, mAffected (mMeta->getAffectedAccounts ())
|
||||
{
|
||||
assert (! ledger->info().open);
|
||||
|
||||
mResult = mMeta->getResultTER ();
|
||||
|
||||
Serializer s;
|
||||
met->add(s);
|
||||
mRawMeta = std::move (s.modData());
|
||||
|
||||
buildJson ();
|
||||
}
|
||||
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (Ledger::ref ledger,
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
STTx::ref txn, TER result)
|
||||
: mLedger (ledger)
|
||||
, mTxn (txn)
|
||||
, mResult (result)
|
||||
, mAffected (txn->getMentionedAccounts ())
|
||||
{
|
||||
assert (ledger->info().open);
|
||||
buildJson ();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,16 +51,17 @@ public:
|
||||
using ref = const pointer&;
|
||||
|
||||
public:
|
||||
AcceptedLedgerTx (Ledger::ref ledger, SerialIter& sit);
|
||||
AcceptedLedgerTx (Ledger::ref ledger, STTx::ref,
|
||||
TxMeta::ref);
|
||||
AcceptedLedgerTx (Ledger::ref ledger, STTx::ref, TER result);
|
||||
AcceptedLedgerTx (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
std::shared_ptr<STTx const> const&,
|
||||
std::shared_ptr<STObject const> const&);
|
||||
AcceptedLedgerTx (std::shared_ptr<ReadView const> const& ledger, STTx::ref, TER result);
|
||||
|
||||
STTx::ref getTxn () const
|
||||
std::shared_ptr <STTx const> const& getTxn () const
|
||||
{
|
||||
return mTxn;
|
||||
}
|
||||
TxMeta::ref getMeta () const
|
||||
std::shared_ptr <TxMeta> const& getMeta () const
|
||||
{
|
||||
return mMeta;
|
||||
}
|
||||
@@ -103,9 +104,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Ledger::pointer mLedger;
|
||||
STTx::pointer mTxn;
|
||||
TxMeta::pointer mMeta;
|
||||
std::shared_ptr<ReadView const> mLedger;
|
||||
std::shared_ptr<STTx const> mTxn;
|
||||
std::shared_ptr<TxMeta> mMeta;
|
||||
TER mResult;
|
||||
boost::container::flat_set<AccountID> mAffected;
|
||||
Blob mRawMeta;
|
||||
|
||||
@@ -1430,115 +1430,4 @@ Ledger::getNeededAccountStateHashes (
|
||||
return ret;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Transaction::pointer
|
||||
getTransaction (Ledger const& ledger,
|
||||
uint256 const& transID, TransactionMaster& cache)
|
||||
{
|
||||
SHAMapTreeNode::TNType type;
|
||||
auto const item =
|
||||
ledger.txMap().peekItem (transID, type);
|
||||
|
||||
if (!item)
|
||||
return Transaction::pointer ();
|
||||
|
||||
auto txn = cache.fetch (transID, false);
|
||||
|
||||
if (txn)
|
||||
return txn;
|
||||
|
||||
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
|
||||
{
|
||||
txn = Transaction::sharedTransaction (item->peekData (), Validate::YES);
|
||||
}
|
||||
else if (type == SHAMapTreeNode::tnTRANSACTION_MD)
|
||||
{
|
||||
auto sit = SerialIter{item->data(), item->size()};
|
||||
txn = Transaction::sharedTransaction(sit.getVL(), Validate::NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (false);
|
||||
return Transaction::pointer ();
|
||||
}
|
||||
|
||||
if (txn->getStatus () == NEW)
|
||||
{
|
||||
txn->setStatus (
|
||||
ledger.info().open ? INCLUDED : COMMITTED, ledger.info().seq);
|
||||
}
|
||||
|
||||
cache.canonicalize (&txn);
|
||||
return txn;
|
||||
}
|
||||
|
||||
bool
|
||||
getTransaction (Ledger const& ledger,
|
||||
uint256 const& txID, Transaction::pointer& txn,
|
||||
TxMeta::pointer& meta,
|
||||
TransactionMaster& cache)
|
||||
{
|
||||
SHAMapTreeNode::TNType type;
|
||||
auto const item =
|
||||
ledger.txMap().peekItem (txID, type);
|
||||
if (!item)
|
||||
return false;
|
||||
|
||||
if (type == SHAMapTreeNode::tnTRANSACTION_NM)
|
||||
{
|
||||
// in tree with no metadata
|
||||
txn = cache.fetch (txID, false);
|
||||
meta.reset ();
|
||||
|
||||
if (!txn)
|
||||
{
|
||||
txn = Transaction::sharedTransaction (
|
||||
item->peekData (), Validate::YES);
|
||||
}
|
||||
}
|
||||
else if (type == SHAMapTreeNode::tnTRANSACTION_MD)
|
||||
{
|
||||
// in tree with metadata
|
||||
SerialIter it (item->slice());
|
||||
txn = getApp().getMasterTransaction ().fetch (txID, false);
|
||||
|
||||
if (!txn)
|
||||
txn = Transaction::sharedTransaction (it.getVL (), Validate::YES);
|
||||
else
|
||||
it.getVL (); // skip transaction
|
||||
|
||||
meta = std::make_shared<TxMeta> (
|
||||
txID, ledger.seq(), it.getVL ());
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
if (txn->getStatus () == NEW)
|
||||
txn->setStatus (ledger.info().open ? INCLUDED : COMMITTED, ledger.seq());
|
||||
|
||||
cache.canonicalize (&txn);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getTransactionMeta (Ledger const& ledger,
|
||||
uint256 const& txID, TxMeta::pointer& meta)
|
||||
{
|
||||
SHAMapTreeNode::TNType type;
|
||||
auto const item =
|
||||
ledger.txMap().peekItem (txID, type);
|
||||
|
||||
if (!item)
|
||||
return false;
|
||||
|
||||
if (type != SHAMapTreeNode::tnTRANSACTION_MD)
|
||||
return false;
|
||||
|
||||
SerialIter it (item->slice());
|
||||
it.getVL (); // skip transaction
|
||||
meta = std::make_shared<TxMeta> (txID, ledger.seq(), it.getVL ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -475,23 +475,6 @@ cachedRead (ReadView const& ledger, uint256 const& key,
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// VFALCO NOTE This is called from only one place
|
||||
Transaction::pointer
|
||||
getTransaction (Ledger const& ledger,
|
||||
uint256 const& transID, TransactionMaster& cache);
|
||||
|
||||
// VFALCO NOTE This is called from only one place
|
||||
bool
|
||||
getTransaction (Ledger const& ledger,
|
||||
uint256 const& transID, Transaction::pointer & txn,
|
||||
TxMeta::pointer & txMeta,
|
||||
TransactionMaster& cache);
|
||||
|
||||
bool
|
||||
getTransactionMeta (Ledger const&,
|
||||
uint256 const& transID,
|
||||
TxMeta::pointer & txMeta);
|
||||
|
||||
void
|
||||
ownerDirDescriber (SLE::ref, bool, AccountID const& owner);
|
||||
|
||||
|
||||
@@ -134,8 +134,7 @@ static
|
||||
void
|
||||
log_one(Ledger::pointer ledger, uint256 const& tx, char const* msg)
|
||||
{
|
||||
TxMeta::pointer metaData;
|
||||
getTransactionMeta(*ledger, tx, metaData);
|
||||
auto metaData = ledger->txRead(tx).second;
|
||||
|
||||
if (metaData != nullptr)
|
||||
{
|
||||
@@ -155,10 +154,17 @@ void
|
||||
log_metadata_difference(Ledger::pointer builtLedger, Ledger::pointer validLedger,
|
||||
uint256 const& tx)
|
||||
{
|
||||
TxMeta::pointer validMetaData;
|
||||
getTransactionMeta(*validLedger, tx, validMetaData);
|
||||
TxMeta::pointer builtMetaData;
|
||||
getTransactionMeta(*builtLedger, tx, builtMetaData);
|
||||
auto getMeta = [](Ledger const& ledger,
|
||||
uint256 const& txID) -> std::shared_ptr<TxMeta>
|
||||
{
|
||||
auto meta = ledger.txRead(txID).second;
|
||||
if (!meta)
|
||||
return {};
|
||||
return std::make_shared<TxMeta> (txID, ledger.seq(), *meta);
|
||||
};
|
||||
|
||||
auto validMetaData = getMeta (*validLedger, tx);
|
||||
auto builtMetaData = getMeta (*builtLedger, tx);
|
||||
assert(validMetaData != nullptr || builtMetaData != nullptr);
|
||||
|
||||
if (validMetaData != nullptr && builtMetaData != nullptr)
|
||||
|
||||
@@ -1327,12 +1327,11 @@ bool ApplicationImp::loadOldLedger (
|
||||
for (auto const& item : txns)
|
||||
{
|
||||
auto const txn =
|
||||
getTransaction(*replayLedger, item.key(),
|
||||
getApp().getMasterTransaction());
|
||||
replayLedger->txRead(item.key()).first;
|
||||
if (m_journal.info) m_journal.info <<
|
||||
txn->getJson(0);
|
||||
Serializer s;
|
||||
txn->getSTransaction()->add(s);
|
||||
txn->add(s);
|
||||
cur->rawTxInsert(item.key(),
|
||||
std::make_shared<Serializer const>(
|
||||
std::move(s)), nullptr);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
// Owner functions
|
||||
//
|
||||
|
||||
virtual Json::Value getOwnerInfo (Ledger::pointer lpLedger,
|
||||
virtual Json::Value getOwnerInfo (std::shared_ptr<ReadView const> lpLedger,
|
||||
AccountID const& account) = 0;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -227,7 +227,8 @@ public:
|
||||
// Monitoring: publisher side
|
||||
//
|
||||
virtual void pubLedger (Ledger::ref lpAccepted) = 0;
|
||||
virtual void pubProposedTransaction (Ledger::ref lpCurrent,
|
||||
virtual void pubProposedTransaction (
|
||||
std::shared_ptr<ReadView const> const& lpCurrent,
|
||||
STTx::ref stTxn, TER terResult) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
|
||||
TxMeta (uint256 const& txID, std::uint32_t ledger, Blob const&);
|
||||
TxMeta (uint256 const& txID, std::uint32_t ledger, std::string const&);
|
||||
TxMeta (uint256 const& txID, std::uint32_t ledger, STObject const&);
|
||||
|
||||
void init (uint256 const& transactionID, std::uint32_t ledger);
|
||||
void clear ()
|
||||
|
||||
@@ -46,6 +46,24 @@ TxMeta::TxMeta (uint256 const& txid,
|
||||
setDeliveredAmount (obj.getFieldAmount (sfDeliveredAmount));
|
||||
}
|
||||
|
||||
TxMeta::TxMeta (uint256 const& txid, std::uint32_t ledger, STObject const& obj)
|
||||
: mTransactionID (txid)
|
||||
, mLedger (ledger)
|
||||
, mNodes (obj.getFieldArray (sfAffectedNodes))
|
||||
{
|
||||
mResult = obj.getFieldU8 (sfTransactionResult);
|
||||
mIndex = obj.getFieldU32 (sfTransactionIndex);
|
||||
|
||||
auto affectedNodes = dynamic_cast <STArray const*>
|
||||
(obj.peekAtPField (sfAffectedNodes));
|
||||
assert (affectedNodes);
|
||||
if (affectedNodes)
|
||||
mNodes = *affectedNodes;
|
||||
|
||||
if (obj.isFieldPresent (sfDeliveredAmount))
|
||||
setDeliveredAmount (obj.getFieldAmount (sfDeliveredAmount));
|
||||
}
|
||||
|
||||
TxMeta::TxMeta (uint256 const& txid,
|
||||
std::uint32_t ledger,
|
||||
Blob const& vec)
|
||||
|
||||
@@ -2022,10 +2022,6 @@ PeerImp::getLedger (std::shared_ptr<protocol::TMGetLedger> const& m)
|
||||
if (p_journal_.debug) p_journal_.debug <<
|
||||
"GetLedger: Don't have " << packet.ledgerseq ();
|
||||
}
|
||||
else if (packet.has_ltype () && (packet.ltype () == protocol::ltCURRENT))
|
||||
{
|
||||
ledger = getApp().getLedgerMaster ().getCurrentLedger ();
|
||||
}
|
||||
else if (packet.has_ltype () && (packet.ltype () == protocol::ltCLOSED) )
|
||||
{
|
||||
ledger = getApp().getLedgerMaster ().getClosedLedger ();
|
||||
|
||||
@@ -299,7 +299,7 @@ enum TMLedgerInfoType
|
||||
enum TMLedgerType
|
||||
{
|
||||
ltACCEPTED = 0;
|
||||
ltCURRENT = 1;
|
||||
ltCURRENT = 1; // no longer supported
|
||||
ltCLOSED = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
AccountID raSrc;
|
||||
AccountID raDst;
|
||||
STAmount saDstAmount;
|
||||
Ledger::pointer lpLedger;
|
||||
std::shared_ptr <ReadView const> lpLedger;
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
@@ -88,7 +88,7 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
context.params.isMember(jss::ledger_hash))
|
||||
{
|
||||
// The caller specified a ledger
|
||||
jvResult = RPC::lookupLedgerDeprecated (lpLedger, context);
|
||||
jvResult = RPC::lookupLedger (lpLedger, context);
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
}
|
||||
@@ -170,7 +170,6 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
if (lpLedger)
|
||||
{
|
||||
// The caller specified a ledger
|
||||
lpLedger = std::make_shared<Ledger> (std::ref (*lpLedger), false);
|
||||
cache = std::make_shared<RippleLineCache>(lpLedger);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace ripple {
|
||||
// means any ledger.
|
||||
Json::Value doTransactionEntry (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedgerDeprecated (lpLedger, context);
|
||||
std::shared_ptr <ReadView const> lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (lpLedger, context);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
@@ -68,16 +68,16 @@ Json::Value doTransactionEntry (RPC::Context& context)
|
||||
Transaction::pointer tpTrans;
|
||||
TxMeta::pointer tmTrans;
|
||||
|
||||
if (!getTransaction (*lpLedger, uTransID, tpTrans, tmTrans,
|
||||
getApp().getMasterTransaction()))
|
||||
auto tx = lpLedger->txRead (uTransID);
|
||||
if (!tx.first)
|
||||
{
|
||||
jvResult[jss::error] = "transactionNotFound";
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult[jss::tx_json] = tpTrans->getJson (0);
|
||||
if (tmTrans)
|
||||
jvResult[jss::metadata] = tmTrans->getJson (0);
|
||||
jvResult[jss::tx_json] = tx.first->getJson (0);
|
||||
if (tx.second)
|
||||
jvResult[jss::metadata] = tx.second->getJson (0);
|
||||
// 'accounts'
|
||||
// 'engine_...'
|
||||
// 'ledger_...'
|
||||
|
||||
@@ -123,10 +123,10 @@ Json::Value doTx (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
TxMeta::pointer txMeta;
|
||||
|
||||
if (getTransactionMeta (*lgr, txn->getID (), txMeta))
|
||||
auto rawMeta = lgr->txRead (txn->getID()).second;
|
||||
if (rawMeta)
|
||||
{
|
||||
auto txMeta = std::make_shared <TxMeta> (txn->getID(), lgr->seq(), *rawMeta);
|
||||
okay = true;
|
||||
auto meta = txMeta->getJson (0);
|
||||
addPaymentDeliveredAmount (meta, context, txn, txMeta);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
Json::Value accounts (
|
||||
Ledger::ref lrLedger,
|
||||
std::shared_ptr <ReadView const> const& lrLedger,
|
||||
RippleAddress const& naMasterGenerator,
|
||||
NetworkOPs& netOps)
|
||||
{
|
||||
@@ -44,8 +44,8 @@ Json::Value accounts (
|
||||
RippleAddress pk;
|
||||
pk.setAccountPublic (naMasterGenerator, uIndex++);
|
||||
|
||||
auto const sle = cachedRead(*lrLedger,
|
||||
keylet::account(calcAccountID(pk)).key, ltACCOUNT_ROOT);
|
||||
auto const sle =
|
||||
lrLedger->read (keylet::account(calcAccountID(pk)));
|
||||
|
||||
if (sle)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ class NetworkOPs;
|
||||
namespace RPC {
|
||||
|
||||
Json::Value accounts (
|
||||
Ledger::ref lrLedger,
|
||||
std::shared_ptr <ReadView const> const& lrLedger,
|
||||
RippleAddress const& naMasterGenerator,
|
||||
NetworkOPs& netOps);
|
||||
|
||||
|
||||
@@ -188,28 +188,6 @@ bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger)
|
||||
// return value. Otherwise, the object contains the field "validated" and
|
||||
// optionally the fields "ledger_hash", "ledger_index" and
|
||||
// "ledger_current_index", if they are defined.
|
||||
Status lookupLedgerDeprecated (
|
||||
Ledger::pointer& ledger, Context& context, Json::Value& result)
|
||||
{
|
||||
if (auto status = ledgerFromRequest (ledger, context))
|
||||
return status;
|
||||
|
||||
auto& info = ledger->info();
|
||||
|
||||
if (!info.open)
|
||||
{
|
||||
result[jss::ledger_hash] = to_string (info.hash);
|
||||
result[jss::ledger_index] = info.seq;
|
||||
}
|
||||
else
|
||||
{
|
||||
result[jss::ledger_current_index] = info.seq;
|
||||
}
|
||||
|
||||
result[jss::validated] = getApp().getLedgerMaster().isValidLedger(info);
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Status lookupLedger (
|
||||
std::shared_ptr<ReadView const>& ledger, Context& context,
|
||||
Json::Value& result)
|
||||
@@ -233,15 +211,6 @@ Status lookupLedger (
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
Json::Value lookupLedgerDeprecated (Ledger::pointer& ledger, Context& context)
|
||||
{
|
||||
Json::Value result;
|
||||
if (auto status = lookupLedgerDeprecated (ledger, context, result))
|
||||
status.inject (result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Json::Value lookupLedger (
|
||||
std::shared_ptr<ReadView const>& ledger, Context& context)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,6 @@ struct Context;
|
||||
If there is no error in the return value, then the ledger pointer will have
|
||||
been filled.
|
||||
*/
|
||||
Json::Value lookupLedgerDeprecated (Ledger::pointer&, Context&);
|
||||
Json::Value lookupLedger (std::shared_ptr<ReadView const>&, Context&);
|
||||
|
||||
/** Look up a ledger from a request and fill a Json::Result with the data
|
||||
|
||||
@@ -35,7 +35,7 @@ class TxnSignApiFacade
|
||||
{
|
||||
private:
|
||||
NetworkOPs* const netOPs_;
|
||||
Ledger::pointer ledger_;
|
||||
std::shared_ptr<ReadView const> ledger_;
|
||||
AccountID accountID_;
|
||||
std::shared_ptr<SLE const> sle_;
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
: netOPs_ (nullptr) { }
|
||||
|
||||
// For testAutoFillFees unit tests.
|
||||
TxnSignApiFacade (NoNetworkOPs noOPs, Ledger::pointer ledger)
|
||||
TxnSignApiFacade (NoNetworkOPs noOPs, std::shared_ptr<ReadView const> ledger)
|
||||
: netOPs_ (nullptr)
|
||||
, ledger_ (ledger)
|
||||
{ }
|
||||
|
||||
Reference in New Issue
Block a user