mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-29 00:08:10 +00:00
Inject Application (cont.)
This commit is contained in:
committed by
Edward Hennis
parent
eed1a891a7
commit
ffbcb96eff
@@ -24,13 +24,15 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
AcceptedLedger::AcceptedLedger (std::shared_ptr<ReadView const> const& ledger)
|
||||
AcceptedLedger::AcceptedLedger (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
AccountIDCache const& accountCache)
|
||||
: mLedger (ledger)
|
||||
{
|
||||
for (auto const& item : ledger->txs)
|
||||
{
|
||||
insert (std::make_shared<AcceptedLedgerTx>(
|
||||
ledger, item.first, item.second));
|
||||
ledger, item.first, item.second, accountCache));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define RIPPLE_APP_LEDGER_ACCEPTEDLEDGER_H_INCLUDED
|
||||
|
||||
#include <ripple/app/ledger/AcceptedLedgerTx.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -67,11 +68,11 @@ public:
|
||||
|
||||
AcceptedLedgerTx::pointer getTxn (int) const;
|
||||
|
||||
explicit AcceptedLedger (std::shared_ptr<ReadView const> const& ledger);
|
||||
|
||||
AcceptedLedger (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
AccountIDCache const& accountCache);
|
||||
|
||||
private:
|
||||
|
||||
void insert (AcceptedLedgerTx::ref);
|
||||
|
||||
std::shared_ptr<ReadView const> mLedger;
|
||||
|
||||
@@ -29,12 +29,14 @@ namespace ripple {
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
std::shared_ptr<STTx const> const& txn,
|
||||
std::shared_ptr<STObject const> const& met)
|
||||
std::shared_ptr<STObject const> const& met,
|
||||
AccountIDCache const& accountCache)
|
||||
: mLedger (ledger)
|
||||
, mTxn (txn)
|
||||
, mMeta (std::make_shared<TxMeta> (
|
||||
txn->getTransactionID(), ledger->seq(), *met))
|
||||
, mAffected (mMeta->getAffectedAccounts ())
|
||||
, accountCache_ (accountCache)
|
||||
{
|
||||
assert (! ledger->info().open);
|
||||
|
||||
@@ -49,11 +51,14 @@ AcceptedLedgerTx::AcceptedLedgerTx (
|
||||
|
||||
AcceptedLedgerTx::AcceptedLedgerTx (
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
STTx::ref txn, TER result)
|
||||
STTx::ref txn,
|
||||
TER result,
|
||||
AccountIDCache const& accountCache)
|
||||
: mLedger (ledger)
|
||||
, mTxn (txn)
|
||||
, mResult (result)
|
||||
, mAffected (txn->getMentionedAccounts ())
|
||||
, accountCache_ (accountCache)
|
||||
{
|
||||
assert (ledger->info().open);
|
||||
buildJson ();
|
||||
@@ -82,7 +87,7 @@ void AcceptedLedgerTx::buildJson ()
|
||||
{
|
||||
Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
|
||||
for (auto const& account: mAffected)
|
||||
affected.append (getApp().accountIDCache().toBase58(account));
|
||||
affected.append (accountCache_.toBase58(account));
|
||||
}
|
||||
|
||||
if (mTxn->getTxnType () == ttOFFER_CREATE)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define RIPPLE_APP_LEDGER_ACCEPTEDLEDGERTX_H_INCLUDED
|
||||
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
|
||||
namespace ripple {
|
||||
@@ -54,8 +55,13 @@ public:
|
||||
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&, STTx::ref, TER);
|
||||
std::shared_ptr<STObject const> const&,
|
||||
AccountIDCache const&);
|
||||
AcceptedLedgerTx (
|
||||
std::shared_ptr<ReadView const> const&,
|
||||
STTx::ref,
|
||||
TER,
|
||||
AccountIDCache const&);
|
||||
|
||||
std::shared_ptr <STTx const> const& getTxn () const
|
||||
{
|
||||
@@ -111,6 +117,7 @@ private:
|
||||
boost::container::flat_set<AccountID> mAffected;
|
||||
Blob mRawMeta;
|
||||
Json::Value mJson;
|
||||
AccountIDCache const& accountCache_;
|
||||
|
||||
void buildJson ();
|
||||
};
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/core/JobQueue.h>
|
||||
#include <ripple/core/SociDB.h>
|
||||
#include <ripple/core/TimeKeeper.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <ripple/protocol/digest.h>
|
||||
@@ -170,12 +169,12 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Ledger::Ledger (create_genesis_t, Config const& config)
|
||||
Ledger::Ledger (create_genesis_t, Config const& config, Family& family)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||
family, deprecatedLogs().journal("SHAMap")))
|
||||
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE,
|
||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||
family, deprecatedLogs().journal("SHAMap")))
|
||||
{
|
||||
info_.seq = 1;
|
||||
info_.drops = SYSTEM_CURRENCY_START;
|
||||
@@ -205,13 +204,14 @@ Ledger::Ledger (uint256 const& parentHash,
|
||||
int closeResolution,
|
||||
std::uint32_t ledgerSeq,
|
||||
bool& loaded,
|
||||
Config const& config)
|
||||
Config const& config,
|
||||
Family& family)
|
||||
: mImmutable (true)
|
||||
, txMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, transHash, getApp().family(),
|
||||
SHAMapType::TRANSACTION, transHash, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE, accountHash,
|
||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||
family, deprecatedLogs().journal("SHAMap")))
|
||||
{
|
||||
info_.seq = ledgerSeq;
|
||||
info_.parentCloseTime = parentCloseTime;
|
||||
@@ -256,10 +256,11 @@ Ledger::Ledger (Ledger const& ledger,
|
||||
}
|
||||
|
||||
// Create a new open ledger that follows this one
|
||||
Ledger::Ledger (open_ledger_t, Ledger const& prevLedger)
|
||||
Ledger::Ledger (open_ledger_t, Ledger const& prevLedger,
|
||||
NetClock::time_point closeTime)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||
prevLedger.stateMap_->family(), deprecatedLogs().journal("SHAMap")))
|
||||
, stateMap_ (prevLedger.stateMap_->snapShot (true))
|
||||
, fees_(prevLedger.fees_)
|
||||
{
|
||||
@@ -274,11 +275,10 @@ Ledger::Ledger (open_ledger_t, Ledger const& prevLedger)
|
||||
info_.closeTimeResolution = getNextLedgerTimeResolution (
|
||||
prevLedger.info_.closeTimeResolution,
|
||||
getCloseAgree(prevLedger.info()), info_.seq);
|
||||
// VFALCO Remove this call to getApp
|
||||
if (prevLedger.info_.closeTime == 0)
|
||||
{
|
||||
info_.closeTime = roundCloseTime (
|
||||
getApp().timeKeeper().closeTime().time_since_epoch().count(),
|
||||
closeTime.time_since_epoch().count(),
|
||||
info_.closeTimeResolution);
|
||||
}
|
||||
else
|
||||
@@ -290,28 +290,29 @@ Ledger::Ledger (open_ledger_t, Ledger const& prevLedger)
|
||||
|
||||
Ledger::Ledger (void const* data,
|
||||
std::size_t size, bool hasPrefix,
|
||||
Config const& config)
|
||||
Config const& config, Family& family)
|
||||
: mImmutable (true)
|
||||
, txMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, getApp().family(),
|
||||
SHAMapType::TRANSACTION, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
, stateMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::STATE, getApp().family(),
|
||||
SHAMapType::STATE, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
{
|
||||
SerialIter sit (data, size);
|
||||
setRaw (sit, hasPrefix);
|
||||
setRaw (sit, hasPrefix, family);
|
||||
// Can't set up until the stateMap is filled in
|
||||
}
|
||||
|
||||
Ledger::Ledger (std::uint32_t ledgerSeq,
|
||||
std::uint32_t closeTime, Config const& config)
|
||||
std::uint32_t closeTime, Config const& config,
|
||||
Family& family)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, getApp().family(),
|
||||
SHAMapType::TRANSACTION, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
, stateMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::STATE, getApp().family(),
|
||||
SHAMapType::STATE, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
{
|
||||
info_.seq = ledgerSeq;
|
||||
@@ -370,7 +371,7 @@ void Ledger::updateHash()
|
||||
mValidHash = true;
|
||||
}
|
||||
|
||||
void Ledger::setRaw (SerialIter& sit, bool hasPrefix)
|
||||
void Ledger::setRaw (SerialIter& sit, bool hasPrefix, Family& family)
|
||||
{
|
||||
if (hasPrefix)
|
||||
sit.get32 ();
|
||||
@@ -386,9 +387,9 @@ void Ledger::setRaw (SerialIter& sit, bool hasPrefix)
|
||||
info_.closeFlags = sit.get8 ();
|
||||
updateHash ();
|
||||
txMap_ = std::make_shared<SHAMap> (SHAMapType::TRANSACTION, info_.txHash,
|
||||
getApp().family(), deprecatedLogs().journal("SHAMap"));
|
||||
family, deprecatedLogs().journal("SHAMap"));
|
||||
stateMap_ = std::make_shared<SHAMap> (SHAMapType::STATE, info_.accountHash,
|
||||
getApp().family(), deprecatedLogs().journal("SHAMap"));
|
||||
family, deprecatedLogs().journal("SHAMap"));
|
||||
}
|
||||
|
||||
void Ledger::addRaw (Serializer& s) const
|
||||
@@ -448,227 +449,6 @@ deserializeTxPlusMeta (SHAMapItem const& item)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a ledger from the database.
|
||||
*
|
||||
* @param sqlSuffix: Additional string to append to the sql query.
|
||||
* (typically a where clause).
|
||||
* @return The ledger, ledger sequence, and ledger hash.
|
||||
*/
|
||||
std::tuple<Ledger::pointer, std::uint32_t, uint256>
|
||||
loadLedgerHelper(std::string const& sqlSuffix)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
uint256 ledgerHash{};
|
||||
std::uint32_t ledgerSeq{0};
|
||||
|
||||
auto db = getApp ().getLedgerDB ().checkoutDb ();
|
||||
|
||||
boost::optional<std::string> sLedgerHash, sPrevHash, sAccountHash,
|
||||
sTransHash;
|
||||
boost::optional<std::uint64_t> totDrops, closingTime, prevClosingTime,
|
||||
closeResolution, closeFlags, ledgerSeq64;
|
||||
|
||||
std::string const sql =
|
||||
"SELECT "
|
||||
"LedgerHash, PrevHash, AccountSetHash, TransSetHash, "
|
||||
"TotalCoins,"
|
||||
"ClosingTime, PrevClosingTime, CloseTimeRes, CloseFlags,"
|
||||
"LedgerSeq from Ledgers " +
|
||||
sqlSuffix + ";";
|
||||
|
||||
*db << sql,
|
||||
soci::into(sLedgerHash),
|
||||
soci::into(sPrevHash),
|
||||
soci::into(sAccountHash),
|
||||
soci::into(sTransHash),
|
||||
soci::into(totDrops),
|
||||
soci::into(closingTime),
|
||||
soci::into(prevClosingTime),
|
||||
soci::into(closeResolution),
|
||||
soci::into(closeFlags),
|
||||
soci::into(ledgerSeq64);
|
||||
|
||||
if (!db->got_data ())
|
||||
{
|
||||
WriteLog (lsDEBUG, Ledger) << "Ledger not found: " << sqlSuffix;
|
||||
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
|
||||
}
|
||||
|
||||
ledgerSeq =
|
||||
rangeCheckedCast<std::uint32_t>(ledgerSeq64.value_or (0));
|
||||
|
||||
uint256 prevHash{}, accountHash{}, transHash{};
|
||||
if (sLedgerHash)
|
||||
ledgerHash.SetHexExact (*sLedgerHash);
|
||||
if (sPrevHash)
|
||||
prevHash.SetHexExact (*sPrevHash);
|
||||
if (sAccountHash)
|
||||
accountHash.SetHexExact (*sAccountHash);
|
||||
if (sTransHash)
|
||||
transHash.SetHexExact (*sTransHash);
|
||||
|
||||
bool loaded = false;
|
||||
ledger = std::make_shared<Ledger>(prevHash,
|
||||
transHash,
|
||||
accountHash,
|
||||
totDrops.value_or(0),
|
||||
closingTime.value_or(0),
|
||||
prevClosingTime.value_or(0),
|
||||
closeFlags.value_or(0),
|
||||
closeResolution.value_or(0),
|
||||
ledgerSeq,
|
||||
loaded,
|
||||
getConfig());
|
||||
|
||||
if (!loaded)
|
||||
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
|
||||
|
||||
return std::make_tuple (ledger, ledgerSeq, ledgerHash);
|
||||
}
|
||||
|
||||
void finishLoadByIndexOrHash(Ledger::pointer& ledger)
|
||||
{
|
||||
if (!ledger)
|
||||
return;
|
||||
|
||||
ledger->setClosed ();
|
||||
ledger->setImmutable ();
|
||||
|
||||
WriteLog (lsTRACE, Ledger)
|
||||
<< "Loaded ledger: " << to_string (ledger->getHash ());
|
||||
|
||||
ledger->setFull ();
|
||||
}
|
||||
|
||||
Ledger::pointer Ledger::loadByIndex (std::uint32_t ledgerIndex)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "WHERE LedgerSeq = " << ledgerIndex;
|
||||
std::tie (ledger, std::ignore, std::ignore) =
|
||||
loadLedgerHelper (s.str ());
|
||||
}
|
||||
|
||||
finishLoadByIndexOrHash (ledger);
|
||||
return ledger;
|
||||
}
|
||||
|
||||
Ledger::pointer Ledger::loadByHash (uint256 const& ledgerHash)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "WHERE LedgerHash = '" << ledgerHash << "'";
|
||||
std::tie (ledger, std::ignore, std::ignore) =
|
||||
loadLedgerHelper (s.str ());
|
||||
}
|
||||
|
||||
finishLoadByIndexOrHash (ledger);
|
||||
|
||||
assert (!ledger || ledger->getHash () == ledgerHash);
|
||||
|
||||
return ledger;
|
||||
}
|
||||
|
||||
uint256 Ledger::getHashByIndex (std::uint32_t ledgerIndex)
|
||||
{
|
||||
uint256 ret;
|
||||
|
||||
std::string sql =
|
||||
"SELECT LedgerHash FROM Ledgers INDEXED BY SeqLedger WHERE LedgerSeq='";
|
||||
sql.append (beast::lexicalCastThrow <std::string> (ledgerIndex));
|
||||
sql.append ("';");
|
||||
|
||||
std::string hash;
|
||||
{
|
||||
auto db = getApp().getLedgerDB ().checkoutDb ();
|
||||
|
||||
boost::optional<std::string> lh;
|
||||
*db << sql,
|
||||
soci::into (lh);
|
||||
|
||||
if (!db->got_data () || !lh)
|
||||
return ret;
|
||||
|
||||
hash = *lh;
|
||||
if (hash.empty ())
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.SetHexExact (hash);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Ledger::getHashesByIndex (
|
||||
std::uint32_t ledgerIndex, uint256& ledgerHash, uint256& parentHash)
|
||||
{
|
||||
auto db = getApp().getLedgerDB ().checkoutDb ();
|
||||
|
||||
boost::optional <std::string> lhO, phO;
|
||||
|
||||
*db << "SELECT LedgerHash,PrevHash FROM Ledgers "
|
||||
"INDEXED BY SeqLedger Where LedgerSeq = :ls;",
|
||||
soci::into (lhO),
|
||||
soci::into (phO),
|
||||
soci::use (ledgerIndex);
|
||||
|
||||
if (!lhO || !phO)
|
||||
{
|
||||
WriteLog (lsTRACE, Ledger) << "Don't have ledger " << ledgerIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
ledgerHash.SetHexExact (*lhO);
|
||||
parentHash.SetHexExact (*phO);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map< std::uint32_t, std::pair<uint256, uint256> >
|
||||
Ledger::getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq)
|
||||
{
|
||||
std::map< std::uint32_t, std::pair<uint256, uint256> > ret;
|
||||
|
||||
std::string sql =
|
||||
"SELECT LedgerSeq,LedgerHash,PrevHash FROM Ledgers WHERE LedgerSeq >= ";
|
||||
sql.append (beast::lexicalCastThrow <std::string> (minSeq));
|
||||
sql.append (" AND LedgerSeq <= ");
|
||||
sql.append (beast::lexicalCastThrow <std::string> (maxSeq));
|
||||
sql.append (";");
|
||||
|
||||
auto db = getApp().getLedgerDB ().checkoutDb ();
|
||||
|
||||
std::uint64_t ls;
|
||||
std::string lh;
|
||||
boost::optional<std::string> ph;
|
||||
soci::statement st =
|
||||
(db->prepare << sql,
|
||||
soci::into (ls),
|
||||
soci::into (lh),
|
||||
soci::into (ph));
|
||||
|
||||
st.execute ();
|
||||
while (st.fetch ())
|
||||
{
|
||||
std::pair<uint256, uint256>& hashes =
|
||||
ret[rangeCheckedCast<std::uint32_t>(ls)];
|
||||
hashes.first.SetHexExact (lh);
|
||||
if (ph)
|
||||
hashes.second.SetHexExact (*ph);
|
||||
else
|
||||
hashes.second.zero ();
|
||||
if (!ph)
|
||||
{
|
||||
WriteLog (lsWARNING, Ledger)
|
||||
<< "Null prev hash for ledger seq: " << ls;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Ledger::setAcquiring (void)
|
||||
{
|
||||
if (!txMap_ || !stateMap_)
|
||||
@@ -961,11 +741,7 @@ void Ledger::visitStateItems (std::function<void (SLE::ref)> callback) const
|
||||
}
|
||||
catch (SHAMapMissingNode&)
|
||||
{
|
||||
if (info_.hash.isNonZero ())
|
||||
{
|
||||
getApp().getInboundLedgers().acquire(
|
||||
info_.hash, info_.seq, InboundLedger::fcGENERIC);
|
||||
}
|
||||
stateMap_->family().missing_node (info_.hash);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -1169,7 +945,7 @@ static bool saveValidatedLedger (
|
||||
aLedger = app.getAcceptedLedgerCache().fetch (ledger->info().hash);
|
||||
if (! aLedger)
|
||||
{
|
||||
aLedger = std::make_shared<AcceptedLedger>(ledger);
|
||||
aLedger = std::make_shared<AcceptedLedger>(ledger, app.accountIDCache());
|
||||
app.getAcceptedLedgerCache().canonicalize(ledger->info().hash, aLedger);
|
||||
}
|
||||
}
|
||||
@@ -1338,7 +1114,8 @@ qualityDirDescriber (
|
||||
SLE::ref sle, bool isNew,
|
||||
Currency const& uTakerPaysCurrency, AccountID const& uTakerPaysIssuer,
|
||||
Currency const& uTakerGetsCurrency, AccountID const& uTakerGetsIssuer,
|
||||
const std::uint64_t& uRate)
|
||||
const std::uint64_t& uRate,
|
||||
Application& app)
|
||||
{
|
||||
sle->setFieldH160 (sfTakerPaysCurrency, uTakerPaysCurrency);
|
||||
sle->setFieldH160 (sfTakerPaysIssuer, uTakerPaysIssuer);
|
||||
@@ -1348,7 +1125,7 @@ qualityDirDescriber (
|
||||
if (isNew)
|
||||
{
|
||||
// VFALCO NO! This shouldn't be done here!
|
||||
getApp().getOrderBookDB().addOrderBook(
|
||||
app.getOrderBookDB().addOrderBook(
|
||||
{{uTakerPaysCurrency, uTakerPaysIssuer},
|
||||
{uTakerGetsCurrency, uTakerGetsIssuer}});
|
||||
}
|
||||
@@ -1428,4 +1205,234 @@ Ledger::getNeededAccountStateHashes (
|
||||
return ret;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Load a ledger from the database.
|
||||
*
|
||||
* @param sqlSuffix: Additional string to append to the sql query.
|
||||
* (typically a where clause).
|
||||
* @return The ledger, ledger sequence, and ledger hash.
|
||||
*/
|
||||
std::tuple<Ledger::pointer, std::uint32_t, uint256>
|
||||
loadLedgerHelper(std::string const& sqlSuffix, Application& app)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
uint256 ledgerHash{};
|
||||
std::uint32_t ledgerSeq{0};
|
||||
|
||||
auto db = app.getLedgerDB ().checkoutDb ();
|
||||
|
||||
boost::optional<std::string> sLedgerHash, sPrevHash, sAccountHash,
|
||||
sTransHash;
|
||||
boost::optional<std::uint64_t> totDrops, closingTime, prevClosingTime,
|
||||
closeResolution, closeFlags, ledgerSeq64;
|
||||
|
||||
std::string const sql =
|
||||
"SELECT "
|
||||
"LedgerHash, PrevHash, AccountSetHash, TransSetHash, "
|
||||
"TotalCoins,"
|
||||
"ClosingTime, PrevClosingTime, CloseTimeRes, CloseFlags,"
|
||||
"LedgerSeq from Ledgers " +
|
||||
sqlSuffix + ";";
|
||||
|
||||
*db << sql,
|
||||
soci::into(sLedgerHash),
|
||||
soci::into(sPrevHash),
|
||||
soci::into(sAccountHash),
|
||||
soci::into(sTransHash),
|
||||
soci::into(totDrops),
|
||||
soci::into(closingTime),
|
||||
soci::into(prevClosingTime),
|
||||
soci::into(closeResolution),
|
||||
soci::into(closeFlags),
|
||||
soci::into(ledgerSeq64);
|
||||
|
||||
if (!db->got_data ())
|
||||
{
|
||||
WriteLog (lsDEBUG, Ledger) << "Ledger not found: " << sqlSuffix;
|
||||
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
|
||||
}
|
||||
|
||||
ledgerSeq =
|
||||
rangeCheckedCast<std::uint32_t>(ledgerSeq64.value_or (0));
|
||||
|
||||
uint256 prevHash{}, accountHash{}, transHash{};
|
||||
if (sLedgerHash)
|
||||
ledgerHash.SetHexExact (*sLedgerHash);
|
||||
if (sPrevHash)
|
||||
prevHash.SetHexExact (*sPrevHash);
|
||||
if (sAccountHash)
|
||||
accountHash.SetHexExact (*sAccountHash);
|
||||
if (sTransHash)
|
||||
transHash.SetHexExact (*sTransHash);
|
||||
|
||||
bool loaded = false;
|
||||
ledger = std::make_shared<Ledger>(prevHash,
|
||||
transHash,
|
||||
accountHash,
|
||||
totDrops.value_or(0),
|
||||
closingTime.value_or(0),
|
||||
prevClosingTime.value_or(0),
|
||||
closeFlags.value_or(0),
|
||||
closeResolution.value_or(0),
|
||||
ledgerSeq,
|
||||
loaded,
|
||||
getConfig(),
|
||||
app.family());
|
||||
|
||||
if (!loaded)
|
||||
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
|
||||
|
||||
return std::make_tuple (ledger, ledgerSeq, ledgerHash);
|
||||
}
|
||||
|
||||
void finishLoadByIndexOrHash(Ledger::pointer& ledger)
|
||||
{
|
||||
if (!ledger)
|
||||
return;
|
||||
|
||||
ledger->setClosed ();
|
||||
ledger->setImmutable ();
|
||||
|
||||
WriteLog (lsTRACE, Ledger)
|
||||
<< "Loaded ledger: " << to_string (ledger->getHash ());
|
||||
|
||||
ledger->setFull ();
|
||||
}
|
||||
|
||||
Ledger::pointer
|
||||
loadByIndex (std::uint32_t ledgerIndex, Application& app)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "WHERE LedgerSeq = " << ledgerIndex;
|
||||
std::tie (ledger, std::ignore, std::ignore) =
|
||||
loadLedgerHelper (s.str (), app);
|
||||
}
|
||||
|
||||
finishLoadByIndexOrHash (ledger);
|
||||
return ledger;
|
||||
}
|
||||
|
||||
Ledger::pointer
|
||||
loadByHash (uint256 const& ledgerHash, Application& app)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "WHERE LedgerHash = '" << ledgerHash << "'";
|
||||
std::tie (ledger, std::ignore, std::ignore) =
|
||||
loadLedgerHelper (s.str (), app);
|
||||
}
|
||||
|
||||
finishLoadByIndexOrHash (ledger);
|
||||
|
||||
assert (!ledger || ledger->getHash () == ledgerHash);
|
||||
|
||||
return ledger;
|
||||
}
|
||||
|
||||
uint256
|
||||
getHashByIndex (std::uint32_t ledgerIndex, Application& app)
|
||||
{
|
||||
uint256 ret;
|
||||
|
||||
std::string sql =
|
||||
"SELECT LedgerHash FROM Ledgers INDEXED BY SeqLedger WHERE LedgerSeq='";
|
||||
sql.append (beast::lexicalCastThrow <std::string> (ledgerIndex));
|
||||
sql.append ("';");
|
||||
|
||||
std::string hash;
|
||||
{
|
||||
auto db = app.getLedgerDB ().checkoutDb ();
|
||||
|
||||
boost::optional<std::string> lh;
|
||||
*db << sql,
|
||||
soci::into (lh);
|
||||
|
||||
if (!db->got_data () || !lh)
|
||||
return ret;
|
||||
|
||||
hash = *lh;
|
||||
if (hash.empty ())
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.SetHexExact (hash);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
getHashesByIndex(std::uint32_t ledgerIndex,
|
||||
uint256& ledgerHash, uint256& parentHash,
|
||||
Application& app)
|
||||
{
|
||||
auto db = app.getLedgerDB ().checkoutDb ();
|
||||
|
||||
boost::optional <std::string> lhO, phO;
|
||||
|
||||
*db << "SELECT LedgerHash,PrevHash FROM Ledgers "
|
||||
"INDEXED BY SeqLedger Where LedgerSeq = :ls;",
|
||||
soci::into (lhO),
|
||||
soci::into (phO),
|
||||
soci::use (ledgerIndex);
|
||||
|
||||
if (!lhO || !phO)
|
||||
{
|
||||
WriteLog (lsTRACE, Ledger) << "Don't have ledger " << ledgerIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
ledgerHash.SetHexExact (*lhO);
|
||||
parentHash.SetHexExact (*phO);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map< std::uint32_t, std::pair<uint256, uint256> >
|
||||
getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq,
|
||||
Application& app)
|
||||
{
|
||||
std::map< std::uint32_t, std::pair<uint256, uint256> > ret;
|
||||
|
||||
std::string sql =
|
||||
"SELECT LedgerSeq,LedgerHash,PrevHash FROM Ledgers WHERE LedgerSeq >= ";
|
||||
sql.append (beast::lexicalCastThrow <std::string> (minSeq));
|
||||
sql.append (" AND LedgerSeq <= ");
|
||||
sql.append (beast::lexicalCastThrow <std::string> (maxSeq));
|
||||
sql.append (";");
|
||||
|
||||
auto db = app.getLedgerDB ().checkoutDb ();
|
||||
|
||||
std::uint64_t ls;
|
||||
std::string lh;
|
||||
boost::optional<std::string> ph;
|
||||
soci::statement st =
|
||||
(db->prepare << sql,
|
||||
soci::into (ls),
|
||||
soci::into (lh),
|
||||
soci::into (ph));
|
||||
|
||||
st.execute ();
|
||||
while (st.fetch ())
|
||||
{
|
||||
std::pair<uint256, uint256>& hashes =
|
||||
ret[rangeCheckedCast<std::uint32_t>(ls)];
|
||||
hashes.first.SetHexExact (lh);
|
||||
if (ph)
|
||||
hashes.second.SetHexExact (*ph);
|
||||
else
|
||||
hashes.second.zero ();
|
||||
if (!ph)
|
||||
{
|
||||
WriteLog (lsWARNING, Ledger)
|
||||
<< "Null prev hash for ledger seq: " << ls;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <ripple/ledger/CachedView.h>
|
||||
#include <ripple/app/tx/Transaction.h>
|
||||
#include <ripple/basics/CountedObject.h>
|
||||
#include <ripple/core/TimeKeeper.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <ripple/protocol/Serializer.h>
|
||||
@@ -98,14 +99,15 @@ public:
|
||||
starts in this account can ever exist, with amounts
|
||||
used to pay fees being destroyed.
|
||||
*/
|
||||
Ledger (create_genesis_t, Config const& config);
|
||||
Ledger (create_genesis_t, Config const& config, Family& family);
|
||||
|
||||
// Used for ledgers loaded from JSON files
|
||||
Ledger (uint256 const& parentHash, uint256 const& transHash,
|
||||
uint256 const& accountHash,
|
||||
std::uint64_t totDrops, std::uint32_t closeTime,
|
||||
std::uint32_t parentCloseTime, int closeFlags, int closeResolution,
|
||||
std::uint32_t ledgerSeq, bool & loaded, Config const& config);
|
||||
std::uint32_t ledgerSeq, bool & loaded, Config const& config,
|
||||
Family& family);
|
||||
|
||||
// Create a new ledger that's a snapshot of this one
|
||||
Ledger (Ledger const& target, bool isMutable);
|
||||
@@ -116,15 +118,17 @@ public:
|
||||
follows previous, and have
|
||||
parentCloseTime == previous.closeTime.
|
||||
*/
|
||||
Ledger (open_ledger_t, Ledger const& previous);
|
||||
Ledger (open_ledger_t, Ledger const& previous,
|
||||
NetClock::time_point closeTime);
|
||||
|
||||
Ledger (void const* data,
|
||||
std::size_t size, bool hasPrefix,
|
||||
Config const& config);
|
||||
Config const& config, Family& family);
|
||||
|
||||
// used for database ledgers
|
||||
Ledger (std::uint32_t ledgerSeq,
|
||||
std::uint32_t closeTime, Config const& config);
|
||||
std::uint32_t closeTime, Config const& config,
|
||||
Family& family);
|
||||
|
||||
~Ledger();
|
||||
|
||||
@@ -250,7 +254,7 @@ public:
|
||||
|
||||
// ledger signature operations
|
||||
void addRaw (Serializer& s) const;
|
||||
void setRaw (SerialIter& sit, bool hasPrefix);
|
||||
void setRaw (SerialIter& sit, bool hasPrefix, Family& family);
|
||||
|
||||
// DEPRECATED
|
||||
// Remove contract.h include
|
||||
@@ -356,19 +360,6 @@ public:
|
||||
|
||||
bool assertSane ();
|
||||
|
||||
// database functions (low-level)
|
||||
static Ledger::pointer loadByIndex (std::uint32_t ledgerIndex);
|
||||
|
||||
static Ledger::pointer loadByHash (uint256 const& ledgerHash);
|
||||
|
||||
static uint256 getHashByIndex (std::uint32_t index);
|
||||
|
||||
static bool getHashesByIndex (
|
||||
std::uint32_t index, uint256 & ledgerHash, uint256 & parentHash);
|
||||
|
||||
static std::map< std::uint32_t, std::pair<uint256, uint256> >
|
||||
getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq);
|
||||
|
||||
private:
|
||||
class sles_iter_impl;
|
||||
class txs_iter_impl;
|
||||
@@ -416,12 +407,6 @@ private:
|
||||
std::uint32_t mutable mReserveIncrement = 0;
|
||||
};
|
||||
|
||||
bool pendSaveValidated (
|
||||
Application& app,
|
||||
std::shared_ptr<Ledger> const& ledger,
|
||||
bool isSynchronous,
|
||||
bool isCurrent);
|
||||
|
||||
/** A ledger wrapped in a CachedView. */
|
||||
using CachedLedger = CachedView<Ledger>;
|
||||
|
||||
@@ -431,6 +416,43 @@ using CachedLedger = CachedView<Ledger>;
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern
|
||||
bool
|
||||
pendSaveValidated(
|
||||
Application& app,
|
||||
std::shared_ptr<Ledger> const& ledger,
|
||||
bool isSynchronous,
|
||||
bool isCurrent);
|
||||
|
||||
extern
|
||||
Ledger::pointer
|
||||
loadByIndex (std::uint32_t ledgerIndex,
|
||||
Application& app);
|
||||
|
||||
extern
|
||||
std::tuple<Ledger::pointer, std::uint32_t, uint256>
|
||||
loadLedgerHelper(std::string const& sqlSuffix,
|
||||
Application& app);
|
||||
|
||||
extern
|
||||
Ledger::pointer
|
||||
loadByHash (uint256 const& ledgerHash, Application& app);
|
||||
|
||||
extern
|
||||
uint256
|
||||
getHashByIndex(std::uint32_t index, Application& app);
|
||||
|
||||
extern
|
||||
bool
|
||||
getHashesByIndex(std::uint32_t index,
|
||||
uint256 &ledgerHash, uint256& parentHash,
|
||||
Application& app);
|
||||
|
||||
extern
|
||||
std::map< std::uint32_t, std::pair<uint256, uint256>>
|
||||
getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq,
|
||||
Application& app);
|
||||
|
||||
/** Deserialize a SHAMapItem containing a single STTx
|
||||
|
||||
Throw:
|
||||
@@ -454,9 +476,6 @@ std::pair<std::shared_ptr<
|
||||
STObject const>>
|
||||
deserializeTxPlusMeta (SHAMapItem const& item);
|
||||
|
||||
std::tuple<Ledger::pointer, std::uint32_t, uint256>
|
||||
loadLedgerHelper(std::string const& sqlSuffix);
|
||||
|
||||
// DEPRECATED
|
||||
inline
|
||||
std::shared_ptr<SLE const>
|
||||
@@ -479,7 +498,7 @@ qualityDirDescriber (
|
||||
SLE::ref, bool,
|
||||
Currency const& uTakerPaysCurrency, AccountID const& uTakerPaysIssuer,
|
||||
Currency const& uTakerGetsCurrency, AccountID const& uTakerGetsIssuer,
|
||||
const std::uint64_t & uRate);
|
||||
const std::uint64_t & uRate, Application& app);
|
||||
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -39,8 +39,10 @@ namespace ripple {
|
||||
// FIXME: Need to clean up ledgers by index at some point
|
||||
|
||||
LedgerHistory::LedgerHistory (
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
: collector_ (collector)
|
||||
beast::insight::Collector::ptr const& collector,
|
||||
Application& app)
|
||||
: app_ (app)
|
||||
, collector_ (collector)
|
||||
, mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch"))
|
||||
, m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
|
||||
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||
@@ -89,7 +91,7 @@ Ledger::pointer LedgerHistory::getLedgerBySeq (LedgerIndex index)
|
||||
}
|
||||
}
|
||||
|
||||
Ledger::pointer ret (Ledger::loadByIndex (index));
|
||||
Ledger::pointer ret = loadByIndex (index, app_);
|
||||
|
||||
if (!ret)
|
||||
return ret;
|
||||
@@ -118,7 +120,7 @@ Ledger::pointer LedgerHistory::getLedgerByHash (LedgerHash const& hash)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = Ledger::loadByHash (hash);
|
||||
ret = loadByHash (hash, app_);
|
||||
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define RIPPLE_APP_LEDGER_LEDGERHISTORY_H_INCLUDED
|
||||
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/protocol/RippleLedgerHash.h>
|
||||
#include <beast/insight/Collector.h>
|
||||
#include <beast/insight/Event.h>
|
||||
@@ -33,8 +34,8 @@ namespace ripple {
|
||||
class LedgerHistory
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
LedgerHistory (beast::insight::Collector::ptr const& collector);
|
||||
LedgerHistory (beast::insight::Collector::ptr const& collector,
|
||||
Application& app);
|
||||
|
||||
/** Track a ledger
|
||||
@return `true` if the ledger was already tracked
|
||||
@@ -106,6 +107,7 @@ private:
|
||||
*/
|
||||
void handleMismatch (LedgerHash const& built, LedgerHash const& valid);
|
||||
|
||||
Application& app_;
|
||||
beast::insight::Collector::ptr collector_;
|
||||
beast::insight::Counter mismatch_counter_;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ bool InboundLedger::tryLocal ()
|
||||
if (m_journal.trace) m_journal.trace <<
|
||||
"Ledger header found in fetch pack";
|
||||
mLedger = std::make_shared<Ledger> (
|
||||
data.data(), data.size(), true, getConfig());
|
||||
data.data(), data.size(), true, getConfig(), app_.family());
|
||||
app_.getNodeStore ().store (
|
||||
hotLEDGER, std::move (data), mHash);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ bool InboundLedger::tryLocal ()
|
||||
{
|
||||
mLedger = std::make_shared<Ledger>(
|
||||
node->getData().data(), node->getData().size(),
|
||||
true, getConfig());
|
||||
true, getConfig(), app_.family());
|
||||
}
|
||||
|
||||
if (mLedger->getHash () != mHash)
|
||||
@@ -769,7 +769,7 @@ bool InboundLedger::takeHeader (std::string const& data)
|
||||
return true;
|
||||
|
||||
mLedger = std::make_shared<Ledger>(
|
||||
data.data(), data.size(), false, getConfig());
|
||||
data.data(), data.size(), false, getConfig(), app_.family());
|
||||
|
||||
if (mLedger->getHash () != mHash)
|
||||
{
|
||||
|
||||
@@ -301,7 +301,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
Ledger::pointer dbLedger = Ledger::loadByIndex(ledgerIndex);
|
||||
Ledger::pointer dbLedger = loadByIndex(ledgerIndex, app_);
|
||||
if (! dbLedger ||
|
||||
(dbLedger->getHash() != ledgerHash) ||
|
||||
(dbLedger->info().parentHash != nodeLedger->info().parentHash))
|
||||
|
||||
@@ -1006,7 +1006,8 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
|
||||
|
||||
// Build the new last closed ledger
|
||||
auto newLCL = std::make_shared<Ledger>(
|
||||
open_ledger, *mPreviousLedger);
|
||||
open_ledger, *mPreviousLedger,
|
||||
app_.timeKeeper().closeTime());
|
||||
newLCL->setClosed (); // so applyTransactions sees a closed ledger
|
||||
|
||||
// Set up to write SHAMap changes to our database,
|
||||
@@ -1113,7 +1114,7 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
|
||||
|
||||
// Build new open ledger
|
||||
auto newOL = std::make_shared<Ledger>(
|
||||
open_ledger, *newLCL);
|
||||
open_ledger, *newLCL, app_.timeKeeper().closeTime());
|
||||
OpenView accum(&*newOL);
|
||||
assert(accum.open());
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
, app_ (app)
|
||||
, m_journal (journal)
|
||||
, mLastValidLedger (std::make_pair (uint256(), 0))
|
||||
, mLedgerHistory (collector)
|
||||
, mLedgerHistory (collector, app)
|
||||
, mHeldTransactions (uint256 ())
|
||||
, mLedgerCleaner (make_LedgerCleaner (
|
||||
app, *this, deprecatedLogs().journal("LedgerCleaner")))
|
||||
@@ -617,9 +617,9 @@ public:
|
||||
mCompleteLedgers.setRange (minHas, maxHas);
|
||||
}
|
||||
maxHas = minHas;
|
||||
ledgerHashes = Ledger::getHashesByIndex ((seq < 500)
|
||||
ledgerHashes = getHashesByIndex ((seq < 500)
|
||||
? 0
|
||||
: (seq - 499), seq);
|
||||
: (seq - 499), seq, app_);
|
||||
it = ledgerHashes.find (seq);
|
||||
|
||||
if (it == ledgerHashes.end ())
|
||||
@@ -755,7 +755,7 @@ public:
|
||||
{
|
||||
// Check the SQL database's entry for the sequence before this
|
||||
// ledger, if it's not this ledger's parent, invalidate it
|
||||
uint256 prevHash = Ledger::getHashByIndex (ledger->info().seq - 1);
|
||||
uint256 prevHash = getHashByIndex (ledger->info().seq - 1, app_);
|
||||
if (prevHash.isNonZero () && prevHash != ledger->info().parentHash)
|
||||
clearLedger (ledger->info().seq - 1);
|
||||
}
|
||||
@@ -1451,7 +1451,7 @@ public:
|
||||
if (hash.isNonZero ())
|
||||
return hash;
|
||||
|
||||
return Ledger::getHashByIndex (index);
|
||||
return getHashByIndex (index, app_);
|
||||
}
|
||||
|
||||
// VFALCO NOTE This should return boost::optional<uint256>
|
||||
@@ -1747,7 +1747,7 @@ void LedgerMasterImp::doAdvance ()
|
||||
mHistLedger = ledger;
|
||||
auto& parent = ledger->info().parentHash;
|
||||
if (mFillInProgress == 0 &&
|
||||
Ledger::getHashByIndex(seq - 1) == parent)
|
||||
getHashByIndex(seq - 1, app_) == parent)
|
||||
{
|
||||
// Previous ledger is in DB
|
||||
ScopedLockType lock (m_mutex);
|
||||
|
||||
@@ -110,7 +110,7 @@ Application* ApplicationImpBase::s_instance;
|
||||
|
||||
namespace detail {
|
||||
|
||||
class AppFamily : public shamap::Family
|
||||
class AppFamily : public Family
|
||||
{
|
||||
private:
|
||||
Application& app_;
|
||||
@@ -178,6 +178,17 @@ public:
|
||||
app_.getInboundLedgers ().acquire (
|
||||
hash, seq, InboundLedger::fcGENERIC);
|
||||
}
|
||||
|
||||
virtual
|
||||
void
|
||||
missing_node (uint256 const& hash) override
|
||||
{
|
||||
if (hash.isNonZero())
|
||||
{
|
||||
app_.getInboundLedgers ().acquire (
|
||||
hash, 0, InboundLedger::fcGENERIC);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
@@ -341,6 +352,8 @@ public:
|
||||
, timeKeeper_ (make_TimeKeeper(
|
||||
deprecatedLogs().journal("TimeKeeper")))
|
||||
|
||||
, m_txMaster (*this)
|
||||
|
||||
, m_nodeStoreScheduler (*this)
|
||||
|
||||
, m_shaMapStore (make_SHAMapStore (*this, setup_SHAMapStore (
|
||||
@@ -471,7 +484,7 @@ public:
|
||||
return *m_collectorManager;
|
||||
}
|
||||
|
||||
shamap::Family&
|
||||
Family&
|
||||
family()
|
||||
{
|
||||
return family_;
|
||||
@@ -1064,16 +1077,17 @@ void ApplicationImp::startGenesisLedger ()
|
||||
{
|
||||
std::shared_ptr<Ledger const> const genesis =
|
||||
std::make_shared<Ledger>(
|
||||
create_genesis, config_);
|
||||
create_genesis, config_, family());
|
||||
auto const next = std::make_shared<Ledger>(
|
||||
open_ledger, *genesis);
|
||||
open_ledger, *genesis, timeKeeper().closeTime());
|
||||
next->setClosed ();
|
||||
next->setImmutable ();
|
||||
m_networkOPs->setLastCloseTime (next->info().closeTime);
|
||||
openLedger_.emplace(next, config_,
|
||||
cachedSLEs_, deprecatedLogs().journal("OpenLedger"));
|
||||
m_ledgerMaster->pushLedger (next,
|
||||
std::make_shared<Ledger>(open_ledger, *next));
|
||||
std::make_shared<Ledger>(open_ledger, *next,
|
||||
timeKeeper().closeTime()));
|
||||
}
|
||||
|
||||
Ledger::pointer
|
||||
@@ -1085,7 +1099,7 @@ ApplicationImp::getLastFullLedger()
|
||||
std::uint32_t ledgerSeq;
|
||||
uint256 ledgerHash;
|
||||
std::tie (ledger, ledgerSeq, ledgerHash) =
|
||||
loadLedgerHelper ("order by LedgerSeq desc limit 1");
|
||||
loadLedgerHelper ("order by LedgerSeq desc limit 1", *this);
|
||||
|
||||
if (!ledger)
|
||||
return ledger;
|
||||
@@ -1192,7 +1206,7 @@ bool ApplicationImp::loadOldLedger (
|
||||
}
|
||||
else
|
||||
{
|
||||
loadLedger = std::make_shared<Ledger> (seq, closeTime, config_);
|
||||
loadLedger = std::make_shared<Ledger> (seq, closeTime, config_, family());
|
||||
loadLedger->setTotalDrops(totalDrops);
|
||||
|
||||
for (Json::UInt index = 0; index < ledger.get().size(); ++index)
|
||||
@@ -1237,7 +1251,7 @@ bool ApplicationImp::loadOldLedger (
|
||||
// by hash
|
||||
uint256 hash;
|
||||
hash.SetHex (ledgerID);
|
||||
loadLedger = Ledger::loadByHash (hash);
|
||||
loadLedger = loadByHash (hash, *this);
|
||||
|
||||
if (!loadLedger)
|
||||
{
|
||||
@@ -1250,8 +1264,8 @@ bool ApplicationImp::loadOldLedger (
|
||||
|
||||
}
|
||||
else // assume by sequence
|
||||
loadLedger = Ledger::loadByIndex (
|
||||
beast::lexicalCastThrow <std::uint32_t> (ledgerID));
|
||||
loadLedger = loadByIndex (
|
||||
beast::lexicalCastThrow <std::uint32_t> (ledgerID), *this);
|
||||
|
||||
if (!loadLedger)
|
||||
{
|
||||
@@ -1269,7 +1283,7 @@ bool ApplicationImp::loadOldLedger (
|
||||
|
||||
m_journal.info << "Loading parent ledger";
|
||||
|
||||
loadLedger = Ledger::loadByHash (replayLedger->info().parentHash);
|
||||
loadLedger = loadByHash (replayLedger->info().parentHash, *this);
|
||||
if (!loadLedger)
|
||||
{
|
||||
m_journal.info << "Loading parent ledger from node store";
|
||||
@@ -1318,7 +1332,8 @@ bool ApplicationImp::loadOldLedger (
|
||||
m_ledgerMaster->setLedgerRangePresent (loadLedger->info().seq, loadLedger->info().seq);
|
||||
|
||||
auto const openLedger =
|
||||
std::make_shared<Ledger>(open_ledger, *loadLedger);
|
||||
std::make_shared<Ledger>(open_ledger, *loadLedger,
|
||||
timeKeeper().closeTime());
|
||||
m_ledgerMaster->switchLedgers (loadLedger, openLedger);
|
||||
m_ledgerMaster->forceValid(loadLedger);
|
||||
m_networkOPs->setLastCloseTime (loadLedger->info().closeTime);
|
||||
|
||||
@@ -40,9 +40,7 @@ namespace NodeStore { class Database; }
|
||||
class AmendmentTable;
|
||||
class CachedSLEs;
|
||||
class CollectorManager;
|
||||
namespace shamap {
|
||||
class Family;
|
||||
} // shamap
|
||||
class HashRouter;
|
||||
class Logs;
|
||||
class LoadFeeTrack;
|
||||
@@ -95,7 +93,7 @@ public:
|
||||
virtual Config const& config() const = 0;
|
||||
virtual boost::asio::io_service& getIOService () = 0;
|
||||
virtual CollectorManager& getCollectorManager () = 0;
|
||||
virtual shamap::Family& family() = 0;
|
||||
virtual Family& family() = 0;
|
||||
virtual TimeKeeper& timeKeeper() = 0;
|
||||
virtual JobQueue& getJobQueue () = 0;
|
||||
virtual NodeCache& getTempNodeCache () = 0;
|
||||
|
||||
@@ -94,7 +94,7 @@ void startServer (Application& app)
|
||||
Resource::Charge loadType = Resource::feeReferenceRPC;
|
||||
RPC::Context context {
|
||||
jvCommand, app, loadType, app.getOPs (),
|
||||
app.getLedgerMaster(), Role::ADMIN};
|
||||
app.getLedgerMaster(), Role::ADMIN, app};
|
||||
|
||||
Json::Value jvResult;
|
||||
RPC::doCommand (context, jvResult);
|
||||
|
||||
@@ -699,7 +699,7 @@ void NetworkOPsImp::submitTransaction (STTx::pointer iTrans)
|
||||
}
|
||||
|
||||
auto tx = std::make_shared<Transaction> (
|
||||
trans, Validate::NO, directSigVerify, reason);
|
||||
trans, Validate::NO, directSigVerify, reason, app_);
|
||||
|
||||
m_job_queue.addJob (jtTRANSACTION, "submitTxn", [this, tx] (Job&) {
|
||||
auto t = tx;
|
||||
@@ -1316,7 +1316,8 @@ void NetworkOPsImp::switchLastClosedLedger (
|
||||
clearNeedNetworkLedger ();
|
||||
newLCL->setClosed ();
|
||||
auto const newOL = std::make_shared<
|
||||
Ledger>(open_ledger, std::ref (*newLCL));
|
||||
Ledger>(open_ledger, std::ref (*newLCL),
|
||||
app_.timeKeeper().closeTime());
|
||||
// Caller must own master lock
|
||||
{
|
||||
auto const oldOL =
|
||||
@@ -1746,7 +1747,7 @@ NetworkOPs::AccountTxs NetworkOPsImp::getAccountTxs (
|
||||
txnMeta.clear ();
|
||||
|
||||
auto txn = Transaction::transactionFromSQL (
|
||||
ledgerSeq, status, rawTxn, Validate::NO);
|
||||
ledgerSeq, status, rawTxn, Validate::NO, app_);
|
||||
|
||||
if (txnMeta.empty ())
|
||||
{ // Work around a bug that could leave the metadata missing
|
||||
@@ -1824,15 +1825,17 @@ NetworkOPsImp::getTxsAccount (
|
||||
{
|
||||
static std::uint32_t const page_length (200);
|
||||
|
||||
Application& app = app_;
|
||||
NetworkOPsImp::AccountTxs ret;
|
||||
|
||||
auto bound = [&ret](
|
||||
auto bound = [&ret, &app](
|
||||
std::uint32_t ledger_index,
|
||||
std::string const& status,
|
||||
Blob const& rawTxn,
|
||||
Blob const& rawMeta)
|
||||
{
|
||||
convertBlobsToTxResult (ret, ledger_index, status, rawTxn, rawMeta);
|
||||
convertBlobsToTxResult (
|
||||
ret, ledger_index, status, rawTxn, rawMeta, app);
|
||||
};
|
||||
|
||||
accountTxPage(app_.getTxnDB (), app_.accountIDCache(),
|
||||
@@ -2099,7 +2102,8 @@ void NetworkOPsImp::pubProposedTransaction (
|
||||
}
|
||||
}
|
||||
}
|
||||
AcceptedLedgerTx alt (lpCurrent, stTxn, terResult);
|
||||
AcceptedLedgerTx alt (lpCurrent, stTxn, terResult,
|
||||
app_.accountIDCache());
|
||||
m_journal.trace << "pubProposed: " << alt.getJson ();
|
||||
pubAccountTransaction (lpCurrent, alt, false);
|
||||
}
|
||||
@@ -2113,7 +2117,8 @@ void NetworkOPsImp::pubLedger (Ledger::ref lpAccepted)
|
||||
app_.getAcceptedLedgerCache().fetch (lpAccepted->info().hash);
|
||||
if (! alpAccepted)
|
||||
{
|
||||
alpAccepted = std::make_shared<AcceptedLedger> (lpAccepted);
|
||||
alpAccepted = std::make_shared<AcceptedLedger> (
|
||||
lpAccepted, app_.accountIDCache());
|
||||
app_.getAcceptedLedgerCache().canonicalize (
|
||||
lpAccepted->info().hash, alpAccepted);
|
||||
}
|
||||
|
||||
@@ -36,14 +36,15 @@ convertBlobsToTxResult (
|
||||
std::uint32_t ledger_index,
|
||||
std::string const& status,
|
||||
Blob const& rawTxn,
|
||||
Blob const& rawMeta)
|
||||
Blob const& rawMeta,
|
||||
Application& app)
|
||||
{
|
||||
SerialIter it (makeSlice(rawTxn));
|
||||
STTx::pointer txn = std::make_shared<STTx> (it);
|
||||
std::string reason;
|
||||
|
||||
auto tr = std::make_shared<Transaction> (txn, Validate::NO,
|
||||
directSigVerify, reason);
|
||||
directSigVerify, reason, app);
|
||||
|
||||
tr->setStatus (Transaction::sqlTransactionStatus(status));
|
||||
tr->setLedger (ledger_index);
|
||||
|
||||
@@ -37,7 +37,8 @@ convertBlobsToTxResult (
|
||||
std::uint32_t ledger_index,
|
||||
std::string const& status,
|
||||
Blob const& rawTxn,
|
||||
Blob const& rawMeta);
|
||||
Blob const& rawMeta,
|
||||
Application& app);
|
||||
|
||||
void
|
||||
saveLedgerAsync (Application& app, std::uint32_t seq);
|
||||
|
||||
@@ -47,9 +47,10 @@ public:
|
||||
findPathsForIssue (
|
||||
Issue const& issue,
|
||||
STPathSet const& paths,
|
||||
STPath& fullLiquidityPath)
|
||||
STPath& fullLiquidityPath,
|
||||
Application& app)
|
||||
{
|
||||
if (auto& pathfinder = getPathFinder (issue.currency))
|
||||
if (auto& pathfinder = getPathFinder (issue.currency, app))
|
||||
{
|
||||
return pathfinder->getBestPaths (maxPaths_,
|
||||
fullLiquidityPath, paths, issue.account);
|
||||
@@ -69,14 +70,15 @@ private:
|
||||
int const searchLevel_;
|
||||
unsigned int const maxPaths_;
|
||||
|
||||
std::unique_ptr<Pathfinder> const& getPathFinder (Currency const& currency)
|
||||
std::unique_ptr<Pathfinder> const&
|
||||
getPathFinder (Currency const& currency, Application& app)
|
||||
{
|
||||
auto i = currencyMap_.find (currency);
|
||||
if (i != currencyMap_.end ())
|
||||
return i->second;
|
||||
auto pathfinder = std::make_unique<Pathfinder> (
|
||||
cache_, srcAccount_, dstAccount_, currency,
|
||||
boost::none, dstAmount_, srcAmount_);
|
||||
boost::none, dstAmount_, srcAmount_, app);
|
||||
if (pathfinder->findPaths (searchLevel_))
|
||||
pathfinder->computePathRanks (maxPaths_);
|
||||
else
|
||||
@@ -108,9 +110,10 @@ boost::optional<STPathSet>
|
||||
FindPaths::findPathsForIssue (
|
||||
Issue const& issue,
|
||||
STPathSet const& paths,
|
||||
STPath& fullLiquidityPath)
|
||||
STPath& fullLiquidityPath,
|
||||
Application& app)
|
||||
{
|
||||
return impl_->findPathsForIssue (issue, paths, fullLiquidityPath);
|
||||
return impl_->findPathsForIssue (issue, paths, fullLiquidityPath, app);
|
||||
}
|
||||
|
||||
boost::optional<STPathSet>
|
||||
@@ -123,7 +126,8 @@ findPathsForOneIssuer (
|
||||
int searchLevel,
|
||||
unsigned int const maxPaths,
|
||||
STPathSet const& paths,
|
||||
STPath& fullLiquidityPath)
|
||||
STPath& fullLiquidityPath,
|
||||
Application& app)
|
||||
{
|
||||
Pathfinder pf (
|
||||
cache,
|
||||
@@ -132,7 +136,8 @@ findPathsForOneIssuer (
|
||||
srcIssue.currency,
|
||||
srcIssue.account,
|
||||
dstAmount,
|
||||
boost::none);
|
||||
boost::none,
|
||||
app);
|
||||
|
||||
if (! pf.findPaths(searchLevel))
|
||||
return boost::none;
|
||||
|
||||
@@ -55,7 +55,9 @@ public:
|
||||
|
||||
On output, if fullLiquidityPath is non-empty, it contains one extra
|
||||
path that can move the entire liquidity requested. */
|
||||
STPath& fullLiquidityPath);
|
||||
STPath& fullLiquidityPath,
|
||||
|
||||
Application& app);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
@@ -88,7 +90,9 @@ findPathsForOneIssuer (
|
||||
|
||||
On output, if fullLiquidityPath is non-empty, it contains one extra path
|
||||
that can move the entire liquidity requested. */
|
||||
STPath& fullLiquidityPath);
|
||||
STPath& fullLiquidityPath,
|
||||
|
||||
Application& app);
|
||||
|
||||
void initializePathfinding ();
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ PathRequest::findPaths (
|
||||
{
|
||||
STPath fullLiquidityPath;
|
||||
auto result = fp.findPathsForIssue(issue,
|
||||
mContext[issue], fullLiquidityPath);
|
||||
mContext[issue], fullLiquidityPath, app_);
|
||||
if (! result)
|
||||
{
|
||||
m_journal.debug << iIdentifier << " No paths found";
|
||||
|
||||
@@ -148,7 +148,8 @@ Pathfinder::Pathfinder (
|
||||
Currency const& uSrcCurrency,
|
||||
boost::optional<AccountID> const& uSrcIssuer,
|
||||
STAmount const& saDstAmount,
|
||||
boost::optional<STAmount> const& srcAmount)
|
||||
boost::optional<STAmount> const& srcAmount,
|
||||
Application& app)
|
||||
: mSrcAccount (uSrcAccount),
|
||||
mDstAccount (uDstAccount),
|
||||
mEffectiveDst (isXRP(saDstAmount.getIssuer ()) ?
|
||||
@@ -162,7 +163,8 @@ Pathfinder::Pathfinder (
|
||||
convert_all_ (mDstAmount ==
|
||||
STAmount(mDstAmount.issue(), STAmount::cMaxValue, STAmount::cMaxOffset)),
|
||||
mLedger (cache->getLedger ()),
|
||||
mRLCache (cache)
|
||||
mRLCache (cache),
|
||||
app_ (app)
|
||||
{
|
||||
assert (! uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.get()));
|
||||
}
|
||||
@@ -201,7 +203,7 @@ bool Pathfinder::findPaths (int searchLevel)
|
||||
return true;
|
||||
}
|
||||
|
||||
m_loadEvent = getApp ().getJobQueue ().getLoadEvent (
|
||||
m_loadEvent = app_.getJobQueue ().getLoadEvent (
|
||||
jtPATH_FIND, "FindPath");
|
||||
auto currencyIsXRP = isXRP (mSrcCurrency);
|
||||
|
||||
@@ -715,7 +717,7 @@ int Pathfinder::getPathsOut (
|
||||
|
||||
if (!bFrozen)
|
||||
{
|
||||
count = getApp ().getOrderBookDB ().getBookSize (issue);
|
||||
count = app_.getOrderBookDB ().getBookSize (issue);
|
||||
|
||||
for (auto const& item : mRLCache->getRippleLines (account))
|
||||
{
|
||||
@@ -1057,7 +1059,7 @@ void Pathfinder::addLink (
|
||||
if (addFlags & afOB_XRP)
|
||||
{
|
||||
// to XRP only
|
||||
if (!bOnXRP && getApp ().getOrderBookDB ().isBookToXRP (
|
||||
if (!bOnXRP && app_.getOrderBookDB ().isBookToXRP (
|
||||
{uEndCurrency, uEndIssuer}))
|
||||
{
|
||||
STPathElement pathElement(
|
||||
@@ -1071,7 +1073,7 @@ void Pathfinder::addLink (
|
||||
else
|
||||
{
|
||||
bool bDestOnly = (addFlags & afOB_LAST) != 0;
|
||||
auto books = getApp ().getOrderBookDB ().getBooksByTakerPays(
|
||||
auto books = app_.getOrderBookDB ().getBooksByTakerPays(
|
||||
{uEndCurrency, uEndIssuer});
|
||||
WriteLog (lsTRACE, Pathfinder)
|
||||
<< books.size () << " books found from this currency/issuer";
|
||||
|
||||
@@ -45,7 +45,8 @@ public:
|
||||
Currency const& uSrcCurrency,
|
||||
boost::optional<AccountID> const& uSrcIssuer,
|
||||
STAmount const& dstAmount,
|
||||
boost::optional<STAmount> const& srcAmount);
|
||||
boost::optional<STAmount> const& srcAmount,
|
||||
Application& app);
|
||||
~Pathfinder();
|
||||
|
||||
static void initPathTable ();
|
||||
@@ -190,6 +191,8 @@ private:
|
||||
|
||||
hash_map<Issue, int> mPathsOutCountMap;
|
||||
|
||||
Application& app_;
|
||||
|
||||
// Add ripple paths
|
||||
static std::uint32_t const afADD_ACCOUNTS = 0x001;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <ripple/core/DatabaseCon.h>
|
||||
#include <ripple/app/misc/impl/AccountTxPaging.h>
|
||||
#include <ripple/protocol/types.h>
|
||||
#include <ripple/test/jtx.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
#include <beast/unit_test/suite.h>
|
||||
#include <cstdlib>
|
||||
@@ -90,15 +91,18 @@ struct AccountTxPaging_test : beast::unit_test::suite
|
||||
std::int32_t const page_length = 200;
|
||||
bool const admin = true;
|
||||
|
||||
test::jtx::Env env(*this);
|
||||
Application& app = env.app();
|
||||
auto& txs = txs_;
|
||||
|
||||
auto bound = [&txs](
|
||||
auto bound = [&txs, &app](
|
||||
std::uint32_t ledger_index,
|
||||
std::string const& status,
|
||||
Blob const& rawTxn,
|
||||
Blob const& rawMeta)
|
||||
{
|
||||
convertBlobsToTxResult (txs, ledger_index, status, rawTxn, rawMeta);
|
||||
convertBlobsToTxResult (
|
||||
txs, ledger_index, status, rawTxn, rawMeta, app);
|
||||
};
|
||||
|
||||
accountTxPage(*db_, *idCache_, [](std::uint32_t){}, bound, account_, minLedger,
|
||||
|
||||
@@ -135,12 +135,13 @@ equal(STAmount const& sa1, STAmount const& sa2)
|
||||
}
|
||||
|
||||
std::tuple <STPathSet, STAmount, STAmount>
|
||||
find_paths(std::shared_ptr<ReadView const> const& view,
|
||||
find_paths(jtx::Env& env,
|
||||
jtx::Account const& src, jtx::Account const& dst,
|
||||
STAmount const& saDstAmount,
|
||||
boost::optional<STAmount> const& saSendMax = boost::none)
|
||||
{
|
||||
static int const level = 8;
|
||||
auto const& view = env.open ();
|
||||
auto cache = std::make_shared<RippleLineCache>(view);
|
||||
auto currencies = accountSourceCurrencies(src, cache, true);
|
||||
auto jvSrcCurrencies = Json::Value(Json::arrayValue);
|
||||
@@ -153,7 +154,7 @@ find_paths(std::shared_ptr<ReadView const> const& view,
|
||||
|
||||
auto result = ripplePathFind(cache, src.id(), dst.id(),
|
||||
saDstAmount, jvSrcCurrencies, boost::none, level, saSendMax,
|
||||
saDstAmount == STAmount(saDstAmount.issue(), 1u, 0, true));
|
||||
saDstAmount == STAmount(saDstAmount.issue(), 1u, 0, true), env.app ());
|
||||
if (! result.first)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
@@ -191,7 +192,7 @@ public:
|
||||
Env env(*this);
|
||||
env.fund(XRP(10000), "alice", "bob");
|
||||
|
||||
auto const result = find_paths(env.open(),
|
||||
auto const result = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](5));
|
||||
expect(std::get<0>(result).empty());
|
||||
}
|
||||
@@ -207,7 +208,7 @@ public:
|
||||
|
||||
STPathSet st;
|
||||
STAmount sa;
|
||||
std::tie(st, sa, std::ignore) = find_paths(env.open(),
|
||||
std::tie(st, sa, std::ignore) = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](5));
|
||||
expect(st.empty());
|
||||
expect(equal(sa, Account("alice")["USD"](5)));
|
||||
@@ -248,7 +249,7 @@ public:
|
||||
|
||||
STPathSet st;
|
||||
STAmount sa;
|
||||
std::tie(st, sa, std::ignore) = find_paths(env.open(),
|
||||
std::tie(st, sa, std::ignore) = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](5));
|
||||
expect(same(st, stpath("gateway")));
|
||||
expect(equal(sa, Account("alice")["USD"](5)));
|
||||
@@ -273,7 +274,7 @@ public:
|
||||
STPathSet st;
|
||||
STAmount sa;
|
||||
STAmount da;
|
||||
std::tie(st, sa, da) = find_paths(env.open(),
|
||||
std::tie(st, sa, da) = find_paths(env,
|
||||
"alice", "edward", Account("edward")["USD"](-1));
|
||||
expect(same(st, stpath("dan"), stpath("bob", "carol")));
|
||||
expect(equal(sa, Account("alice")["USD"](110)));
|
||||
@@ -292,11 +293,11 @@ public:
|
||||
STPathSet st;
|
||||
STAmount sa;
|
||||
STAmount da;
|
||||
std::tie(st, sa, da) = find_paths(env.open(),
|
||||
std::tie(st, sa, da) = find_paths(env,
|
||||
"alice", "bob", Account("bob")["AUD"](-1),
|
||||
boost::optional<STAmount>(XRP(100000000)));
|
||||
expect(st.empty());
|
||||
std::tie(st, sa, da) = find_paths(env.open(),
|
||||
std::tie(st, sa, da) = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](-1),
|
||||
boost::optional<STAmount>(XRP(100000000)));
|
||||
expect(sa == XRP(100));
|
||||
@@ -417,7 +418,7 @@ public:
|
||||
|
||||
STPathSet st;
|
||||
STAmount sa;
|
||||
std::tie(st, sa, std::ignore) = find_paths(env.open(),
|
||||
std::tie(st, sa, std::ignore) = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](5));
|
||||
expect(same(st, stpath("gateway"), stpath("gateway2"),
|
||||
stpath("dan"), stpath("carol")));
|
||||
@@ -438,14 +439,14 @@ public:
|
||||
env.require(balance("bob", Account("carol")["USD"](-75)));
|
||||
env.require(balance("carol", Account("bob")["USD"](75)));
|
||||
|
||||
auto result = find_paths(env.open(),
|
||||
auto result = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](25));
|
||||
expect(std::get<0>(result).empty());
|
||||
|
||||
env(pay("alice", "bob", Account("alice")["USD"](25)),
|
||||
ter(tecPATH_DRY));
|
||||
|
||||
result = find_paths(env.open(),
|
||||
result = find_paths(env,
|
||||
"alice", "bob", Account("alice")["USD"](25));
|
||||
expect(std::get<0>(result).empty());
|
||||
|
||||
@@ -527,7 +528,7 @@ public:
|
||||
env.require(balance("bob", AUD(10)));
|
||||
env.require(balance("carol", AUD(39)));
|
||||
|
||||
auto const result = find_paths(env.open(),
|
||||
auto const result = find_paths(env,
|
||||
"alice", "bob", Account("bob")["USD"](25));
|
||||
expect(std::get<0>(result).empty());
|
||||
}
|
||||
@@ -544,7 +545,7 @@ public:
|
||||
|
||||
STPathSet st;
|
||||
STAmount sa;
|
||||
std::tie(st, sa, std::ignore) = find_paths(env.open(),
|
||||
std::tie(st, sa, std::ignore) = find_paths(env,
|
||||
"alice", "carol", Account("carol")["USD"](5));
|
||||
expect(same(st, stpath("bob")));
|
||||
expect(equal(sa, Account("alice")["USD"](5)));
|
||||
|
||||
@@ -49,7 +49,7 @@ struct Regression_test : public beast::unit_test::suite
|
||||
// be reproduced against an open ledger. Make a local
|
||||
// closed ledger and work with it directly.
|
||||
auto closed = std::make_shared<Ledger>(
|
||||
create_genesis, env.config);
|
||||
create_genesis, env.config, env.app().family());
|
||||
auto expectedDrops = SYSTEM_CURRENCY_START;
|
||||
expect(closed->info().drops == expectedDrops);
|
||||
|
||||
@@ -57,7 +57,8 @@ struct Regression_test : public beast::unit_test::suite
|
||||
auto const aliceAmount = XRP(aliceXRP);
|
||||
|
||||
auto next = std::make_shared<Ledger>(
|
||||
open_ledger, *closed);
|
||||
open_ledger, *closed,
|
||||
env.app().timeKeeper().closeTime());
|
||||
next->setClosed();
|
||||
{
|
||||
// Fund alice
|
||||
@@ -89,7 +90,7 @@ struct Regression_test : public beast::unit_test::suite
|
||||
// doesn't know about this account.
|
||||
auto const jt = env.jt(noop("alice"), fee(expectedDrops),
|
||||
seq(1));
|
||||
|
||||
|
||||
OpenView accum(&*next);
|
||||
|
||||
auto const result = ripple::apply(env.app(),
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace ripple {
|
||||
// obtain a binary version.
|
||||
//
|
||||
|
||||
class Application;
|
||||
class Database;
|
||||
|
||||
enum TransStatus
|
||||
@@ -62,11 +63,12 @@ public:
|
||||
using ref = const pointer&;
|
||||
|
||||
public:
|
||||
Transaction (STTx::ref, Validate, SigVerify, std::string&) noexcept;
|
||||
Transaction (
|
||||
STTx::ref, Validate, SigVerify, std::string&, Application&) noexcept;
|
||||
|
||||
static
|
||||
Transaction::pointer
|
||||
sharedTransaction (Blob const&, Validate);
|
||||
sharedTransaction (Blob const&, Validate, Application& app);
|
||||
|
||||
static
|
||||
Transaction::pointer
|
||||
@@ -74,7 +76,8 @@ public:
|
||||
boost::optional<std::uint64_t> const& ledgerSeq,
|
||||
boost::optional<std::string> const& status,
|
||||
Blob const& rawTxn,
|
||||
Validate validate);
|
||||
Validate validate,
|
||||
Application& app);
|
||||
|
||||
static
|
||||
TransStatus
|
||||
@@ -152,12 +155,10 @@ public:
|
||||
|
||||
Json::Value getJson (int options, bool binary = false) const;
|
||||
|
||||
static Transaction::pointer load (uint256 const& id);
|
||||
static Transaction::pointer load (uint256 const& id, Application& app);
|
||||
|
||||
private:
|
||||
uint256 mTransactionID;
|
||||
// VFALCO NOTE This member appears unused
|
||||
AccountID mAccountFrom;
|
||||
RippleAddress mFromPubKey; // Sign transaction with this. mSignPubKey
|
||||
RippleAddress mSourcePrivate; // Sign transaction with this.
|
||||
|
||||
@@ -166,7 +167,8 @@ private:
|
||||
TER mResult = temUNCERTAIN;
|
||||
bool mApplying = false;
|
||||
|
||||
STTx::pointer mTransaction;
|
||||
STTx::pointer mTransaction;
|
||||
Application& mApp;
|
||||
};
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -26,12 +26,16 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class Application;
|
||||
|
||||
// Tracks all transactions in memory
|
||||
|
||||
class TransactionMaster
|
||||
{
|
||||
public:
|
||||
TransactionMaster ();
|
||||
TransactionMaster (Application& app);
|
||||
TransactionMaster (TransactionMaster const&) = delete;
|
||||
TransactionMaster& operator= (TransactionMaster const&) = delete;
|
||||
|
||||
Transaction::pointer fetch (uint256 const& , bool checkDisk);
|
||||
STTx::pointer fetch (std::shared_ptr<SHAMapItem> const& item, SHAMapTreeNode:: TNType type,
|
||||
@@ -44,6 +48,7 @@ public:
|
||||
TaggedCache <uint256, Transaction>& getCache();
|
||||
|
||||
private:
|
||||
Application& mApp;
|
||||
TaggedCache <uint256, Transaction> mCache;
|
||||
};
|
||||
|
||||
|
||||
@@ -835,7 +835,7 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel)
|
||||
&qualityDirDescriber, std::placeholders::_1,
|
||||
std::placeholders::_2, saTakerPays.getCurrency (),
|
||||
uPaysIssuerID, saTakerGets.getCurrency (),
|
||||
uGetsIssuerID, uRate));
|
||||
uGetsIssuerID, uRate, std::ref(ctx_.app)));
|
||||
}
|
||||
|
||||
if (result == tesSUCCESS)
|
||||
|
||||
@@ -31,15 +31,15 @@
|
||||
namespace ripple {
|
||||
|
||||
Transaction::Transaction (STTx::ref stx, Validate validate,
|
||||
SigVerify sigVerify, std::string& reason)
|
||||
SigVerify sigVerify, std::string& reason, Application& app)
|
||||
noexcept
|
||||
: mTransaction (stx)
|
||||
, mApp (app)
|
||||
{
|
||||
try
|
||||
{
|
||||
mFromPubKey.setAccountPublic (mTransaction->getSigningPubKey ());
|
||||
mTransactionID = mTransaction->getTransactionID ();
|
||||
mAccountFrom = mTransaction->getAccountID(sfAccount);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ Transaction::Transaction (STTx::ref stx, Validate validate,
|
||||
}
|
||||
|
||||
Transaction::pointer Transaction::sharedTransaction (
|
||||
Blob const& vucTransaction, Validate validate)
|
||||
Blob const& vucTransaction, Validate validate, Application& app)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -69,7 +69,7 @@ Transaction::pointer Transaction::sharedTransaction (
|
||||
std::string reason;
|
||||
|
||||
return std::make_shared<Transaction> (std::make_shared<STTx> (sit),
|
||||
validate, getApp().getHashRouter().sigVerify(), reason);
|
||||
validate, app.getHashRouter().sigVerify(), reason, app);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
@@ -90,7 +90,7 @@ Transaction::pointer Transaction::sharedTransaction (
|
||||
|
||||
bool Transaction::checkSign (std::string& reason, SigVerify sigVerify) const
|
||||
{
|
||||
bool const allowMultiSign = getApp().getLedgerMaster().
|
||||
bool const allowMultiSign = mApp.getLedgerMaster().
|
||||
getValidatedRules().enabled (featureMultiSign, getConfig().features);
|
||||
|
||||
if (! mFromPubKey.isValid ())
|
||||
@@ -135,7 +135,8 @@ Transaction::pointer Transaction::transactionFromSQL (
|
||||
boost::optional<std::uint64_t> const& ledgerSeq,
|
||||
boost::optional<std::string> const& status,
|
||||
Blob const& rawTxn,
|
||||
Validate validate)
|
||||
Validate validate,
|
||||
Application& app)
|
||||
{
|
||||
std::uint32_t const inLedger =
|
||||
rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or (0));
|
||||
@@ -144,14 +145,14 @@ Transaction::pointer Transaction::transactionFromSQL (
|
||||
auto txn = std::make_shared<STTx> (it);
|
||||
std::string reason;
|
||||
auto tr = std::make_shared<Transaction> (txn, validate,
|
||||
getApp().getHashRouter().sigVerify(), reason);
|
||||
app.getHashRouter().sigVerify(), reason, app);
|
||||
|
||||
tr->setStatus (sqlTransactionStatus (status));
|
||||
tr->setLedger (inLedger);
|
||||
return tr;
|
||||
}
|
||||
|
||||
Transaction::pointer Transaction::load (uint256 const& id)
|
||||
Transaction::pointer Transaction::load (uint256 const& id, Application& app)
|
||||
{
|
||||
std::string sql = "SELECT LedgerSeq,Status,RawTxn "
|
||||
"FROM Transactions WHERE TransID='";
|
||||
@@ -162,7 +163,7 @@ Transaction::pointer Transaction::load (uint256 const& id)
|
||||
boost::optional<std::string> status;
|
||||
Blob rawTxn;
|
||||
{
|
||||
auto db = getApp().getTxnDB ().checkoutDb ();
|
||||
auto db = app.getTxnDB ().checkoutDb ();
|
||||
soci::blob sociRawTxnBlob (*db);
|
||||
soci::indicator rti;
|
||||
|
||||
@@ -175,7 +176,7 @@ Transaction::pointer Transaction::load (uint256 const& id)
|
||||
}
|
||||
|
||||
return Transaction::transactionFromSQL (
|
||||
ledgerSeq, status, rawTxn, Validate::YES);
|
||||
ledgerSeq, status, rawTxn, Validate::YES, app);
|
||||
}
|
||||
|
||||
// options 1 to include the date of the transaction
|
||||
@@ -190,7 +191,7 @@ Json::Value Transaction::getJson (int options, bool binary) const
|
||||
|
||||
if (options == 1)
|
||||
{
|
||||
auto ledger = getApp().getLedgerMaster ().
|
||||
auto ledger = mApp.getLedgerMaster ().
|
||||
getLedgerBySeq (mInLedger);
|
||||
if (ledger)
|
||||
ret[jss::date] = ledger->info().closeTime;
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
TransactionMaster::TransactionMaster ()
|
||||
: mCache ("TransactionCache", 65536, 1800, stopwatch(),
|
||||
TransactionMaster::TransactionMaster (Application& app)
|
||||
: mApp (app)
|
||||
, mCache ("TransactionCache", 65536, 1800, stopwatch(),
|
||||
deprecatedLogs().journal("TaggedCache"))
|
||||
{
|
||||
}
|
||||
@@ -49,7 +50,7 @@ Transaction::pointer TransactionMaster::fetch (uint256 const& txnID, bool checkD
|
||||
if (!checkDisk || txn)
|
||||
return txn;
|
||||
|
||||
txn = Transaction::load (txnID);
|
||||
txn = Transaction::load (txnID, mApp);
|
||||
|
||||
if (!txn)
|
||||
return txn;
|
||||
@@ -64,7 +65,7 @@ STTx::pointer TransactionMaster::fetch (std::shared_ptr<SHAMapItem> const& item,
|
||||
bool checkDisk, std::uint32_t uCommitLedger)
|
||||
{
|
||||
STTx::pointer txn;
|
||||
auto iTx = getApp().getMasterTransaction ().fetch (item->key(), false);
|
||||
auto iTx = fetch (item->key(), false);
|
||||
|
||||
if (!iTx)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace test {
|
||||
*/
|
||||
inline
|
||||
bool
|
||||
isOffer (jtx::Env const& env,
|
||||
isOffer (jtx::Env& env,
|
||||
jtx::Account const& account,
|
||||
STAmount const& takerPays,
|
||||
STAmount const& takerGets)
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/ledger/View.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/ledger/View.h>
|
||||
#include <ripple/test/jtx.h>
|
||||
#include <beast/unit_test/suite.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -34,14 +35,16 @@ class SkipList_test : public beast::unit_test::suite
|
||||
beast::Journal const j;
|
||||
std::vector<std::shared_ptr<Ledger>> history;
|
||||
{
|
||||
jtx::Env env(*this);
|
||||
Config const config;
|
||||
auto prev =
|
||||
std::make_shared<Ledger>(create_genesis, config);
|
||||
std::make_shared<Ledger>(create_genesis, config, env.app().family());
|
||||
history.push_back(prev);
|
||||
for (auto i = 0; i < 1023; ++i)
|
||||
{
|
||||
auto next = std::make_shared<Ledger>(
|
||||
open_ledger, *prev);
|
||||
open_ledger, *prev,
|
||||
env.app().timeKeeper().closeTime());
|
||||
next->updateSkipList();
|
||||
next->setClosed();
|
||||
history.push_back(next);
|
||||
|
||||
@@ -147,13 +147,15 @@ class View_test
|
||||
testLedger()
|
||||
{
|
||||
using namespace jtx;
|
||||
Env env(*this);
|
||||
Config const config;
|
||||
std::shared_ptr<Ledger const> const genesis =
|
||||
std::make_shared<Ledger>(
|
||||
create_genesis, config);
|
||||
create_genesis, config, env.app().family());
|
||||
auto const ledger =
|
||||
std::make_shared<Ledger>(
|
||||
open_ledger, *genesis);
|
||||
open_ledger, *genesis,
|
||||
env.app().timeKeeper().closeTime());
|
||||
wipe(*ledger);
|
||||
ReadView& v = *ledger;
|
||||
succ(v, 0, boost::none);
|
||||
@@ -409,13 +411,14 @@ class View_test
|
||||
testSles()
|
||||
{
|
||||
using namespace jtx;
|
||||
Env env(*this);
|
||||
Config const config;
|
||||
std::shared_ptr<Ledger const> const genesis =
|
||||
std::make_shared<Ledger> (
|
||||
create_genesis, config);
|
||||
auto const ledger =
|
||||
std::make_shared<Ledger> (
|
||||
open_ledger, *genesis);
|
||||
create_genesis, config, env.app().family());
|
||||
auto const ledger = std::make_shared<Ledger>(
|
||||
open_ledger, *genesis,
|
||||
env.app().timeKeeper().closeTime());
|
||||
auto setup123 = [&ledger, this]()
|
||||
{
|
||||
// erase middle element
|
||||
@@ -489,13 +492,15 @@ class View_test
|
||||
// ApplyView on that, then another ApplyView,
|
||||
// erase the item, apply.
|
||||
{
|
||||
Env env(*this);
|
||||
Config const config;
|
||||
std::shared_ptr<Ledger const> const genesis =
|
||||
std::make_shared<Ledger>(
|
||||
create_genesis, config);
|
||||
create_genesis, config, env.app().family());
|
||||
auto const ledger =
|
||||
std::make_shared<Ledger>(
|
||||
open_ledger, *genesis);
|
||||
open_ledger, *genesis,
|
||||
env.app().timeKeeper().closeTime());
|
||||
wipe(*ledger);
|
||||
ledger->rawInsert(sle(1));
|
||||
ReadView& v0 = *ledger;
|
||||
|
||||
@@ -156,14 +156,15 @@ ManifestCache::configValidatorKey(
|
||||
}
|
||||
|
||||
void
|
||||
ManifestCache::configManifest(Manifest m, beast::Journal const& journal)
|
||||
ManifestCache::configManifest (
|
||||
Manifest m, UniqueNodeList& unl, beast::Journal const& journal)
|
||||
{
|
||||
if (!m.verify())
|
||||
{
|
||||
throw std::runtime_error("Unverifiable manifest in config");
|
||||
}
|
||||
|
||||
auto const result = applyManifest (std::move(m), journal);
|
||||
auto const result = applyManifest (std::move(m), unl, journal);
|
||||
|
||||
if (result != ManifestDisposition::accepted)
|
||||
{
|
||||
@@ -225,7 +226,8 @@ ManifestCache::canApply (PublicKey const& pk, std::uint32_t seq,
|
||||
|
||||
|
||||
ManifestDisposition
|
||||
ManifestCache::applyManifest (Manifest m, beast::Journal const& journal)
|
||||
ManifestCache::applyManifest (
|
||||
Manifest m, UniqueNodeList& unl, beast::Journal const& journal)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock (mutex_);
|
||||
@@ -253,8 +255,6 @@ ManifestCache::applyManifest (Manifest m, beast::Journal const& journal)
|
||||
return ManifestDisposition::invalid;
|
||||
}
|
||||
|
||||
auto& unl = getApp().getUNL();
|
||||
|
||||
std::lock_guard<std::mutex> lock (mutex_);
|
||||
|
||||
/*
|
||||
@@ -334,7 +334,7 @@ ManifestCache::applyManifest (Manifest m, beast::Journal const& journal)
|
||||
}
|
||||
|
||||
void ManifestCache::load (
|
||||
DatabaseCon& dbCon, beast::Journal const& journal)
|
||||
DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal const& journal)
|
||||
{
|
||||
static const char* const sql =
|
||||
"SELECT RawData FROM ValidatorManifests;";
|
||||
@@ -358,7 +358,7 @@ void ManifestCache::load (
|
||||
map_[mo->masterKey];
|
||||
|
||||
// OK if not accepted (may have been loaded from the config file)
|
||||
applyManifest (std::move(*mo), journal);
|
||||
applyManifest (std::move(*mo), unl, journal);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_OVERLAY_MANIFEST_H_INCLUDED
|
||||
#define RIPPLE_OVERLAY_MANIFEST_H_INCLUDED
|
||||
|
||||
#include <ripple/app/misc/UniqueNodeList.h>
|
||||
#include <ripple/basics/BasicConfig.h>
|
||||
#include <ripple/basics/UnorderedContainers.h>
|
||||
#include <ripple/protocol/PublicKey.h>
|
||||
@@ -193,14 +194,16 @@ public:
|
||||
~ManifestCache() = default;
|
||||
|
||||
void configValidatorKey(std::string const& line, beast::Journal const& journal);
|
||||
void configManifest(Manifest m, beast::Journal const& journal);
|
||||
void configManifest (Manifest m, UniqueNodeList& unl, beast::Journal const& journal);
|
||||
|
||||
void addTrustedKey (PublicKey const& pk, std::string comment);
|
||||
|
||||
ManifestDisposition
|
||||
applyManifest (Manifest m, beast::Journal const& journal);
|
||||
applyManifest (
|
||||
Manifest m, UniqueNodeList& unl, beast::Journal const& journal);
|
||||
|
||||
void load (DatabaseCon& dbCon, beast::Journal const& journal);
|
||||
void load (
|
||||
DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal const& journal);
|
||||
void save (DatabaseCon& dbCon) const;
|
||||
|
||||
// A "for_each" for populated manifests only
|
||||
|
||||
@@ -459,7 +459,7 @@ OverlayImpl::setupValidatorKeyManifests (BasicConfig const& config,
|
||||
s = beast::base64_decode(s);
|
||||
if (auto mo = make_Manifest (std::move (s)))
|
||||
{
|
||||
manifestCache_.configManifest (std::move (*mo), journal_);
|
||||
manifestCache_.configManifest (std::move (*mo), app_.getUNL (), journal_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -472,7 +472,7 @@ OverlayImpl::setupValidatorKeyManifests (BasicConfig const& config,
|
||||
journal_.warning << "No [validation_manifest] section in config";
|
||||
}
|
||||
|
||||
manifestCache_.load (db, journal_);
|
||||
manifestCache_.load (db, app_.getUNL(), journal_);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -657,7 +657,7 @@ OverlayImpl::onManifests (
|
||||
|
||||
auto const serialized = mo->serialized;
|
||||
auto const result =
|
||||
manifestCache_.applyManifest (std::move(*mo), journal);
|
||||
manifestCache_.applyManifest (std::move(*mo), app_.getUNL(), journal);
|
||||
|
||||
if (result == ManifestDisposition::accepted)
|
||||
{
|
||||
|
||||
@@ -1737,7 +1737,7 @@ PeerImp::checkTransaction (int flags, STTx::pointer stx)
|
||||
std::string reason;
|
||||
auto tx = std::make_shared<Transaction> (stx, validate,
|
||||
directSigVerify,
|
||||
reason);
|
||||
reason, app_);
|
||||
|
||||
if (tx->getStatus () == INVALID)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <ripple/protocol/SecretKey.h>
|
||||
#include <ripple/protocol/Sign.h>
|
||||
#include <ripple/protocol/STExchange.h>
|
||||
#include <ripple/test/jtx.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
@@ -121,7 +122,7 @@ public:
|
||||
return Manifest (m.serialized, m.masterKey, m.signingKey, m.sequence);
|
||||
}
|
||||
|
||||
void testLoadStore (ManifestCache const& m)
|
||||
void testLoadStore (ManifestCache const& m, UniqueNodeList& unl)
|
||||
{
|
||||
testcase ("load/store");
|
||||
|
||||
@@ -137,7 +138,7 @@ public:
|
||||
|
||||
ManifestCache loaded;
|
||||
beast::Journal journal;
|
||||
loaded.load (dbCon, journal);
|
||||
loaded.load (dbCon, unl, journal);
|
||||
|
||||
auto getPopulatedManifests =
|
||||
[](ManifestCache const& cache) -> std::vector<Manifest const*>
|
||||
@@ -183,6 +184,8 @@ public:
|
||||
run() override
|
||||
{
|
||||
ManifestCache cache;
|
||||
test::jtx::Env env(*this);
|
||||
auto& unl = env.app().getUNL();
|
||||
{
|
||||
testcase ("apply");
|
||||
auto const accepted = ManifestDisposition::accepted;
|
||||
@@ -207,26 +210,26 @@ public:
|
||||
make_Manifest (KeyType::ed25519, sk_b, kp_b.first, 2, true); // broken
|
||||
auto const fake = s_b1.serialized + '\0';
|
||||
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == untrusted,
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == untrusted,
|
||||
"have to install a trusted key first");
|
||||
|
||||
cache.addTrustedKey (pk_a, "a");
|
||||
cache.addTrustedKey (pk_b, "b");
|
||||
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == stale);
|
||||
|
||||
expect (cache.applyManifest (clone (s_a1), journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a1), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a1), unl, journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a1), unl, journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == stale);
|
||||
|
||||
expect (cache.applyManifest (clone (s_b0), journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_b0), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_b0), unl, journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_b0), unl, journal) == stale);
|
||||
|
||||
expect (!ripple::make_Manifest(fake));
|
||||
expect (cache.applyManifest (clone (s_b2), journal) == invalid);
|
||||
expect (cache.applyManifest (clone (s_b2), unl, journal) == invalid);
|
||||
}
|
||||
testLoadStore (cache);
|
||||
testLoadStore (cache, unl);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ struct Context
|
||||
NetworkOPs& netOps;
|
||||
LedgerMaster& ledgerMaster;
|
||||
Role role;
|
||||
InfoSub::pointer infoSub;
|
||||
JobQueueSuspender suspend;
|
||||
InfoSub::pointer infoSub;
|
||||
NodeStore::ScopedMetrics metrics;
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ ripplePathFind (RippleLineCache::pointer const& cache,
|
||||
Json::Value const& jvSrcCurrencies,
|
||||
boost::optional<Json::Value> const& contextPaths,
|
||||
int const& level, boost::optional<STAmount> saSendMax,
|
||||
bool convert_all);
|
||||
bool convert_all, Application& app);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class Application;
|
||||
class BasicConfig;
|
||||
class JobQueue;
|
||||
class Section;
|
||||
@@ -119,13 +120,13 @@ struct JobQueueSuspender
|
||||
|
||||
/** Create a JobQueueSuspender where yield does nothing and the suspend
|
||||
immediately executes the continuation. */
|
||||
JobQueueSuspender();
|
||||
JobQueueSuspender(Application&);
|
||||
|
||||
/** Create a JobQueueSuspender with a Suspend.
|
||||
|
||||
When yield is called, it reschedules the current job on the JobQueue
|
||||
with the given jobName. */
|
||||
JobQueueSuspender(Suspend const&, std::string const& jobName);
|
||||
JobQueueSuspender(Application&, Suspend const&, std::string const& jobName);
|
||||
};
|
||||
|
||||
} // RPC
|
||||
|
||||
@@ -69,7 +69,7 @@ buildSrcCurrencies(AccountID const& account,
|
||||
// This interface is deprecated.
|
||||
Json::Value doRipplePathFind (RPC::Context& context)
|
||||
{
|
||||
RPC::LegacyPathFind lpf (context.role == Role::ADMIN);
|
||||
RPC::LegacyPathFind lpf (context.role == Role::ADMIN, context.app);
|
||||
if (!lpf.isOk ())
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
|
||||
@@ -244,7 +244,8 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
boost::optional<Json::Value>(context.params[jss::paths]) :
|
||||
boost::optional<Json::Value>(boost::none);
|
||||
auto pathFindResult = ripplePathFind(cache, raSrc, raDst, saDstAmount,
|
||||
jvSrcCurrencies, contextPaths, level, saSendMax, convert_all);
|
||||
jvSrcCurrencies, contextPaths, level, saSendMax, convert_all,
|
||||
context.app);
|
||||
if (!pathFindResult.first)
|
||||
return pathFindResult.second;
|
||||
|
||||
@@ -264,7 +265,7 @@ ripplePathFind (RippleLineCache::pointer const& cache,
|
||||
STAmount const& saDstAmount, Json::Value const& jvSrcCurrencies,
|
||||
boost::optional<Json::Value> const& contextPaths,
|
||||
int const& level, boost::optional<STAmount> saSendMax,
|
||||
bool convert_all)
|
||||
bool convert_all, Application& app)
|
||||
{
|
||||
auto const sa = STAmount(saDstAmount.issue(),
|
||||
STAmount::cMaxValue, STAmount::cMaxOffset);
|
||||
@@ -356,7 +357,8 @@ ripplePathFind (RippleLineCache::pointer const& cache,
|
||||
auto result = fp.findPathsForIssue(
|
||||
issue,
|
||||
spsComputed,
|
||||
fullLiquidityPath);
|
||||
fullLiquidityPath,
|
||||
app);
|
||||
if (! result)
|
||||
{
|
||||
WriteLog(lsWARNING, RPCHandler)
|
||||
|
||||
@@ -50,7 +50,7 @@ Json::Value doSignFor (RPC::Context& context)
|
||||
failType,
|
||||
context.role,
|
||||
context.ledgerMaster.getValidatedLedgerAge(),
|
||||
context.app.getFeeTrack(),
|
||||
context.app,
|
||||
context.ledgerMaster.getCurrentLedger());
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ Json::Value doSign (RPC::Context& context)
|
||||
failType,
|
||||
context.role,
|
||||
context.ledgerMaster.getValidatedLedgerAge(),
|
||||
context.app.getFeeTrack(),
|
||||
context.app,
|
||||
context.ledgerMaster.getCurrentLedger());
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ Json::Value doSubmit (RPC::Context& context)
|
||||
failType,
|
||||
context.role,
|
||||
context.ledgerMaster.getValidatedLedgerAge(),
|
||||
context.app.getFeeTrack(),
|
||||
context.app,
|
||||
context.ledgerMaster.getCurrentLedger(),
|
||||
RPC::getProcessTxnFn (context.netOps));
|
||||
}
|
||||
@@ -83,7 +83,7 @@ Json::Value doSubmit (RPC::Context& context)
|
||||
Transaction::pointer tpTrans;
|
||||
std::string reason;
|
||||
tpTrans = std::make_shared<Transaction> (stpTrans, Validate::YES,
|
||||
context.app.getHashRouter().sigVerify(), reason);
|
||||
context.app.getHashRouter().sigVerify(), reason, context.app);
|
||||
if (tpTrans->getStatus() != NEW)
|
||||
{
|
||||
jvResult[jss::error] = "invalidTransaction";
|
||||
|
||||
@@ -49,7 +49,7 @@ Json::Value doSubmitMultiSigned (RPC::Context& context)
|
||||
failType,
|
||||
context.role,
|
||||
context.ledgerMaster.getValidatedLedgerAge(),
|
||||
context.app.getFeeTrack(),
|
||||
context.app,
|
||||
context.ledgerMaster.getCurrentLedger(),
|
||||
RPC::getProcessTxnFn (context.netOps));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ Json::Value doTxHistory (RPC::Context& context)
|
||||
rawTxn.clear ();
|
||||
|
||||
if (auto trans = Transaction::transactionFromSQL (
|
||||
ledgerSeq, status, rawTxn, Validate::NO))
|
||||
ledgerSeq, status, rawTxn, Validate::NO, context.app))
|
||||
txs.append (trans->getJson (0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace ripple {
|
||||
namespace RPC {
|
||||
|
||||
LegacyPathFind::LegacyPathFind (bool isAdmin) : m_isOk (false)
|
||||
LegacyPathFind::LegacyPathFind (bool isAdmin, Application& app) : m_isOk (false)
|
||||
{
|
||||
if (isAdmin)
|
||||
{
|
||||
@@ -37,8 +37,8 @@ LegacyPathFind::LegacyPathFind (bool isAdmin) : m_isOk (false)
|
||||
return;
|
||||
}
|
||||
|
||||
auto const& jobCount = getApp().getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
if (jobCount > Tuning::maxPathfindJobCount || getApp().getFeeTrack().isLoadedLocal ())
|
||||
auto const& jobCount = app.getJobQueue ().getJobCountGE (jtCLIENT);
|
||||
if (jobCount > Tuning::maxPathfindJobCount || app.getFeeTrack().isLoadedLocal ())
|
||||
return;
|
||||
|
||||
while (true)
|
||||
|
||||
@@ -23,12 +23,15 @@
|
||||
#include <atomic>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class Application;
|
||||
|
||||
namespace RPC {
|
||||
|
||||
class LegacyPathFind
|
||||
{
|
||||
public:
|
||||
LegacyPathFind (bool isAdmin);
|
||||
LegacyPathFind (bool isAdmin, Application& app);
|
||||
~LegacyPathFind ();
|
||||
|
||||
bool isOk () const
|
||||
|
||||
@@ -137,7 +137,8 @@ Status ledgerFromRequest (T& ledger, Context& context)
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger)
|
||||
bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger,
|
||||
Application& app)
|
||||
{
|
||||
if (ledger.info().validated)
|
||||
return true;
|
||||
@@ -158,7 +159,7 @@ bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger)
|
||||
// This ledger's hash is not the hash of the validated ledger
|
||||
if (hash.isNonZero ())
|
||||
{
|
||||
uint256 valHash = Ledger::getHashByIndex (seq);
|
||||
uint256 valHash = getHashByIndex (seq, app);
|
||||
if (valHash == ledger.info().hash)
|
||||
{
|
||||
// SQL database doesn't match ledger chain
|
||||
@@ -220,7 +221,7 @@ Status lookupLedger (
|
||||
result[jss::ledger_current_index] = info.seq;
|
||||
}
|
||||
|
||||
result[jss::validated] = isValidated (context.ledgerMaster, *ledger);
|
||||
result[jss::validated] = isValidated (context.ledgerMaster, *ledger, context.app);
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ static Json::Value checkPayment(
|
||||
Json::Value& tx_json,
|
||||
AccountID const& srcAddressID,
|
||||
Role const role,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const>& ledger,
|
||||
bool doPath)
|
||||
{
|
||||
@@ -187,7 +188,7 @@ static Json::Value checkPayment(
|
||||
"Cannot build XRP to XRP paths.");
|
||||
|
||||
{
|
||||
LegacyPathFind lpf (role == Role::ADMIN);
|
||||
LegacyPathFind lpf (role == Role::ADMIN, app);
|
||||
if (!lpf.isOk ())
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
|
||||
@@ -202,7 +203,8 @@ static Json::Value checkPayment(
|
||||
getConfig().PATH_SEARCH_OLD,
|
||||
4, // iMaxPaths
|
||||
{},
|
||||
fullLiquidityPath);
|
||||
fullLiquidityPath,
|
||||
app);
|
||||
|
||||
if (! result)
|
||||
{
|
||||
@@ -329,7 +331,7 @@ transactionPreProcessImpl (
|
||||
Role role,
|
||||
SigningForParams& signingArgs,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger)
|
||||
{
|
||||
KeyPair keypair;
|
||||
@@ -349,8 +351,9 @@ transactionPreProcessImpl (
|
||||
Json::Value& tx_json (params [jss::tx_json]);
|
||||
|
||||
// Check tx_json fields, but don't add any.
|
||||
auto txJsonResult =
|
||||
checkTxJsonFields (tx_json, role, verify, validatedLedgerAge, feeTrack);
|
||||
auto txJsonResult = checkTxJsonFields (
|
||||
tx_json, role, verify, validatedLedgerAge, app.getFeeTrack());
|
||||
|
||||
if (RPC::contains_error (txJsonResult.first))
|
||||
return std::move (txJsonResult.first);
|
||||
|
||||
@@ -381,7 +384,7 @@ transactionPreProcessImpl (
|
||||
params,
|
||||
role,
|
||||
signingArgs.editFields(),
|
||||
feeTrack,
|
||||
app.getFeeTrack(),
|
||||
ledger);
|
||||
|
||||
if (RPC::contains_error (err))
|
||||
@@ -392,6 +395,7 @@ transactionPreProcessImpl (
|
||||
tx_json,
|
||||
srcAddressID,
|
||||
role,
|
||||
app,
|
||||
ledger,
|
||||
signingArgs.editFields());
|
||||
|
||||
@@ -498,7 +502,7 @@ transactionPreProcessImpl (
|
||||
|
||||
static
|
||||
std::pair <Json::Value, Transaction::pointer>
|
||||
transactionConstructImpl (STTx::pointer stpTrans)
|
||||
transactionConstructImpl (STTx::pointer stpTrans, Application& app)
|
||||
{
|
||||
std::pair <Json::Value, Transaction::pointer> ret;
|
||||
|
||||
@@ -507,7 +511,7 @@ transactionConstructImpl (STTx::pointer stpTrans)
|
||||
{
|
||||
std::string reason;
|
||||
tpTrans = std::make_shared<Transaction>(stpTrans, Validate::NO,
|
||||
directSigVerify, reason);
|
||||
directSigVerify, reason, app);
|
||||
if (tpTrans->getStatus () != NEW)
|
||||
{
|
||||
ret.first = RPC::make_error (rpcINTERNAL,
|
||||
@@ -526,7 +530,7 @@ transactionConstructImpl (STTx::pointer stpTrans)
|
||||
tpTrans->getSTransaction ()->add (s);
|
||||
|
||||
Transaction::pointer tpTransNew =
|
||||
Transaction::sharedTransaction (s.getData (), Validate::YES);
|
||||
Transaction::sharedTransaction(s.getData(), Validate::YES, app);
|
||||
|
||||
if (tpTransNew && (
|
||||
!tpTransNew->getSTransaction ()->isEquivalent (
|
||||
@@ -645,7 +649,7 @@ Json::Value transactionSign (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger)
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "transactionSign: " << jvRequest;
|
||||
@@ -655,14 +659,15 @@ Json::Value transactionSign (
|
||||
// Add and amend fields based on the transaction type.
|
||||
SigningForParams signForParams;
|
||||
transactionPreProcessResult preprocResult = transactionPreProcessImpl (
|
||||
jvRequest, role, signForParams, validatedLedgerAge, feeTrack, ledger);
|
||||
jvRequest, role, signForParams,
|
||||
validatedLedgerAge, app, ledger);
|
||||
|
||||
if (!preprocResult.second)
|
||||
return preprocResult.first;
|
||||
|
||||
// Make sure the STTx makes a legitimate Transaction.
|
||||
std::pair <Json::Value, Transaction::pointer> txn =
|
||||
transactionConstructImpl (preprocResult.second);
|
||||
transactionConstructImpl (preprocResult.second, app);
|
||||
|
||||
if (!txn.second)
|
||||
return txn.first;
|
||||
@@ -676,7 +681,7 @@ Json::Value transactionSubmit (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger,
|
||||
ProcessTransactionFn const& processTransaction)
|
||||
{
|
||||
@@ -687,14 +692,14 @@ Json::Value transactionSubmit (
|
||||
// Add and amend fields based on the transaction type.
|
||||
SigningForParams signForParams;
|
||||
transactionPreProcessResult preprocResult = transactionPreProcessImpl (
|
||||
jvRequest, role, signForParams, validatedLedgerAge, feeTrack, ledger);
|
||||
jvRequest, role, signForParams, validatedLedgerAge, app, ledger);
|
||||
|
||||
if (!preprocResult.second)
|
||||
return preprocResult.first;
|
||||
|
||||
// Make sure the STTx makes a legitimate Transaction.
|
||||
std::pair <Json::Value, Transaction::pointer> txn =
|
||||
transactionConstructImpl (preprocResult.second);
|
||||
transactionConstructImpl (preprocResult.second, app);
|
||||
|
||||
if (!txn.second)
|
||||
return txn.first;
|
||||
@@ -750,7 +755,7 @@ Json::Value transactionSignFor (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger)
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "transactionSignFor: " << jvRequest;
|
||||
@@ -790,7 +795,7 @@ Json::Value transactionSignFor (
|
||||
role,
|
||||
signForParams,
|
||||
validatedLedgerAge,
|
||||
feeTrack,
|
||||
app,
|
||||
ledger);
|
||||
|
||||
if (!preprocResult.second)
|
||||
@@ -811,7 +816,7 @@ Json::Value transactionSignFor (
|
||||
|
||||
// Make sure the STTx makes a legitimate Transaction.
|
||||
std::pair <Json::Value, Transaction::pointer> txn =
|
||||
transactionConstructImpl (preprocResult.second);
|
||||
transactionConstructImpl (preprocResult.second, app);
|
||||
|
||||
if (!txn.second)
|
||||
return txn.first;
|
||||
@@ -850,7 +855,7 @@ Json::Value transactionSubmitMultiSigned (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger,
|
||||
ProcessTransactionFn const& processTransaction)
|
||||
{
|
||||
@@ -868,8 +873,9 @@ Json::Value transactionSubmitMultiSigned (
|
||||
|
||||
Json::Value& tx_json (jvRequest ["tx_json"]);
|
||||
|
||||
auto const txJsonResult =
|
||||
checkTxJsonFields (tx_json, role, true, validatedLedgerAge, feeTrack);
|
||||
auto const txJsonResult = checkTxJsonFields (
|
||||
tx_json, role, true, validatedLedgerAge, app.getFeeTrack());
|
||||
|
||||
if (RPC::contains_error (txJsonResult.first))
|
||||
return std::move (txJsonResult.first);
|
||||
|
||||
@@ -890,7 +896,8 @@ Json::Value transactionSubmitMultiSigned (
|
||||
}
|
||||
|
||||
{
|
||||
Json::Value err = checkFee (jvRequest, role, false, feeTrack, ledger);
|
||||
Json::Value err = checkFee (
|
||||
jvRequest, role, false, app.getFeeTrack(), ledger);
|
||||
|
||||
if (RPC::contains_error(err))
|
||||
return std::move (err);
|
||||
@@ -900,6 +907,7 @@ Json::Value transactionSubmitMultiSigned (
|
||||
tx_json,
|
||||
srcAddressID,
|
||||
role,
|
||||
app,
|
||||
ledger,
|
||||
false);
|
||||
|
||||
@@ -1045,7 +1053,7 @@ Json::Value transactionSubmitMultiSigned (
|
||||
|
||||
// Make sure the SerializedTransaction makes a legitimate Transaction.
|
||||
std::pair <Json::Value, Transaction::pointer> txn =
|
||||
transactionConstructImpl (stpTrans);
|
||||
transactionConstructImpl (stpTrans, app);
|
||||
|
||||
if (!txn.second)
|
||||
return txn.first;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
namespace ripple {
|
||||
|
||||
// Forward declarations
|
||||
class Application;
|
||||
class LoadFeeTrack;
|
||||
|
||||
namespace RPC {
|
||||
@@ -78,7 +79,7 @@ Json::Value transactionSign (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger);
|
||||
|
||||
/** Returns a Json::objectValue. */
|
||||
@@ -87,7 +88,7 @@ Json::Value transactionSubmit (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger,
|
||||
ProcessTransactionFn const& processTransaction);
|
||||
|
||||
@@ -97,7 +98,7 @@ Json::Value transactionSignFor (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger);
|
||||
|
||||
/** Returns a Json::objectValue. */
|
||||
@@ -106,7 +107,7 @@ Json::Value transactionSubmitMultiSigned (
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger,
|
||||
ProcessTransactionFn const& processTransaction);
|
||||
|
||||
|
||||
@@ -36,18 +36,20 @@ Suspend const dontSuspend = [] (Continuation const& continuation)
|
||||
|
||||
namespace {
|
||||
|
||||
void runOnJobQueue(std::string const& name, Callback const& callback)
|
||||
void runOnJobQueue(
|
||||
Application& app, std::string const& name, Callback const& callback)
|
||||
{
|
||||
auto cb = [callback] (Job&) { callback(); };
|
||||
getApp().getJobQueue().addJob(jtCLIENT, name, cb);
|
||||
app.getJobQueue().addJob(jtCLIENT, name, cb);
|
||||
};
|
||||
|
||||
Callback suspendForJobQueue(Suspend const& suspend, std::string const& jobName)
|
||||
Callback suspendForJobQueue(
|
||||
Application& app, Suspend const& suspend, std::string const& jobName)
|
||||
{
|
||||
assert(suspend);
|
||||
return Callback( [suspend, jobName] () {
|
||||
suspend([jobName] (Callback const& callback) {
|
||||
runOnJobQueue(jobName, callback);
|
||||
return Callback( [suspend, jobName, &app] () {
|
||||
suspend([jobName, &app] (Callback const& callback) {
|
||||
runOnJobQueue(app, jobName, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -112,15 +114,16 @@ YieldStrategy makeYieldStrategy (BasicConfig const& config)
|
||||
}
|
||||
|
||||
JobQueueSuspender::JobQueueSuspender(
|
||||
Suspend const& susp, std::string const& jobName)
|
||||
Application& app, Suspend const& susp, std::string const& jobName)
|
||||
: suspend(susp ? susp : dontSuspend),
|
||||
yield(suspendForJobQueue(suspend, jobName))
|
||||
yield(suspendForJobQueue(app, suspend, jobName))
|
||||
{
|
||||
// There's a non-empty jobName exactly if there's a non-empty Suspend.
|
||||
assert(!(susp && jobName.empty()));
|
||||
}
|
||||
|
||||
JobQueueSuspender::JobQueueSuspender() : JobQueueSuspender({}, {})
|
||||
JobQueueSuspender::JobQueueSuspender(Application &app)
|
||||
: JobQueueSuspender(app, {}, {})
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1396,9 +1396,10 @@ class JSONRPC_test : public beast::unit_test::suite
|
||||
public:
|
||||
void testAutoFillFees ()
|
||||
{
|
||||
test::jtx::Env env(*this);
|
||||
Config const config;
|
||||
std::shared_ptr<const ReadView> ledger =
|
||||
std::make_shared<Ledger>(create_genesis, config);
|
||||
std::make_shared<Ledger>(create_genesis, config, env.app().family());
|
||||
LoadFeeTrack const feeTrack;
|
||||
|
||||
{
|
||||
@@ -1451,8 +1452,6 @@ public:
|
||||
|
||||
auto const ledger = env.open();
|
||||
|
||||
LoadFeeTrack const feeTrack;
|
||||
|
||||
ProcessTransactionFn processTxn = fakeProcessTransaction;
|
||||
|
||||
// A list of all the functions we want to test.
|
||||
@@ -1461,7 +1460,7 @@ public:
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger);
|
||||
|
||||
using submitFunc = Json::Value (*) (
|
||||
@@ -1469,7 +1468,7 @@ public:
|
||||
NetworkOPs::FailHard failType,
|
||||
Role role,
|
||||
int validatedLedgerAge,
|
||||
LoadFeeTrack const& feeTrack,
|
||||
Application& app,
|
||||
std::shared_ptr<ReadView const> ledger,
|
||||
ProcessTransactionFn const& processTransaction);
|
||||
|
||||
@@ -1510,7 +1509,7 @@ public:
|
||||
NetworkOPs::FailHard::yes,
|
||||
testRole,
|
||||
1,
|
||||
feeTrack,
|
||||
env.app(),
|
||||
ledger);
|
||||
}
|
||||
else
|
||||
@@ -1522,7 +1521,7 @@ public:
|
||||
NetworkOPs::FailHard::yes,
|
||||
testRole,
|
||||
1,
|
||||
feeTrack,
|
||||
env.app(),
|
||||
ledger,
|
||||
processTxn);
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ ServerHandlerImp::processRequest (
|
||||
|
||||
RPC::Context context {
|
||||
params, app_, loadType, m_networkOPs, app_.getLedgerMaster(), role,
|
||||
nullptr, {suspend, "RPC-Coroutine"}};
|
||||
{app_, suspend, "RPC-Coroutine"}};
|
||||
|
||||
std::string response;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <cstdint>
|
||||
|
||||
namespace ripple {
|
||||
namespace shamap {
|
||||
|
||||
class Family
|
||||
{
|
||||
@@ -60,9 +59,12 @@ public:
|
||||
virtual
|
||||
void
|
||||
missing_node (std::uint32_t refNum) = 0;
|
||||
|
||||
virtual
|
||||
void
|
||||
missing_node (uint256 const& hash) = 0;
|
||||
};
|
||||
|
||||
} // shamap
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -79,7 +79,6 @@ using MissingNodeHandler = std::function <void (std::uint32_t refNum)>;
|
||||
class SHAMap
|
||||
{
|
||||
private:
|
||||
using Family = shamap::Family;
|
||||
using NodeStack = std::stack<std::pair<SHAMapAbstractNode*, SHAMapNodeID>,
|
||||
std::vector<std::pair<SHAMapAbstractNode*, SHAMapNodeID>>>;
|
||||
|
||||
@@ -115,6 +114,12 @@ public:
|
||||
Family& f,
|
||||
beast::Journal journal);
|
||||
|
||||
Family&
|
||||
family()
|
||||
{
|
||||
return f_;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/** Iterator to a SHAMap's leaves
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
namespace shamap {
|
||||
namespace tests {
|
||||
|
||||
class FetchPack_test : public beast::unit_test::suite
|
||||
@@ -164,6 +163,5 @@ public:
|
||||
BEAST_DEFINE_TESTSUITE(FetchPack,shamap,ripple);
|
||||
|
||||
} // tests
|
||||
} // shamap
|
||||
} // ripple
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <beast/utility/Journal.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace shamap {
|
||||
namespace tests {
|
||||
|
||||
inline bool operator== (SHAMapItem const& a, SHAMapItem const& b) { return a.key() == b.key(); }
|
||||
@@ -141,5 +140,4 @@ public:
|
||||
BEAST_DEFINE_TESTSUITE(SHAMap,ripple_app,ripple);
|
||||
|
||||
} // tests
|
||||
} // shamap
|
||||
} // ripple
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <openssl/rand.h> // DEPRECATED
|
||||
|
||||
namespace ripple {
|
||||
namespace shamap {
|
||||
namespace tests {
|
||||
|
||||
#ifdef BEAST_DEBUG
|
||||
@@ -227,5 +226,4 @@ public:
|
||||
BEAST_DEFINE_TESTSUITE(sync,shamap,ripple);
|
||||
|
||||
} // tests
|
||||
} // shamap
|
||||
} // ripple
|
||||
|
||||
@@ -33,10 +33,9 @@
|
||||
#include <beast/chrono/manual_clock.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace shamap {
|
||||
namespace tests {
|
||||
|
||||
class TestFamily : public shamap::Family
|
||||
class TestFamily : public Family
|
||||
{
|
||||
private:
|
||||
TestStopwatch clock_;
|
||||
@@ -105,10 +104,15 @@ public:
|
||||
{
|
||||
throw std::runtime_error("missing node");
|
||||
}
|
||||
|
||||
void
|
||||
missing_node (uint256 const& hash) override
|
||||
{
|
||||
throw std::runtime_error("missing node");
|
||||
}
|
||||
};
|
||||
|
||||
} // tests
|
||||
} // shamap
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -318,7 +318,7 @@ public:
|
||||
*/
|
||||
template <class... Args>
|
||||
void
|
||||
require (Args const&... args) const
|
||||
require (Args const&... args)
|
||||
{
|
||||
jtx::required(args...)(*this);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&) const;
|
||||
operator()(Env&) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jtx) const;
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const& env) const;
|
||||
operator()(Env& env) const;
|
||||
};
|
||||
|
||||
/** Match clear account flags */
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const& env) const;
|
||||
operator()(Env& env) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -57,7 +57,7 @@ Env::Env (beast::unit_test::suite& test_)
|
||||
KeyType::secp256k1,
|
||||
generateSeed("masterpassphrase")))
|
||||
, closed_ (std::make_shared<Ledger>(
|
||||
create_genesis, config))
|
||||
create_genesis, config, app().family()))
|
||||
, cachedSLEs_ (std::chrono::seconds(5), stopwatch_)
|
||||
, openLedger (closed_, config, cachedSLEs_, journal)
|
||||
{
|
||||
@@ -83,7 +83,8 @@ Env::close(NetClock::time_point const& closeTime)
|
||||
clock.set(closeTime);
|
||||
// VFALCO TODO Fix the Ledger constructor
|
||||
auto next = std::make_shared<Ledger>(
|
||||
open_ledger, *closed_);
|
||||
open_ledger, *closed_,
|
||||
app().timeKeeper().closeTime());
|
||||
next->setClosed();
|
||||
#if 0
|
||||
// Build a SHAMap, put all the transactions
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
balance::operator()(Env const& env) const
|
||||
balance::operator()(Env& env) const
|
||||
{
|
||||
if (isXRP(value_.issue()))
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
delivermin::operator()(Env const& env, JTx& jt) const
|
||||
delivermin::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[jss::DeliverMin] = amount_.getJson(0);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
fee::operator()(Env const&, JTx& jt) const
|
||||
fee::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
if (! manual_)
|
||||
return;
|
||||
|
||||
@@ -40,7 +40,7 @@ fset (Account const& account,
|
||||
}
|
||||
|
||||
void
|
||||
flags::operator()(Env const& env) const
|
||||
flags::operator()(Env& env) const
|
||||
{
|
||||
auto const sle = env.le(account_);
|
||||
if (sle->isFieldPresent(sfFlags))
|
||||
@@ -51,7 +51,7 @@ flags::operator()(Env const& env) const
|
||||
}
|
||||
|
||||
void
|
||||
nflags::operator()(Env const& env) const
|
||||
nflags::operator()(Env& env) const
|
||||
{
|
||||
auto const sle = env.le(account_);
|
||||
if (sle->isFieldPresent(sfFlags))
|
||||
|
||||
@@ -42,7 +42,7 @@ json::json (Json::Value jv)
|
||||
}
|
||||
|
||||
void
|
||||
json::operator()(Env const&, JTx& jt) const
|
||||
json::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
for (auto iter = jv_.begin();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
memo::operator()(Env const&, JTx& jt) const
|
||||
memo::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
@@ -39,7 +39,7 @@ memo::operator()(Env const&, JTx& jt) const
|
||||
}
|
||||
|
||||
void
|
||||
memodata::operator()(Env const&, JTx& jt) const
|
||||
memodata::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
@@ -49,7 +49,7 @@ memodata::operator()(Env const&, JTx& jt) const
|
||||
}
|
||||
|
||||
void
|
||||
memoformat::operator()(Env const&, JTx& jt) const
|
||||
memoformat::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
@@ -59,7 +59,7 @@ memoformat::operator()(Env const&, JTx& jt) const
|
||||
}
|
||||
|
||||
void
|
||||
memotype::operator()(Env const&, JTx& jt) const
|
||||
memotype::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
@@ -69,7 +69,7 @@ memotype::operator()(Env const&, JTx& jt) const
|
||||
}
|
||||
|
||||
void
|
||||
memondata::operator()(Env const&, JTx& jt) const
|
||||
memondata::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
@@ -80,7 +80,7 @@ memondata::operator()(Env const&, JTx& jt) const
|
||||
}
|
||||
|
||||
void
|
||||
memonformat::operator()(Env const&, JTx& jt) const
|
||||
memonformat::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
@@ -91,7 +91,7 @@ memonformat::operator()(Env const&, JTx& jt) const
|
||||
}
|
||||
|
||||
void
|
||||
memontype::operator()(Env const&, JTx& jt) const
|
||||
memontype::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto& ma = jv["Memos"];
|
||||
|
||||
@@ -74,7 +74,7 @@ msig::msig (std::vector<msig::Reg> signers_)
|
||||
}
|
||||
|
||||
void
|
||||
msig::operator()(Env const& env, JTx& jt) const
|
||||
msig::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
auto const mySigners = signers;
|
||||
jt.signer = [mySigners, &env](Env&, JTx& jt)
|
||||
|
||||
@@ -42,7 +42,7 @@ owned_count_of(ReadView const& view,
|
||||
}
|
||||
|
||||
void
|
||||
owned_count_helper(Env const& env,
|
||||
owned_count_helper(Env& env,
|
||||
AccountID const& id,
|
||||
LedgerEntryType type,
|
||||
std::uint32_t value)
|
||||
@@ -54,7 +54,7 @@ owned_count_helper(Env const& env,
|
||||
} // detail
|
||||
|
||||
void
|
||||
owners::operator()(Env const& env) const
|
||||
owners::operator()(Env& env) const
|
||||
{
|
||||
env.test.expect(env.le(
|
||||
account_)->getFieldU32(sfOwnerCount) ==
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
paths::operator()(Env const& env, JTx& jt) const
|
||||
paths::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
auto& jv = jt.jv;
|
||||
auto const from = env.lookup(
|
||||
@@ -41,7 +41,7 @@ paths::operator()(Env const& env, JTx& jt) const
|
||||
std::make_shared<RippleLineCache>(
|
||||
env.open()), from, to,
|
||||
in_, amount,
|
||||
depth_, limit_, {}, fp);
|
||||
depth_, limit_, {}, fp, env.app());
|
||||
// VFALCO TODO API to allow caller to examine the STPathSet
|
||||
// VFALCO isDefault should be renamed to empty()
|
||||
if (found && ! found->isDefault())
|
||||
@@ -80,7 +80,7 @@ path::append_one(BookSpec const& book)
|
||||
}
|
||||
|
||||
void
|
||||
path::operator()(Env const& env, JTx& jt) const
|
||||
path::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv["Paths"].append(jv_);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
sendmax::operator()(Env const& env, JTx& jt) const
|
||||
sendmax::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[jss::SendMax] = amount_.getJson(0);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
seq::operator()(Env const&, JTx& jt) const
|
||||
seq::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
if (! manual_)
|
||||
return;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
sig::operator()(Env const&, JTx& jt) const
|
||||
sig::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
if (! manual_)
|
||||
return;
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
dtag::operator()(Env const&, JTx& jt) const
|
||||
dtag::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
jt.jv["DestinationTag"] = value_;
|
||||
}
|
||||
|
||||
void
|
||||
stag::operator()(Env const&, JTx& jt) const
|
||||
stag::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
jt.jv["SourceTag"] = value_;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace test {
|
||||
namespace jtx {
|
||||
|
||||
void
|
||||
txflags::operator()(Env const&, JTx& jt) const
|
||||
txflags::operator()(Env&, JTx& jt) const
|
||||
{
|
||||
jt[jss::Flags] =
|
||||
v_ /*| tfUniversal*/;
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
class memodata
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
class memoformat
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
class memotype
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
class memondata
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
class memonformat
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
class memontype
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
|
||||
private:
|
||||
template <class AccountType>
|
||||
|
||||
@@ -38,7 +38,7 @@ owned_count_of (ReadView const& view,
|
||||
LedgerEntryType type);
|
||||
|
||||
void
|
||||
owned_count_helper(Env const& env,
|
||||
owned_count_helper(Env& env,
|
||||
AccountID const& id,
|
||||
LedgerEntryType type,
|
||||
std::uint32_t value);
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const& env) const
|
||||
operator()(Env& env) const
|
||||
{
|
||||
detail::owned_count_helper(
|
||||
env, account_.id(), Type, value_);
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const& env) const;
|
||||
operator()(Env& env) const;
|
||||
};
|
||||
|
||||
/** Match the number of trust lines in the account's owner directory */
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
path (T const& t, Args const&... args);
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
|
||||
private:
|
||||
Json::Value&
|
||||
|
||||
@@ -43,7 +43,7 @@ struct prop
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const& env, JTx& jt) const
|
||||
operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.set(p_->clone());
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ required (Args const&... args)
|
||||
{
|
||||
requires_t vec;
|
||||
detail::require_args(vec, args...);
|
||||
return [vec](Env const& env)
|
||||
return [vec](Env& env)
|
||||
{
|
||||
for(auto const& f : vec)
|
||||
f(env);
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const
|
||||
operator()(Env&, JTx& jt) const
|
||||
{
|
||||
jt.requires.emplace_back(cond_);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace jtx {
|
||||
|
||||
class Env;
|
||||
|
||||
using require_t = std::function<void(Env const&)>;
|
||||
using require_t = std::function<void(Env&)>;
|
||||
using requires_t = std::vector<require_t>;
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jtx) const;
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
/** Set the source tag on a JTx*/
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const
|
||||
operator()(Env&, JTx& jt) const
|
||||
{
|
||||
jt.ter = v_;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env const&, JTx& jt) const;
|
||||
operator()(Env&, JTx& jt) const;
|
||||
};
|
||||
|
||||
} // jtx
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
using handler_type = HandlerImpl <WebSocket>;
|
||||
|
||||
ConnectionImpl (
|
||||
Application& app,
|
||||
Resource::Manager& resourceManager,
|
||||
InfoSub::Source& source,
|
||||
handler_type& handler,
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
void setPingTimer ();
|
||||
|
||||
private:
|
||||
Application& app_;
|
||||
HTTP::Port const& m_port;
|
||||
Resource::Manager& m_resourceManager;
|
||||
Resource::Consumer m_usage;
|
||||
@@ -121,6 +123,7 @@ private:
|
||||
|
||||
template <class WebSocket>
|
||||
ConnectionImpl <WebSocket>::ConnectionImpl (
|
||||
Application& app,
|
||||
Resource::Manager& resourceManager,
|
||||
InfoSub::Source& source,
|
||||
handler_type& handler,
|
||||
@@ -129,10 +132,11 @@ ConnectionImpl <WebSocket>::ConnectionImpl (
|
||||
boost::asio::io_service& io_service)
|
||||
: InfoSub (source, // usage
|
||||
resourceManager.newInboundEndpoint (remoteAddress))
|
||||
, app_(app)
|
||||
, m_port (handler.port ())
|
||||
, m_resourceManager (resourceManager)
|
||||
, m_remoteAddress (remoteAddress)
|
||||
, m_netOPs (getApp ().getOPs ())
|
||||
, m_netOPs (app_.getOPs ())
|
||||
, m_io_service (io_service)
|
||||
, m_pingTimer (io_service)
|
||||
, m_handler (handler)
|
||||
@@ -270,9 +274,9 @@ Json::Value ConnectionImpl <WebSocket>::invokeCommand (
|
||||
else
|
||||
{
|
||||
RPC::Context context {
|
||||
jvRequest, getApp(), loadType, m_netOPs, getApp().getLedgerMaster(), role,
|
||||
this->shared_from_this (),
|
||||
{suspend, "WSClient::command"}};
|
||||
jvRequest, app_, loadType, m_netOPs, app_.getLedgerMaster(),
|
||||
role, {app_, suspend, "WSClient::command"},
|
||||
this->shared_from_this ()};
|
||||
RPC::doCommand (context, jvResult[jss::result]);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,7 @@ public:
|
||||
{
|
||||
auto remoteEndpoint = cpClient->get_socket ().remote_endpoint ();
|
||||
auto connection = std::make_shared <ConnectionImpl <WebSocket> > (
|
||||
desc_.app,
|
||||
desc_.resourceManager,
|
||||
desc_.source,
|
||||
*this,
|
||||
|
||||
Reference in New Issue
Block a user