diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index 08916b7fb5..40128c5114 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -375,6 +375,8 @@
+
+
@@ -1517,12 +1519,6 @@
-
- True
- True
-
-
-
@@ -1701,10 +1697,6 @@
-
- True
- True
-
@@ -2631,6 +2623,8 @@
True
True
+
+
@@ -2645,6 +2639,10 @@
+
+ True
+ True
+
True
True
@@ -2775,6 +2773,10 @@
True
True
+
+ True
+ True
+
True
True
@@ -2883,10 +2885,18 @@
True
True
+
+ True
+ True
+
+
+
+
+
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index c401660506..0b97d0865c 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -271,9 +271,6 @@
{9AD8D049-10A8-704C-D51A-FAD55B1F235F}
-
- {1025719B-6A8F-D9FB-A6BA-02B93756DE09}
-
{2E791662-6ED0-D1E1-03A4-0CB35473EC56}
@@ -837,6 +834,9 @@
beast\crypto
+
+ beast\crypto
+
beast\crypto
@@ -2253,12 +2253,6 @@
ripple\app\main
-
- ripple\app\misc
-
-
- ripple\app\misc
-
ripple\app\misc
@@ -2430,9 +2424,6 @@
ripple\app\paths
-
- ripple\app\paths\tests
-
ripple\app\paths
@@ -3327,6 +3318,9 @@
ripple\peerfinder\tests
+
+ ripple\protocol
+
ripple\protocol
@@ -3348,6 +3342,9 @@
ripple\protocol
+
+ ripple\protocol\impl
+
ripple\protocol\impl
@@ -3447,6 +3444,9 @@
ripple\protocol\impl
+
+ ripple\protocol\impl
+
ripple\protocol\impl
@@ -3579,12 +3579,21 @@
ripple\protocol\tests
+
+ ripple\protocol\tests
+
+
+ ripple\protocol
+
ripple\protocol
ripple\protocol
+
+ ripple\protocol
+
ripple\protocol
diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.cpp b/src/ripple/app/ledger/AcceptedLedgerTx.cpp
index 373120cc1a..922b67fe42 100644
--- a/src/ripple/app/ledger/AcceptedLedgerTx.cpp
+++ b/src/ripple/app/ledger/AcceptedLedgerTx.cpp
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
namespace ripple {
@@ -83,19 +84,17 @@ void AcceptedLedgerTx::buildJson ()
mJson[jss::result] = transHuman (mResult);
- if (!mAffected.empty ())
+ if (! mAffected.empty ())
{
Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
- for (auto const& ra : mAffected)
- {
- affected.append (ra.humanAccountID ());
- }
+ for (auto const& account: mAffected)
+ affected.append (getApp().accountIDCache().toBase58(account));
}
if (mTxn->getTxnType () == ttOFFER_CREATE)
{
- auto const account (mTxn->getSourceAccount ().getAccountID ());
- auto const amount (mTxn->getFieldAmount (sfTakerGets));
+ auto const& account = mTxn->getAccountID(sfAccount);
+ auto const amount = mTxn->getFieldAmount (sfTakerGets);
// If the offer create is not self funded then add the owner balance
if (account != amount.issue ().account)
diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.h b/src/ripple/app/ledger/AcceptedLedgerTx.h
index 557288b850..e91a9cc28e 100644
--- a/src/ripple/app/ledger/AcceptedLedgerTx.h
+++ b/src/ripple/app/ledger/AcceptedLedgerTx.h
@@ -21,6 +21,7 @@
#define RIPPLE_APP_LEDGER_ACCEPTEDLEDGERTX_H_INCLUDED
#include
+#include
namespace ripple {
@@ -63,7 +64,9 @@ public:
{
return mMeta;
}
- std::vector const& getAffected () const
+
+ boost::container::flat_set const&
+ getAffected() const
{
return mAffected;
}
@@ -104,7 +107,7 @@ private:
STTx::pointer mTxn;
TransactionMetaSet::pointer mMeta;
TER mResult;
- std::vector mAffected;
+ boost::container::flat_set mAffected;
Blob mRawMeta;
Json::Value mJson;
diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp
index 0a63169b59..f8efc70492 100644
--- a/src/ripple/app/ledger/Ledger.cpp
+++ b/src/ripple/app/ledger/Ledger.cpp
@@ -43,6 +43,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -65,7 +66,7 @@ makeGenesisAccount (AccountID const& id,
std::shared_ptr sle =
std::make_shared(ltACCOUNT_ROOT,
getAccountRootIndex(id));
- sle->setFieldAccount (sfAccount, id);
+ sle->setAccountID (sfAccount, id);
sle->setFieldAmount (sfBalance, drops);
sle->setFieldU32 (sfSequence, 1);
return sle;
@@ -76,8 +77,10 @@ makeGenesisAccount (AccountID const& id,
// other constructor with appropriate parameters, and
// then create the master account / flush dirty.
//
-Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount)
- : mTotCoins (startAmount)
+// VFALCO Use `AnyPublicKey masterPublicKey`
+Ledger::Ledger (RippleAddress const& masterPublicKey,
+ std::uint64_t balanceInDrops)
+ : mTotCoins (balanceInDrops)
, seq_ (1) // First Ledger
, mCloseTime (0)
, mParentCloseTime (0)
@@ -90,7 +93,8 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount)
getApp().family(), deprecatedLogs().journal("SHAMap")))
{
auto sle = makeGenesisAccount(
- masterID.getAccountID(), startAmount);
+ calcAccountID(masterPublicKey),
+ balanceInDrops);
WriteLog (lsTRACE, Ledger)
<< "root account: " << sle->getJson(0);
unchecked_insert(std::move(sle));
@@ -603,7 +607,7 @@ bool Ledger::saveValidatedLedger (bool current)
sql.reserve (sql.length () + (accts.size () * 128));
bool first = true;
- for (auto const& it : accts)
+ for (auto const& account : accts)
{
if (!first)
sql += ", ('";
@@ -615,7 +619,7 @@ bool Ledger::saveValidatedLedger (bool current)
sql += txnId;
sql += "','";
- sql += it.humanAccountID ();
+ sql += getApp().accountIDCache().toBase58(account);
sql += "',";
sql += ledgerSeq;
sql += ",";
@@ -703,7 +707,6 @@ loadLedgerHelper(std::string const& sqlSuffix)
if (!db->got_data ())
{
- std::stringstream s;
WriteLog (lsINFO, Ledger) << "Ledger not found: " << sqlSuffix;
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
}
@@ -1236,7 +1239,7 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent)
void
ownerDirDescriber (SLE::ref sle, bool, AccountID const& owner)
{
- sle->setFieldAccount (sfOwner, owner);
+ sle->setAccountID (sfOwner, owner);
}
void
@@ -1362,31 +1365,6 @@ cachedRead (Ledger const& ledger, uint256 const& key,
return sle;
}
-AccountState::pointer
-getAccountState (Ledger const& ledger,
- RippleAddress const& accountID,
- SLECache& cache)
-{
- auto const sle = cachedRead (ledger,
- getAccountRootIndex(accountID.getAccountID()),
- cache);
- if (!sle)
- {
- // VFALCO Do we really need to log here?
- WriteLog (lsDEBUG, Ledger) << "Ledger:getAccountState:" <<
- " not found: " << accountID.humanAccountID () <<
- ": " << to_string (getAccountRootIndex (accountID));
-
- return {};
- }
-
- // VFALCO Does this ever really happen?
- if (sle->getType () != ltACCOUNT_ROOT)
- return {};
-
- return std::make_shared(sle, accountID);
-}
-
boost::optional
hashOfSeq (Ledger& ledger, LedgerIndex seq,
SLECache& cache, beast::Journal journal)
@@ -1459,6 +1437,35 @@ hashOfSeq (Ledger& ledger, LedgerIndex seq,
return boost::none;
}
+void
+injectSLE (Json::Value& jv,
+ SLE const& sle)
+{
+ jv = sle.getJson(0);
+ if (sle.getType() == ltACCOUNT_ROOT)
+ {
+ if (sle.isFieldPresent(sfEmailHash))
+ {
+ auto const& hash =
+ sle.getFieldH128(sfEmailHash);
+ Blob const b (hash.begin(), hash.end());
+ std::string md5 = strHex(b);
+ boost::to_lower(md5);
+ // VFALCO TODO Give a name and move this constant
+ // to a more visible location. Also
+ // shouldn't this be https?
+ jv[jss::urlgravatar] = str(boost::format(
+ "http://www.gravatar.com/avatar/%s") % md5);
+ }
+ }
+ else
+ {
+ jv[jss::Invalid] = true;
+ }
+}
+
+//------------------------------------------------------------------------------
+
bool
getMetaHex (Ledger const& ledger,
uint256 const& transID, std::string& hex)
diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h
index faebf53e50..212044d22a 100644
--- a/src/ripple/app/ledger/Ledger.h
+++ b/src/ripple/app/ledger/Ledger.h
@@ -25,7 +25,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -83,9 +82,13 @@ public:
Ledger (Ledger const&) = delete;
Ledger& operator= (Ledger const&) = delete;
- // used for the starting bootstrap ledger
- Ledger (RippleAddress const& masterID,
- std::uint64_t startAmount);
+ /** Construct the genesis ledger.
+
+ @param masterPublicKey The public of the account that
+ will hold `startAmount` XRP in drops.
+ */
+ Ledger (RippleAddress const& masterPublicKey,
+ std::uint64_t balanceInDrops);
// Used for ledgers loaded from JSON files
Ledger (uint256 const& parentHash, uint256 const& transHash,
@@ -482,14 +485,6 @@ std::shared_ptr
cachedRead (Ledger const& ledger, uint256 const& key, SLECache& cache,
boost::optional type = boost::none);
-// DEPRECATED
-// VFALCO This could return by value
-// This should take AccountID parameter
-AccountState::pointer
-getAccountState (Ledger const& ledger,
- RippleAddress const& accountID,
- SLECache& cache);
-
/** Return the hash of a ledger by sequence.
The hash is retrieved by looking up the "skip list"
in the passed ledger. As the skip list is limited
@@ -522,6 +517,18 @@ getCandidateLedger (LedgerIndex requested)
return (requested + 255) & (~255);
}
+/** Inject JSON describing ledger entry
+
+ Effects:
+ Adds the JSON description of `sle` to `jv`.
+
+ If `sle` holds an account root, also adds the
+ urlgravatar field JSON if sfEmailHash is present.
+*/
+void
+injectSLE (Json::Value& jv,
+ SLE const& sle);
+
//------------------------------------------------------------------------------
// VFALCO Should this take Slice? Should id be called key or hash? Or txhash?
diff --git a/src/ripple/app/ledger/MetaView.h b/src/ripple/app/ledger/MetaView.h
index 8c19510042..0265b21051 100644
--- a/src/ripple/app/ledger/MetaView.h
+++ b/src/ripple/app/ledger/MetaView.h
@@ -232,7 +232,7 @@ private:
Mods& mods);
bool
- threadTx (RippleAddress const& to,
+ threadTx (AccountID const& to,
Mods& mods);
bool
diff --git a/src/ripple/app/ledger/impl/MetaView.cpp b/src/ripple/app/ledger/impl/MetaView.cpp
index f14330568a..8f95e4395a 100644
--- a/src/ripple/app/ledger/impl/MetaView.cpp
+++ b/src/ripple/app/ledger/impl/MetaView.cpp
@@ -29,6 +29,7 @@
#include
#include
#include
+#include
namespace ripple {
@@ -586,19 +587,21 @@ MetaView::getForMod (uint256 const& key,
}
bool
-MetaView::threadTx (RippleAddress const& to,
+MetaView::threadTx (AccountID const& to,
Mods& mods)
{
- auto const sle = getForMod(keylet::account(
- to.getAccountID()).key, mods);
+ auto const sle = getForMod(
+ keylet::account(to).key, mods);
#ifdef META_DEBUG
- WriteLog (lsTRACE, View) << "Thread to " << threadTo.getAccountID ();
+ WriteLog (lsTRACE, View) <<
+ "Thread to " << toBase58(to);
#endif
+ assert(sle);
if (! sle)
{
WriteLog (lsFATAL, View) <<
- "Threading to non-existent account: " << to.humanAccountID ();
- assert (false);
+ "Threading to non-existent account: " <<
+ toBase58(to);
return false;
}
@@ -630,21 +633,25 @@ MetaView::threadOwners(std::shared_ptr<
SLE const> const& sle, Mods& mods)
{
// thread new or modified sle to owner or owners
- if (sle->hasOneOwner())
+ // VFALCO Why not isFieldPresent?
+ if (sle->getType() != ltACCOUNT_ROOT &&
+ sle->getFieldIndex(sfAccount) != -1)
{
// thread to owner's account
#ifdef META_DEBUG
WriteLog (lsTRACE, View) << "Thread to single owner";
#endif
- return threadTx (sle->getOwner(), mods);
+ return threadTx (sle->getAccountID(sfAccount), mods);
}
- else if (sle->hasTwoOwners ()) // thread to owner's accounts
+ else if (sle->getType() == ltRIPPLE_STATE)
{
+ // thread to owner's accounts
#ifdef META_DEBUG
WriteLog (lsTRACE, View) << "Thread to two owners";
#endif
- return threadTx(sle->getFirstOwner(), mods) &&
- threadTx(sle->getSecondOwner(), mods);
+ return
+ threadTx(sle->getFieldAmount(sfLowLimit).getIssuer(), mods) &&
+ threadTx(sle->getFieldAmount(sfHighLimit).getIssuer(), mods);
}
return false;
}
diff --git a/src/ripple/app/ledger/tests/DeferredCredits.test.cpp b/src/ripple/app/ledger/tests/DeferredCredits.test.cpp
index 4adf71a173..724a349271 100644
--- a/src/ripple/app/ledger/tests/DeferredCredits.test.cpp
+++ b/src/ripple/app/ledger/tests/DeferredCredits.test.cpp
@@ -22,6 +22,7 @@
namespace ripple {
namespace test {
+
class DeferredCredits_test : public beast::unit_test::suite
{
/*
@@ -152,8 +153,8 @@ class DeferredCredits_test : public beast::unit_test::suite
verifyBalance (ledger, alice, Amount (50, "USD", gw1));
verifyBalance (ledger, alice, Amount (50, "USD", gw2));
- AccountID const gw1Acc (gw1.pk.getAccountID ());
- AccountID const aliceAcc (alice.pk.getAccountID ());
+ AccountID const gw1Acc = calcAccountID(gw1.pk);
+ AccountID const aliceAcc = calcAccountID(alice.pk);
ripple::Currency const usd (to_currency ("USD"));
ripple::Issue const issue (usd, gw1Acc);
STAmount const toCredit (issue, 30);
diff --git a/src/ripple/app/ledger/tests/common_ledger.cpp b/src/ripple/app/ledger/tests/common_ledger.cpp
index 81ca991f4b..dd999b184e 100644
--- a/src/ripple/app/ledger/tests/common_ledger.cpp
+++ b/src/ripple/app/ledger/tests/common_ledger.cpp
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
#include
@@ -62,7 +63,7 @@ Issuer::Issuer(TestAccount issuer)
void
Issuer::getJson(Json::Value& tx_json) const
{
- tx_json[jss::issuer] = issuer_.pk.humanAccountID();
+ tx_json[jss::issuer] = toBase58(calcAccountID(issuer_.pk));
}
TestAccount const&
@@ -213,7 +214,7 @@ Json::Value
getCommonTransactionJson(TestAccount& account)
{
Json::Value tx_json;
- tx_json[jss::Account] = account.pk.humanAccountID();
+ tx_json[jss::Account] = toBase58(calcAccountID(account.pk));
tx_json[jss::Fee] = std::to_string(10);
tx_json[jss::Sequence] = ++account.sequence;
return tx_json;
@@ -269,7 +270,7 @@ getPaymentJson(TestAccount& from, TestAccount const& to,
{
Json::Value tx_json = getCommonTransactionJson(from);
tx_json[jss::Amount] = amountJson;
- tx_json[jss::Destination] = to.pk.humanAccountID();
+ tx_json[jss::Destination] = toBase58(calcAccountID(to.pk));
tx_json[jss::TransactionType] = "Payment";
tx_json[jss::Flags] = tfUniversal;
return tx_json;
@@ -329,10 +330,12 @@ Ledger::pointer const& ledger, bool sign)
STPathSet pathSet;
STPath fullLiquidityPath;
auto stDstAmount = amountFromJson(sfGeneric, amountJson);
- Issue srcIssue = Issue(stDstAmount.getCurrency(), from.pk.getAccountID());
+ Issue srcIssue = Issue(stDstAmount.getCurrency(),
+ calcAccountID(from.pk));
- auto found = findPathsForOneIssuer(cache, from.pk.getAccountID(), to.pk.getAccountID(),
- srcIssue, stDstAmount, 7, 4, pathSet, fullLiquidityPath);
+ auto found = findPathsForOneIssuer(cache,
+ calcAccountID(from.pk), calcAccountID(to.pk),
+ srcIssue, stDstAmount, 7, 4, pathSet, fullLiquidityPath);
if (!found)
throw std::runtime_error(
"!found");
@@ -421,7 +424,7 @@ trust(TestAccount& from, TestAccount const& issuer,
Json::Value tx_json = getCommonTransactionJson(from);
Json::Value& limitAmount = tx_json[jss::LimitAmount];
limitAmount[jss::currency] = currency;
- limitAmount[jss::issuer] = issuer.pk.humanAccountID();
+ limitAmount[jss::issuer] = toBase58(calcAccountID(issuer.pk));
limitAmount[jss::value] = std::to_string(amount);
tx_json[jss::TransactionType] = "TrustSet";
tx_json[jss::Flags] = 0; // tfClearNoRipple;
@@ -486,8 +489,9 @@ Json::Value findPath(Ledger::pointer ledger, TestAccount const& src,
}
log << "Source currencies: " << jvSrcCurrencies;
- auto result = ripplePathFind(cache, src.pk, dest.pk, saDstAmount,
- ledger, jvSrcCurrencies, contextPaths, level);
+ auto result = ripplePathFind(cache, calcAccountID(src.pk),
+ calcAccountID(dest.pk), saDstAmount,
+ ledger, jvSrcCurrencies, contextPaths, level);
if(!result.first)
throw std::runtime_error(
"ripplePathFind find failed");
@@ -501,7 +505,7 @@ getLedgerEntryRippleState(Ledger::pointer ledger,
Currency currency)
{
auto k = keylet::line(
- account1.pk.getAccountID(), account2.pk.getAccountID(),
+ calcAccountID(account1.pk), calcAccountID(account2.pk),
to_currency(currency.getCurrency()));
if (! k.key.isNonZero())
@@ -525,7 +529,7 @@ verifyBalance(Ledger::pointer ledger, TestAccount const& account,
auto high = sle->getFieldAmount(sfHighLimit);
auto balance = sle->getFieldAmount(sfBalance);
- if (high.getIssuer() == account.pk.getAccountID())
+ if (high.getIssuer() == calcAccountID(account.pk))
{
balance.negate();
}
@@ -537,7 +541,7 @@ verifyBalance(Ledger::pointer ledger, TestAccount const& account,
Json::Value pathNode (TestAccount const& acc)
{
Json::Value result;
- result["account"] = acc.pk.humanAccountID();
+ result["account"] = toBase58(calcAccountID(acc.pk));
result["type"] = 1;
result["type_hex"] = "0000000000000001";
return result;
@@ -550,7 +554,7 @@ Json::Value pathNode (OfferPathNode const& offer)
result["type"] = 48;
result["type_hex"] = "0000000000000030";
if (offer.issuer)
- result["issuer"] = offer.issuer->pk.humanAccountID();
+ result["issuer"] = toBase58(calcAccountID(offer.issuer->pk));
return result;
}
diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp
index 19e107f4d4..6e06b817d0 100644
--- a/src/ripple/app/main/Application.cpp
+++ b/src/ripple/app/main/Application.cpp
@@ -58,6 +58,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -259,6 +260,7 @@ public:
std::unique_ptr m_shaMapStore;
std::unique_ptr m_nodeStore;
PendingSaves pendingSaves_;
+ AccountIDCache accountIDCache_;
// These are not Stoppable-derived
NodeCache m_tempNodeCache;
@@ -334,6 +336,8 @@ public:
, m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4))
+ , accountIDCache_(128000)
+
, m_tempNodeCache ("NodeCache", 16384, 90, get_seconds_clock (),
m_logs.journal("TaggedCache"))
@@ -598,6 +602,12 @@ public:
return pendingSaves_;
}
+ AccountIDCache const&
+ accountIDCache() const override
+ {
+ return accountIDCache_;
+ }
+
Overlay& overlay ()
{
return *m_overlay;
@@ -904,7 +914,6 @@ public:
m_overlay->saveValidatorKeyManifests (getWalletDB ());
- RippleAddress::clearCache ();
stopped ();
}
@@ -1038,11 +1047,12 @@ void ApplicationImp::startNewLedger ()
// Print enough information to be able to claim root account.
m_journal.info << "Root master seed: " << rootSeedMaster.humanSeed ();
- m_journal.info << "Root account: " << rootAddress.humanAccountID ();
+ m_journal.info << "Root account: " << toBase58(calcAccountID(rootAddress));
{
Ledger::pointer firstLedger = std::make_shared (rootAddress, SYSTEM_CURRENCY_START);
- assert (firstLedger->exists(keylet::account(rootAddress.getAccountID())));
+ assert (firstLedger->exists(keylet::account(
+ calcAccountID(rootAddress))));
// TODO(david): Add any default amendments
// TODO(david): Set default fee/reserve
firstLedger->getHash(); // updates the hash
@@ -1054,7 +1064,8 @@ void ApplicationImp::startNewLedger ()
secondLedger->setClosed ();
secondLedger->setAccepted ();
m_ledgerMaster->pushLedger (secondLedger, std::make_shared (true, std::ref (*secondLedger)));
- assert (secondLedger->exists(keylet::account(rootAddress.getAccountID())));
+ assert (secondLedger->exists(keylet::account(
+ calcAccountID(rootAddress))));
m_networkOPs->setLastCloseTime (secondLedger->getCloseTimeNC ());
}
}
diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h
index e46764f78a..2490fab0fe 100644
--- a/src/ripple/app/main/Application.h
+++ b/src/ripple/app/main/Application.h
@@ -27,7 +27,7 @@
#include
#include //
#include
-
+
namespace boost { namespace asio { class io_service; } }
namespace ripple {
@@ -58,6 +58,7 @@ class OrderBookDB;
class Overlay;
class PathRequests;
class PendingSaves;
+class AccountIDCache;
class STLedgerEntry;
class TransactionMaster;
class Validations;
@@ -116,6 +117,7 @@ public:
virtual PathRequests& getPathRequests () = 0;
virtual SHAMapStore& getSHAMapStore () = 0;
virtual PendingSaves& pendingSaves() = 0;
+ virtual AccountIDCache const& accountIDCache() const = 0;
virtual DatabaseCon& getTxnDB () = 0;
virtual DatabaseCon& getLedgerDB () = 0;
diff --git a/src/ripple/app/misc/AccountState.cpp b/src/ripple/app/misc/AccountState.cpp
deleted file mode 100644
index 471643a7e5..0000000000
--- a/src/ripple/app/misc/AccountState.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012, 2013 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace ripple {
-
-AccountState::AccountState (std::shared_ptr sle,
- RippleAddress const& naAccountID)
- : mLedgerEntry (sle)
-{
- if (! mLedgerEntry)
- return;
-
- if (mLedgerEntry->getType () != ltACCOUNT_ROOT)
- return;
-
- mValid = true;
-}
-
-// VFALCO TODO Make this a generic utility function of some container class
-//
-std::string AccountState::createGravatarUrl (uint128 uEmailHash)
-{
- Blob vucMD5 (uEmailHash.begin (), uEmailHash.end ());
- std::string strMD5Lower = strHex (vucMD5);
- boost::to_lower (strMD5Lower);
-
- // VFALCO TODO Give a name and move this constant to a more visible location.
- // Also shouldn't this be https?
- return str (boost::format ("http://www.gravatar.com/avatar/%s") % strMD5Lower);
-}
-
-void AccountState::addJson (Json::Value& val)
-{
- val = mLedgerEntry->getJson (0);
-
- if (mValid)
- {
- if (mLedgerEntry->isFieldPresent (sfEmailHash))
- val[jss::urlgravatar] = createGravatarUrl (mLedgerEntry->getFieldH128 (sfEmailHash));
- }
- else
- {
- val[jss::Invalid] = true;
- }
-}
-
-} // ripple
diff --git a/src/ripple/app/misc/AmendmentTableImpl.cpp b/src/ripple/app/misc/AmendmentTableImpl.cpp
index dd68446de5..eca3752cc1 100644
--- a/src/ripple/app/misc/AmendmentTableImpl.cpp
+++ b/src/ripple/app/misc/AmendmentTableImpl.cpp
@@ -557,7 +557,7 @@ AmendmentTableImpl::doVoting (Ledger::ref lastClosedLedger,
// Create the transaction to enable the amendment
STTx trans (ttAMENDMENT);
- trans.setFieldAccount (sfAccount, AccountID ());
+ trans.setAccountID (sfAccount, AccountID ());
trans.setFieldH256 (sfAmendment, uAmendment);
uint256 txID = trans.getTransactionID ();
diff --git a/src/ripple/app/misc/CanonicalTXSet.cpp b/src/ripple/app/misc/CanonicalTXSet.cpp
index f5f0cfa353..8fcce4d9cd 100644
--- a/src/ripple/app/misc/CanonicalTXSet.cpp
+++ b/src/ripple/app/misc/CanonicalTXSet.cpp
@@ -78,7 +78,7 @@ void CanonicalTXSet::push_back (STTx::ref txn)
{
uint256 effectiveAccount = mSetHash;
- effectiveAccount ^= to256 (txn->getSourceAccount ().getAccountID ());
+ effectiveAccount ^= to256 (txn->getAccountID(sfAccount));
mMap.insert (std::make_pair (
Key (effectiveAccount, txn->getSequence (), txn->getTransactionID ()),
diff --git a/src/ripple/app/misc/FeeVoteImpl.cpp b/src/ripple/app/misc/FeeVoteImpl.cpp
index d825f92587..e08db46311 100644
--- a/src/ripple/app/misc/FeeVoteImpl.cpp
+++ b/src/ripple/app/misc/FeeVoteImpl.cpp
@@ -214,7 +214,7 @@ FeeVoteImpl::doVoting (Ledger::ref lastClosedLedger,
"/" << incReserve;
STTx trans (ttFEE);
- trans.setFieldAccount (sfAccount, AccountID ());
+ trans.setAccountID (sfAccount, AccountID ());
trans.setFieldU64 (sfBaseFee, baseFee);
trans.setFieldU32 (sfReferenceFeeUnits, 10);
trans.setFieldU32 (sfReserveBase, baseReserve);
diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp
index f48211d918..4a110aff7d 100644
--- a/src/ripple/app/misc/NetworkOPs.cpp
+++ b/src/ripple/app/misc/NetworkOPs.cpp
@@ -313,7 +313,7 @@ public:
//
Json::Value getOwnerInfo (
- Ledger::pointer lpLedger, RippleAddress const& naAccount) override;
+ Ledger::pointer lpLedger, AccountID const& account) override;
//
// Book functions.
@@ -454,7 +454,7 @@ public:
//Helper function to generate SQL query to get transactions.
std::string transactionsSQL (
- std::string selection, RippleAddress const& account,
+ std::string selection, AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger,
bool descending, std::uint32_t offset, int limit,
bool binary, bool count, bool bAdmin) override;
@@ -462,12 +462,12 @@ public:
// Client information retrieval functions.
using NetworkOPs::AccountTxs;
AccountTxs getAccountTxs (
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool descending,
std::uint32_t offset, int limit, bool bAdmin) override;
AccountTxs getTxsAccount (
- RippleAddress const& account, std::int32_t minLedger,
+ AccountID const& account, std::int32_t minLedger,
std::int32_t maxLedger, bool forward, Json::Value& token, int limit,
bool bAdmin) override;
@@ -476,19 +476,16 @@ public:
MetaTxsList
getAccountTxsB (
- RippleAddress const& account, std::int32_t minLedger,
+ AccountID const& account, std::int32_t minLedger,
std::int32_t maxLedger, bool descending, std::uint32_t offset,
int limit, bool bAdmin) override;
MetaTxsList
getTxsAccountB (
- RippleAddress const& account, std::int32_t minLedger,
+ AccountID const& account, std::int32_t minLedger,
std::int32_t maxLedger, bool forward, Json::Value& token,
int limit, bool bAdmin) override;
- std::vector getLedgerAffectedAccounts (
- std::uint32_t ledgerSeq) override;
-
//
// Monitoring: publisher side.
//
@@ -502,17 +499,17 @@ public:
//
void subAccount (
InfoSub::ref ispListener,
- const hash_set& vnaAccountIDs, bool rt) override;
+ hash_set const& vnaAccountIDs, bool rt) override;
void unsubAccount (
InfoSub::ref ispListener,
- const hash_set& vnaAccountIDs,
+ hash_set const& vnaAccountIDs,
bool rt);
// Just remove the subscription from the tracking
// not from the InfoSub. Needed for InfoSub destruction
void unsubAccountInternal (
std::uint64_t seq,
- const hash_set& vnaAccountIDs,
+ hash_set const& vnaAccountIDs,
bool rt);
bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult) override;
@@ -562,9 +559,6 @@ private:
Ledger::ref lpCurrent);
bool haveConsensusObject ();
- Json::Value pubBootstrapAccountInfo (
- Ledger::ref lpAccepted, RippleAddress const& naAccountID);
-
void pubValidatedTransaction (
Ledger::ref alAccepted, const AcceptedLedgerTx& alTransaction);
void pubAccountTransaction (
@@ -1311,10 +1305,10 @@ STVector256 NetworkOPsImp::getDirNodeInfo (
//
Json::Value NetworkOPsImp::getOwnerInfo (
- Ledger::pointer lpLedger, RippleAddress const& naAccount)
+ Ledger::pointer lpLedger, AccountID const& account)
{
Json::Value jvObjects (Json::objectValue);
- auto uRootIndex = getOwnerDirIndex (naAccount.getAccountID ());
+ auto uRootIndex = getOwnerDirIndex (account);
auto sleNode = cachedRead(*lpLedger, uRootIndex,
getApp().getSLECache(), ltDIR_NODE);
if (sleNode)
@@ -1863,7 +1857,7 @@ void NetworkOPsImp::setMode (OperatingMode om)
std::string
NetworkOPsImp::transactionsSQL (
- std::string selection, RippleAddress const& account,
+ std::string selection, AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool descending,
std::uint32_t offset, int limit,
bool binary, bool count, bool bAdmin)
@@ -1915,7 +1909,7 @@ NetworkOPsImp::transactionsSQL (
"SELECT %s FROM AccountTransactions "
"WHERE Account = '%s' %s %s LIMIT %u, %u;")
% selection
- % account.humanAccountID ()
+ % getApp().accountIDCache().toBase58(account)
% maxClause
% minClause
% beast::lexicalCastThrow (offset)
@@ -1932,7 +1926,7 @@ NetworkOPsImp::transactionsSQL (
"AccountTransactions.TxnSeq %s, AccountTransactions.TransID %s "
"LIMIT %u, %u;")
% selection
- % account.humanAccountID ()
+ % getApp().accountIDCache().toBase58(account)
% maxClause
% minClause
% (descending ? "DESC" : "ASC")
@@ -1946,7 +1940,7 @@ NetworkOPsImp::transactionsSQL (
}
NetworkOPs::AccountTxs NetworkOPsImp::getAccountTxs (
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool descending,
std::uint32_t offset, int limit, bool bAdmin)
{
@@ -2009,7 +2003,7 @@ NetworkOPs::AccountTxs NetworkOPsImp::getAccountTxs (
}
std::vector NetworkOPsImp::getAccountTxsB (
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool descending,
std::uint32_t offset, int limit, bool bAdmin)
{
@@ -2059,7 +2053,7 @@ std::vector NetworkOPsImp::getAccountTxsB (
NetworkOPsImp::AccountTxs
NetworkOPsImp::getTxsAccount (
- RippleAddress const& account, std::int32_t minLedger,
+ AccountID const& account, std::int32_t minLedger,
std::int32_t maxLedger, bool forward, Json::Value& token,
int limit, bool bAdmin)
{
@@ -2084,7 +2078,7 @@ NetworkOPsImp::getTxsAccount (
NetworkOPsImp::MetaTxsList
NetworkOPsImp::getTxsAccountB (
- RippleAddress const& account, std::int32_t minLedger,
+ AccountID const& account, std::int32_t minLedger,
std::int32_t maxLedger, bool forward, Json::Value& token,
int limit, bool bAdmin)
{
@@ -2106,36 +2100,6 @@ NetworkOPsImp::getTxsAccountB (
return ret;
}
-std::vector
-NetworkOPsImp::getLedgerAffectedAccounts (std::uint32_t ledgerSeq)
-{
- std::vector accounts;
- std::string sql = str (boost::format (
- "SELECT DISTINCT Account FROM AccountTransactions "
- "INDEXED BY AcctLgrIndex WHERE LedgerSeq = '%u';")
- % ledgerSeq);
- RippleAddress acct;
- {
- auto db = getApp().getTxnDB ().checkoutDb ();
- soci::blob accountBlob(*db);
- soci::indicator bi;
- soci::statement st = (db->prepare << sql, soci::into(accountBlob, bi));
- st.execute ();
- std::string accountStr;
- while (st.fetch ())
- {
- if (soci::i_ok == bi)
- convert (accountBlob, accountStr);
- else
- accountStr.clear ();
-
- if (acct.setAccountID (accountStr))
- accounts.push_back (acct);
- }
- }
- return accounts;
-}
-
bool NetworkOPsImp::recvValidation (
STValidation::ref val, std::string const& source)
{
@@ -2336,26 +2300,6 @@ Json::Value NetworkOPsImp::getLedgerFetchInfo ()
return getApp().getInboundLedgers().getInfo();
}
-//
-// Monitoring: publisher side
-//
-
-Json::Value NetworkOPsImp::pubBootstrapAccountInfo (
- Ledger::ref lpAccepted, RippleAddress const& naAccountID)
-{
- Json::Value jvObj (Json::objectValue);
-
- jvObj[jss::type] = "accountInfoBootstrap";
- jvObj[jss::account] = naAccountID.humanAccountID ();
- jvObj[jss::owner] = getOwnerInfo (lpAccepted, naAccountID);
- jvObj[jss::ledger_index] = lpAccepted->getLedgerSeq ();
- jvObj[jss::ledger_hash] = to_string (lpAccepted->getHash ());
- jvObj[jss::ledger_time]
- = Json::Value::UInt (utFromSeconds (lpAccepted->getCloseTimeNC ()));
-
- return jvObj;
-}
-
void NetworkOPsImp::pubProposedTransaction (
Ledger::ref lpCurrent, STTx::ref stTxn, TER terResult)
{
@@ -2492,8 +2436,8 @@ Json::Value NetworkOPsImp::transJson(
if (stTxn.getTxnType() == ttOFFER_CREATE)
{
- auto const account (stTxn.getSourceAccount ().getAccountID ());
- auto const amount (stTxn.getFieldAmount (sfTakerGets));
+ auto const account = stTxn.getAccountID(sfAccount);
+ auto const amount = stTxn.getFieldAmount (sfTakerGets);
// If the offer create is not self funded then add the owner balance
if (account != amount.issue ().account)
@@ -2571,7 +2515,7 @@ void NetworkOPsImp::pubAccountTransaction (
for (auto const& affectedAccount: alTx.getAffected ())
{
auto simiIt
- = mSubRTAccount.find (affectedAccount.getAccountID ());
+ = mSubRTAccount.find (affectedAccount);
if (simiIt != mSubRTAccount.end ())
{
auto it = simiIt->second.begin ();
@@ -2593,7 +2537,7 @@ void NetworkOPsImp::pubAccountTransaction (
if (bAccepted)
{
- simiIt = mSubAccount.find (affectedAccount.getAccountID ());
+ simiIt = mSubAccount.find (affectedAccount);
if (simiIt != mSubAccount.end ())
{
@@ -2643,14 +2587,14 @@ void NetworkOPsImp::pubAccountTransaction (
void NetworkOPsImp::subAccount (
InfoSub::ref isrListener,
- const hash_set& vnaAccountIDs, bool rt)
+ hash_set const& vnaAccountIDs, bool rt)
{
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
for (auto const& naAccountID : vnaAccountIDs)
{
- m_journal.trace << "subAccount:"
- " account: " << naAccountID.humanAccountID ();
+ if (m_journal.trace) m_journal.trace <<
+ "subAccount: account: " << toBase58(naAccountID);
isrListener->insertSubAccountInfo (naAccountID, rt);
}
@@ -2659,14 +2603,15 @@ void NetworkOPsImp::subAccount (
for (auto const& naAccountID : vnaAccountIDs)
{
- auto simIterator = subMap.find (naAccountID.getAccountID ());
+ auto simIterator = subMap.find (naAccountID);
if (simIterator == subMap.end ())
{
// Not found, note that account has a new single listner.
SubMapType usisElement;
usisElement[isrListener->getSeq ()] = isrListener;
- subMap.insert (simIterator, make_pair (naAccountID.getAccountID (),
- usisElement));
+ // VFALCO NOTE This is making a needless copy of naAccountID
+ subMap.insert (simIterator,
+ make_pair(naAccountID, usisElement));
}
else
{
@@ -2678,7 +2623,7 @@ void NetworkOPsImp::subAccount (
void NetworkOPsImp::unsubAccount (
InfoSub::ref isrListener,
- hash_set const& vnaAccountIDs,
+ hash_set const& vnaAccountIDs,
bool rt)
{
for (auto const& naAccountID : vnaAccountIDs)
@@ -2693,7 +2638,7 @@ void NetworkOPsImp::unsubAccount (
void NetworkOPsImp::unsubAccountInternal (
std::uint64_t uSeq,
- hash_set const& vnaAccountIDs,
+ hash_set const& vnaAccountIDs,
bool rt)
{
ScopedLockType sl (mSubLock);
@@ -2702,7 +2647,7 @@ void NetworkOPsImp::unsubAccountInternal (
for (auto const& naAccountID : vnaAccountIDs)
{
- auto simIterator = subMap.find (naAccountID.getAccountID ());
+ auto simIterator = subMap.find (naAccountID);
if (simIterator != subMap.end ())
{
@@ -2983,7 +2928,7 @@ void NetworkOPsImp::getBookPage (
if (sleOffer)
{
auto const uOfferOwnerID =
- sleOffer->getFieldAccount160 (sfAccount);
+ sleOffer->getAccountID (sfAccount);
auto const& saTakerGets =
sleOffer->getFieldAmount (sfTakerGets);
auto const& saTakerPays =
@@ -3154,7 +3099,7 @@ void NetworkOPsImp::getBookPage (
SLE::pointer sleOffer = obIterator.getCurrentOffer();
if (sleOffer)
{
- auto const uOfferOwnerID = sleOffer->getFieldAccount160 (sfAccount);
+ auto const uOfferOwnerID = sleOffer->getAccountID (sfAccount);
auto const& saTakerGets = sleOffer->getFieldAmount (sfTakerGets);
auto const& saTakerPays = sleOffer->getFieldAmount (sfTakerPays);
STAmount saDirRate = obIterator.getCurrentRate ();
diff --git a/src/ripple/app/misc/NetworkOPs.h b/src/ripple/app/misc/NetworkOPs.h
index 961f8319ed..3ce1012ac8 100644
--- a/src/ripple/app/misc/NetworkOPs.h
+++ b/src/ripple/app/misc/NetworkOPs.h
@@ -190,7 +190,7 @@ public:
//
virtual Json::Value getOwnerInfo (Ledger::pointer lpLedger,
- RippleAddress const& naAccount) = 0;
+ AccountID const& account) = 0;
//--------------------------------------------------------------------------
//
@@ -286,7 +286,7 @@ public:
//Helper function to generate SQL query to get transactions
virtual std::string transactionsSQL (std::string selection,
- RippleAddress const& account, std::int32_t minLedger, std::int32_t maxLedger,
+ AccountID const& account, std::int32_t minLedger, std::int32_t maxLedger,
bool descending, std::uint32_t offset, int limit, bool binary,
bool count, bool bAdmin) = 0;
@@ -295,29 +295,26 @@ public:
using AccountTxs = std::vector;
virtual AccountTxs getAccountTxs (
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool descending,
std::uint32_t offset, int limit, bool bAdmin) = 0;
virtual AccountTxs getTxsAccount (
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool forward,
Json::Value& token, int limit, bool bAdmin) = 0;
using txnMetaLedgerType = std::tuple;
using MetaTxsList = std::vector;
- virtual MetaTxsList getAccountTxsB (RippleAddress const& account,
+ virtual MetaTxsList getAccountTxsB (AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool descending,
std::uint32_t offset, int limit, bool bAdmin) = 0;
- virtual MetaTxsList getTxsAccountB (RippleAddress const& account,
+ virtual MetaTxsList getTxsAccountB (AccountID const& account,
std::int32_t minLedger, std::int32_t maxLedger, bool forward,
Json::Value& token, int limit, bool bAdmin) = 0;
- virtual std::vector getLedgerAffectedAccounts (
- std::uint32_t ledgerSeq) = 0;
-
//--------------------------------------------------------------------------
//
// Monitoring: publisher side
diff --git a/src/ripple/app/misc/UniqueNodeList.cpp b/src/ripple/app/misc/UniqueNodeList.cpp
index 60887e7aad..5e489855ec 100644
--- a/src/ripple/app/misc/UniqueNodeList.cpp
+++ b/src/ripple/app/misc/UniqueNodeList.cpp
@@ -932,7 +932,7 @@ Json::Value UniqueNodeListImp::getUnlJson()
{
Json::Value node (Json::objectValue);
- node["publicKey"] = encodeCredential (key.first, VER_NODE_PUBLIC);
+ node["publicKey"] = encodeCredential (key.first, TOKEN_NODE_PUBLIC);
node["comment"] = key.second;
ret.append (node);
diff --git a/src/ripple/app/misc/impl/AccountTxPaging.cpp b/src/ripple/app/misc/impl/AccountTxPaging.cpp
index e8293dee4b..bda038e216 100644
--- a/src/ripple/app/misc/impl/AccountTxPaging.cpp
+++ b/src/ripple/app/misc/impl/AccountTxPaging.cpp
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
#include //
#include
@@ -67,7 +68,7 @@ accountTxPage (
std::string const&,
Blob const&,
Blob const&)> const& onTransaction,
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger,
std::int32_t maxLedger,
bool forward,
@@ -132,7 +133,7 @@ accountTxPage (
ORDER BY AccountTransactions.LedgerSeq ASC,
AccountTransactions.TxnSeq ASC
LIMIT %u;)"))
- % account.humanAccountID()
+ % getApp().accountIDCache().toBase58(account)
% minLedger
% maxLedger
% queryLimit);
@@ -149,7 +150,7 @@ accountTxPage (
AccountTransactions.TxnSeq ASC
LIMIT %u;
)"))
- % account.humanAccountID()
+ % getApp().accountIDCache().toBase58(account)
% (findLedger + 1)
% maxLedger
% findLedger
@@ -164,7 +165,7 @@ accountTxPage (
ORDER BY AccountTransactions.LedgerSeq DESC,
AccountTransactions.TxnSeq DESC
LIMIT %u;)"))
- % account.humanAccountID()
+ % getApp().accountIDCache().toBase58(account)
% minLedger
% maxLedger
% queryLimit);
@@ -179,7 +180,7 @@ accountTxPage (
ORDER BY AccountTransactions.LedgerSeq DESC,
AccountTransactions.TxnSeq DESC
LIMIT %u;)"))
- % account.humanAccountID()
+ % getApp().accountIDCache().toBase58(account)
% minLedger
% (findLedger - 1)
% findLedger
diff --git a/src/ripple/app/misc/impl/AccountTxPaging.h b/src/ripple/app/misc/impl/AccountTxPaging.h
index 3707baf878..92a574c5f9 100644
--- a/src/ripple/app/misc/impl/AccountTxPaging.h
+++ b/src/ripple/app/misc/impl/AccountTxPaging.h
@@ -50,7 +50,7 @@ accountTxPage (
std::string const&,
Blob const&,
Blob const&)> const&,
- RippleAddress const& account,
+ AccountID const& account,
std::int32_t minLedger,
std::int32_t maxLedger,
bool forward,
diff --git a/src/ripple/app/misc/tests/AccountTxPaging.test.cpp b/src/ripple/app/misc/tests/AccountTxPaging.test.cpp
index 45369dd072..6fb5b67216 100644
--- a/src/ripple/app/misc/tests/AccountTxPaging.test.cpp
+++ b/src/ripple/app/misc/tests/AccountTxPaging.test.cpp
@@ -18,6 +18,7 @@
//==============================================================================
#include
#include
+#include
#include //
#include
#include
@@ -29,7 +30,7 @@ struct AccountTxPaging_test : beast::unit_test::suite
{
std::unique_ptr db_;
NetworkOPs::AccountTxs txs_;
- RippleAddress account_;
+ AccountID account_;
void
run() override
@@ -51,7 +52,8 @@ struct AccountTxPaging_test : beast::unit_test::suite
db_ = std::make_unique (
dbConf, "account-tx-transactions.db", nullptr, 0);
- account_.setAccountID("rfu6L5p3azwPzQZsbTafuVk884N9YoKvVG");
+ account_ = *parseBase58(
+ "rfu6L5p3azwPzQZsbTafuVk884N9YoKvVG");
testAccountTxPaging();
}
diff --git a/src/ripple/app/paths/AccountCurrencies.cpp b/src/ripple/app/paths/AccountCurrencies.cpp
index 39026f6e9d..6f4d612d3a 100644
--- a/src/ripple/app/paths/AccountCurrencies.cpp
+++ b/src/ripple/app/paths/AccountCurrencies.cpp
@@ -22,19 +22,19 @@
namespace ripple {
-CurrencySet accountSourceCurrencies (
- RippleAddress const& raAccountID,
+hash_set accountSourceCurrencies (
+ AccountID const& account,
RippleLineCache::ref lrCache,
bool includeXRP)
{
- CurrencySet currencies;
+ hash_set currencies;
// YYY Only bother if they are above reserve
if (includeXRP)
currencies.insert (xrpCurrency());
// List of ripple lines.
- auto& rippleLines (lrCache->getRippleLines (raAccountID.getAccountID ()));
+ auto& rippleLines = lrCache->getRippleLines (account);
for (auto const& item : rippleLines)
{
@@ -60,19 +60,19 @@ CurrencySet accountSourceCurrencies (
return currencies;
}
-CurrencySet accountDestCurrencies (
- RippleAddress const& raAccountID,
+hash_set accountDestCurrencies (
+ AccountID const& account,
RippleLineCache::ref lrCache,
bool includeXRP)
{
- CurrencySet currencies;
+ hash_set currencies;
if (includeXRP)
currencies.insert (xrpCurrency());
// Even if account doesn't exist
// List of ripple lines.
- auto& rippleLines (lrCache->getRippleLines (raAccountID.getAccountID ()));
+ auto& rippleLines = lrCache->getRippleLines (account);
for (auto const& item : rippleLines)
{
diff --git a/src/ripple/app/paths/AccountCurrencies.h b/src/ripple/app/paths/AccountCurrencies.h
index 7d082d4f00..8f415f3ecf 100644
--- a/src/ripple/app/paths/AccountCurrencies.h
+++ b/src/ripple/app/paths/AccountCurrencies.h
@@ -21,18 +21,21 @@
#define RIPPLE_APP_PATHS_ACCOUNTCURRENCIES_H_INCLUDED
#include
+#include
namespace ripple {
-CurrencySet accountDestCurrencies
- (RippleAddress const& raAccountID,
- RippleLineCache::ref cache,
- bool includeXRP);
+hash_set
+accountDestCurrencies(
+ AccountID const& account,
+ RippleLineCache::ref cache,
+ bool includeXRP);
-CurrencySet accountSourceCurrencies
- (RippleAddress const& raAccountID,
- RippleLineCache::ref lrLedger,
- bool includeXRP);
+hash_set
+accountSourceCurrencies(
+ AccountID const& account,
+ RippleLineCache::ref lrLedger,
+ bool includeXRP);
} // ripple
diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp
index e5a19352da..092369613f 100644
--- a/src/ripple/app/paths/PathRequest.cpp
+++ b/src/ripple/app/paths/PathRequest.cpp
@@ -143,63 +143,62 @@ void PathRequest::updateComplete ()
bool PathRequest::isValid (RippleLineCache::ref crCache)
{
ScopedLockType sl (mLock);
- bValid = raSrcAccount.isSet () && raDstAccount.isSet () &&
+ bValid = raSrcAccount && raDstAccount &&
saDstAmount > zero;
Ledger::pointer lrLedger = crCache->getLedger ();
if (bValid)
{
- auto asSrc = getAccountState(
- *crCache->getLedger(), raSrcAccount,
- getApp().getSLECache());
-
- if (!asSrc)
+ if (! crCache->getLedger()->exists(
+ keylet::account(*raSrcAccount)))
{
// no source account
bValid = false;
jvStatus = rpcError (rpcSRC_ACT_NOT_FOUND);
}
+ }
+
+ if (bValid)
+ {
+ auto const sleDest = cachedRead(*crCache->getLedger(),
+ keylet::account(*raDstAccount).key,
+ getApp().getSLECache(), ltACCOUNT_ROOT);
+
+ Json::Value& jvDestCur =
+ (jvStatus[jss::destination_currencies] = Json::arrayValue);
+
+ if (!sleDest)
+ {
+ // no destination account
+ jvDestCur.append (Json::Value ("XRP"));
+
+ if (!saDstAmount.native ())
+ {
+ // only XRP can be send to a non-existent account
+ bValid = false;
+ jvStatus = rpcError (rpcACT_NOT_FOUND);
+ }
+ else if (saDstAmount < STAmount (lrLedger->getReserve (0)))
+ {
+ // payment must meet reserve
+ bValid = false;
+ jvStatus = rpcError (rpcDST_AMT_MALFORMED);
+ }
+ }
else
{
- auto asDst = getAccountState(*lrLedger,
- raDstAccount, getApp().getSLECache());
+ bool const disallowXRP (
+ sleDest->getFlags() & lsfDisallowXRP);
- Json::Value& jvDestCur =
- (jvStatus[jss::destination_currencies] = Json::arrayValue);
+ auto usDestCurrID = accountDestCurrencies (
+ *raDstAccount, crCache, !disallowXRP);
- if (!asDst)
- {
- // no destination account
- jvDestCur.append (Json::Value ("XRP"));
+ for (auto const& currency : usDestCurrID)
+ jvDestCur.append (to_string (currency));
- if (!saDstAmount.native ())
- {
- // only XRP can be send to a non-existent account
- bValid = false;
- jvStatus = rpcError (rpcACT_NOT_FOUND);
- }
- else if (saDstAmount < STAmount (lrLedger->getReserve (0)))
- {
- // payment must meet reserve
- bValid = false;
- jvStatus = rpcError (rpcDST_AMT_MALFORMED);
- }
- }
- else
- {
- bool const disallowXRP (
- asDst->sle().getFlags() & lsfDisallowXRP);
-
- auto usDestCurrID = accountDestCurrencies (
- raDstAccount, crCache, !disallowXRP);
-
- for (auto const& currency : usDestCurrID)
- jvDestCur.append (to_string (currency));
-
- jvStatus["destination_tag"] =
- (asDst->sle().getFlags () & lsfRequireDestTag)
- != 0;
- }
+ jvStatus["destination_tag"] =
+ (sleDest->getFlags () & lsfRequireDestTag)
+ != 0;
}
}
@@ -240,7 +239,7 @@ Json::Value PathRequest::doCreate (
if (bValid)
{
m_journal.debug << iIdentifier
- << " valid: " << raSrcAccount.humanAccountID ();
+ << " valid: " << toBase58(*raSrcAccount);
m_journal.debug << iIdentifier
<< " Deliver: " << saDstAmount.getFullText ();
}
@@ -260,7 +259,9 @@ int PathRequest::parseJson (Json::Value const& jvParams, bool complete)
if (jvParams.isMember (jss::source_account))
{
- if (!raSrcAccount.setAccountID (jvParams[jss::source_account].asString ()))
+ raSrcAccount = parseBase58(
+ jvParams[jss::source_account].asString());
+ if (! raSrcAccount)
{
jvStatus = rpcError (rpcSRC_ACT_MALFORMED);
return PFR_PJ_INVALID;
@@ -274,7 +275,9 @@ int PathRequest::parseJson (Json::Value const& jvParams, bool complete)
if (jvParams.isMember (jss::destination_account))
{
- if (!raDstAccount.setAccountID (jvParams[jss::destination_account].asString ()))
+ raDstAccount = parseBase58(
+ jvParams[jss::destination_account].asString());
+ if (! raDstAccount)
{
jvStatus = rpcError (rpcDST_ACT_MALFORMED);
return PFR_PJ_INVALID;
@@ -344,7 +347,7 @@ int PathRequest::parseJson (Json::Value const& jvParams, bool complete)
if (uCur.isNonZero() && uIss.isZero())
{
- uIss = raSrcAccount.getAccountID();
+ uIss = *raSrcAccount;
}
sciSourceCurrencies.insert ({uCur, uIss});
@@ -390,8 +393,8 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
if (sourceCurrencies.empty ())
{
auto usCurrencies =
- accountSourceCurrencies (raSrcAccount, cache, true);
- bool sameAccount = raSrcAccount == raDstAccount;
+ accountSourceCurrencies (*raSrcAccount, cache, true);
+ bool sameAccount = *raSrcAccount == *raDstAccount;
for (auto const& c: usCurrencies)
{
if (!sameAccount || (c != saDstAmount.getCurrency ()))
@@ -399,13 +402,13 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
if (c.isZero ())
sourceCurrencies.insert ({c, xrpAccount()});
else
- sourceCurrencies.insert ({c, raSrcAccount.getAccountID ()});
+ sourceCurrencies.insert ({c, *raSrcAccount});
}
}
}
- jvStatus[jss::source_account] = raSrcAccount.humanAccountID ();
- jvStatus[jss::destination_account] = raDstAccount.humanAccountID ();
+ jvStatus[jss::source_account] = getApp().accountIDCache().toBase58(*raSrcAccount);
+ jvStatus[jss::destination_account] = getApp().accountIDCache().toBase58(*raDstAccount);
jvStatus[jss::destination_amount] = saDstAmount.getJson (0);
if (!jvId.isNull ())
@@ -453,8 +456,8 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
FindPaths fp (
cache,
- raSrcAccount.getAccountID (),
- raDstAccount.getAccountID (),
+ *raSrcAccount,
+ *raDstAccount,
saDstAmount,
iLevel,
4); // iMaxPaths
@@ -486,7 +489,7 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
? currIssuer.account
: isXRP (currIssuer.currency)
? xrpAccount()
- : raSrcAccount.getAccountID ();
+ : *raSrcAccount;
STAmount saMaxAmount ({currIssuer.currency, sourceAccount}, 1);
saMaxAmount.negate ();
@@ -496,8 +499,8 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
sandbox,
saMaxAmount,
saDstAmount,
- raDstAccount.getAccountID (),
- raSrcAccount.getAccountID (),
+ *raDstAccount,
+ *raSrcAccount,
spsPaths);
if (!fullLiquidityPath.empty() &&
@@ -511,8 +514,8 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
sandbox,
saMaxAmount,
saDstAmount,
- raDstAccount.getAccountID (),
- raSrcAccount.getAccountID (),
+ *raDstAccount,
+ *raSrcAccount,
spsPaths);
if (rc.result () != tesSUCCESS)
m_journal.warning
diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h
index ac0c28731d..48d053bcc7 100644
--- a/src/ripple/app/paths/PathRequest.h
+++ b/src/ripple/app/paths/PathRequest.h
@@ -23,6 +23,8 @@
#include
#include
#include
+#include
+#include
#include