Cleanup ripple::Ledger:

* Convert static member functions to free functions
* Adopt consistent naming convention
* De-inline code
This commit is contained in:
Nik Bougalis
2014-10-17 21:23:41 -07:00
parent 0e1dd92d9b
commit 31110c7fd9
36 changed files with 473 additions and 382 deletions

View File

@@ -2637,6 +2637,9 @@
<ClCompile Include="..\..\src\ripple\protocol\impl\HashPrefix.cpp"> <ClCompile Include="..\..\src\ripple\protocol\impl\HashPrefix.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple\protocol\impl\Indexes.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\protocol\impl\LedgerFormats.cpp"> <ClCompile Include="..\..\src\ripple\protocol\impl\LedgerFormats.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
@@ -2679,6 +2682,8 @@
<ClCompile Include="..\..\src\ripple\protocol\impl\TxFormats.cpp"> <ClCompile Include="..\..\src\ripple\protocol\impl\TxFormats.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\protocol\Indexes.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\protocol\JsonFields.h"> <ClInclude Include="..\..\src\ripple\protocol\JsonFields.h">
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\ripple\protocol\KnownFormats.h"> <ClInclude Include="..\..\src\ripple\protocol\KnownFormats.h">

View File

@@ -3705,6 +3705,9 @@
<ClCompile Include="..\..\src\ripple\protocol\impl\HashPrefix.cpp"> <ClCompile Include="..\..\src\ripple\protocol\impl\HashPrefix.cpp">
<Filter>ripple\protocol\impl</Filter> <Filter>ripple\protocol\impl</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple\protocol\impl\Indexes.cpp">
<Filter>ripple\protocol\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\protocol\impl\LedgerFormats.cpp"> <ClCompile Include="..\..\src\ripple\protocol\impl\LedgerFormats.cpp">
<Filter>ripple\protocol\impl</Filter> <Filter>ripple\protocol\impl</Filter>
</ClCompile> </ClCompile>
@@ -3747,6 +3750,9 @@
<ClCompile Include="..\..\src\ripple\protocol\impl\TxFormats.cpp"> <ClCompile Include="..\..\src\ripple\protocol\impl\TxFormats.cpp">
<Filter>ripple\protocol\impl</Filter> <Filter>ripple\protocol\impl</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\src\ripple\protocol\Indexes.h">
<Filter>ripple\protocol</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\protocol\JsonFields.h"> <ClInclude Include="..\..\src\ripple\protocol\JsonFields.h">
<Filter>ripple\protocol</Filter> <Filter>ripple\protocol</Filter>
</ClInclude> </ClInclude>

View File

@@ -70,7 +70,7 @@ public:
Quality const Quality const
quality() const noexcept quality() const noexcept
{ {
return Quality (Ledger::getQuality (m_dir)); return Quality (getQuality (m_dir));
} }
SLE::pointer const& SLE::pointer const&

View File

@@ -25,8 +25,8 @@ namespace core {
BookTip::BookTip (LedgerView& view, BookRef book) BookTip::BookTip (LedgerView& view, BookRef book)
: m_view (view) : m_view (view)
, m_valid (false) , m_valid (false)
, m_book (Ledger::getBookBase (book)) , m_book (getBookBase (book))
, m_end (Ledger::getQualityNext (m_book)) , m_end (getQualityNext (m_book))
{ {
} }

View File

@@ -381,7 +381,7 @@ void Ledger::setAccepted ()
bool Ledger::hasAccount (RippleAddress const& accountID) const bool Ledger::hasAccount (RippleAddress const& accountID) const
{ {
return mAccountStateMap->hasItem (Ledger::getAccountRootIndex (accountID)); return mAccountStateMap->hasItem (getAccountRootIndex (accountID));
} }
bool Ledger::addSLE (SLE const& sle) bool Ledger::addSLE (SLE const& sle)
@@ -392,13 +392,13 @@ bool Ledger::addSLE (SLE const& sle)
AccountState::pointer Ledger::getAccountState (RippleAddress const& accountID) const AccountState::pointer Ledger::getAccountState (RippleAddress const& accountID) const
{ {
SLE::pointer sle = getSLEi (Ledger::getAccountRootIndex (accountID)); SLE::pointer sle = getSLEi (getAccountRootIndex (accountID));
if (!sle) if (!sle)
{ {
WriteLog (lsDEBUG, Ledger) << "Ledger:getAccountState:" << WriteLog (lsDEBUG, Ledger) << "Ledger:getAccountState:" <<
" not found: " << accountID.humanAccountID () << " not found: " << accountID.humanAccountID () <<
": " << to_string (Ledger::getAccountRootIndex (accountID)); ": " << to_string (getAccountRootIndex (accountID));
return AccountState::pointer (); return AccountState::pointer ();
} }
@@ -1351,7 +1351,7 @@ void Ledger::visitAccountItems (
Account const& accountID, std::function<void (SLE::ref)> func) const Account const& accountID, std::function<void (SLE::ref)> func) const
{ {
// Visit each item in this account's owner directory // Visit each item in this account's owner directory
uint256 rootIndex = Ledger::getOwnerDirIndex (accountID); uint256 rootIndex = getOwnerDirIndex (accountID);
uint256 currentIndex = rootIndex; uint256 currentIndex = rootIndex;
while (1) while (1)
@@ -1371,7 +1371,7 @@ void Ledger::visitAccountItems (
if (!uNodeNext) if (!uNodeNext)
return; return;
currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext); currentIndex = getDirNodeIndex (rootIndex, uNodeNext);
} }
} }
@@ -1384,7 +1384,7 @@ bool Ledger::visitAccountItems (
std::function <bool (SLE::ref)> func) const std::function <bool (SLE::ref)> func) const
{ {
// Visit each item in this account's owner directory // Visit each item in this account's owner directory
uint256 const rootIndex (Ledger::getOwnerDirIndex (accountID)); uint256 const rootIndex (getOwnerDirIndex (accountID));
uint256 currentIndex (rootIndex); uint256 currentIndex (rootIndex);
// If startAfter is not zero try jumping to that page using the hint // If startAfter is not zero try jumping to that page using the hint
@@ -1431,7 +1431,7 @@ bool Ledger::visitAccountItems (
if (uNodeNext == 0) if (uNodeNext == 0)
return found; return found;
currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext); currentIndex = getDirNodeIndex (rootIndex, uNodeNext);
} }
} }
else else
@@ -1454,7 +1454,7 @@ bool Ledger::visitAccountItems (
if (uNodeNext == 0) if (uNodeNext == 0)
return true; return true;
currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext); currentIndex = getDirNodeIndex (rootIndex, uNodeNext);
} }
} }
} }
@@ -1597,88 +1597,29 @@ SLE::pointer Ledger::getGenerator (Account const& uGeneratorID) const
return getASNodeI (getGeneratorIndex (uGeneratorID), ltGENERATOR_MAP); return getASNodeI (getGeneratorIndex (uGeneratorID), ltGENERATOR_MAP);
} }
SLE::pointer Ledger::getOffer (uint256 const& uIndex) const SLE::pointer
Ledger::getOffer (uint256 const& uIndex) const
{ {
return getASNodeI (uIndex, ltOFFER); return getASNodeI (uIndex, ltOFFER);
} }
SLE::pointer Ledger::getRippleState (uint256 const& uNode) const SLE::pointer
Ledger::getOffer (Account const& account, std::uint32_t uSequence) const
{
return getOffer (getOfferIndex (account, uSequence));
}
SLE::pointer
Ledger::getRippleState (uint256 const& uNode) const
{ {
return getASNodeI (uNode, ltRIPPLE_STATE); return getASNodeI (uNode, ltRIPPLE_STATE);
} }
// For an entry put in the 64 bit index or quality. SLE::pointer
uint256 Ledger::getQualityIndex ( Ledger::getRippleState (
uint256 const& uBase, const std::uint64_t uNodeDir) Account const& a, Account const& b, Currency const& currency) const
{ {
// Indexes are stored in big endian format: they print as hex as stored. return getRippleState (getRippleStateIndex (a, b, currency));
// Most significant bytes are first. Least significant bytes represent
// adjacent entries. We place uNodeDir in the 8 right most bytes to be
// adjacent. Want uNodeDir in big endian format so ++ goes to the next
// entry for indexes.
uint256 uNode (uBase);
// TODO(tom): there must be a better way.
((std::uint64_t*) uNode.end ())[-1] = htobe64 (uNodeDir);
return uNode;
}
// Return the last 64 bits.
std::uint64_t Ledger::getQuality (uint256 const& uBase)
{
return be64toh (((std::uint64_t*) uBase.end ())[-1]);
}
uint256 Ledger::getQualityNext (uint256 const& uBase)
{
static uint256 uNext ("10000000000000000");
return uBase + uNext;
}
uint256 Ledger::getAccountRootIndex (Account const& account)
{
Serializer s (22);
s.add16 (spaceAccount); // 2
s.add160 (account); // 20
return s.getSHA512Half ();
}
uint256 Ledger::getLedgerFeeIndex ()
{
// get the index of the node that holds the fee schedul
Serializer s (2);
s.add16 (spaceFee);
return s.getSHA512Half ();
}
uint256 Ledger::getLedgerAmendmentIndex ()
{
// get the index of the node that holds the enabled amendments
Serializer s (2);
s.add16 (spaceAmendment);
return s.getSHA512Half ();
}
uint256 Ledger::getLedgerHashIndex ()
{
// get the index of the node that holds the last 256 ledgers
Serializer s (2);
s.add16 (spaceSkipList);
return s.getSHA512Half ();
}
uint256 Ledger::getLedgerHashIndex (std::uint32_t desiredLedgerIndex)
{
// Get the index of the node that holds the set of 256 ledgers that includes
// this ledger's hash (or the first ledger after it if it's not a multiple
// of 256).
Serializer s (6);
s.add16 (spaceSkipList);
s.add32 (desiredLedgerIndex >> 16);
return s.getSHA512Half ();
} }
uint256 Ledger::getLedgerHash (std::uint32_t ledgerIndex) uint256 Ledger::getLedgerHash (std::uint32_t ledgerIndex)
@@ -1786,112 +1727,6 @@ std::vector<uint256> Ledger::getLedgerAmendments () const
return usAmendments; return usAmendments;
} }
uint256 Ledger::getBookBase (Book const& book)
{
Serializer s (82);
s.add16 (spaceBookDir); // 2
s.add160 (book.in.currency); // 20
s.add160 (book.out.currency); // 20
s.add160 (book.in.account); // 20
s.add160 (book.out.account); // 20
// Return with quality 0.
uint256 uBaseIndex = getQualityIndex (s.getSHA512Half ());
WriteLog (lsTRACE, Ledger)
<< "getBookBase (" << book << ") = " << to_string (uBaseIndex);
assert (isConsistent (book));
return uBaseIndex;
}
uint256 Ledger::getDirNodeIndex (
uint256 const& uDirRoot, const std::uint64_t uNodeIndex)
{
if (uNodeIndex)
{
Serializer s (42);
s.add16 (spaceDirNode); // 2
s.add256 (uDirRoot); // 32
s.add64 (uNodeIndex); // 8
return s.getSHA512Half ();
}
else
{
return uDirRoot;
}
}
uint256 Ledger::getGeneratorIndex (Account const& uGeneratorID)
{
Serializer s (22);
s.add16 (spaceGenerator); // 2
s.add160 (uGeneratorID); // 20
return s.getSHA512Half ();
}
uint256 Ledger::getOfferIndex (Account const& account, std::uint32_t uSequence)
{
Serializer s (26);
s.add16 (spaceOffer); // 2
s.add160 (account); // 20
s.add32 (uSequence); // 4
return s.getSHA512Half ();
}
uint256 Ledger::getOwnerDirIndex (Account const& account)
{
Serializer s (22);
s.add16 (spaceOwnerDir); // 2
s.add160 (account); // 20
return s.getSHA512Half ();
}
uint256 Ledger::getRippleStateIndex (
Account const& a, Account const& b, Currency const& currency)
{
Serializer s (62);
s.add16 (spaceRipple); // 2
if (a < b)
{
s.add160 (a); // 20
s.add160 (b); // 20
}
else
{
s.add160 (b); // 20
s.add160 (a); // 20
}
s.add160 (currency); // 20
return s.getSHA512Half ();
}
uint256 Ledger::getTicketIndex (
Account const& account, std::uint32_t uSequence)
{
Serializer s (26);
s.add16 (spaceTicket); // 2
s.add160 (account); // 20
s.add32 (uSequence); // 4
return s.getSHA512Half ();
}
bool Ledger::walkLedger () const bool Ledger::walkLedger () const
{ {
std::vector <SHAMapMissingNode> missingNodes1; std::vector <SHAMapMissingNode> missingNodes1;
@@ -2108,7 +1943,7 @@ void Ledger::updateFees ()
std::int64_t reserveIncrement = getConfig ().FEE_OWNER_RESERVE; std::int64_t reserveIncrement = getConfig ().FEE_OWNER_RESERVE;
LedgerStateParms p = lepNONE; LedgerStateParms p = lepNONE;
auto sle = getASNode (p, Ledger::getLedgerFeeIndex (), ltFEE_SETTINGS); auto sle = getASNode (p, getLedgerFeeIndex (), ltFEE_SETTINGS);
if (sle) if (sle)
{ {
@@ -2209,7 +2044,7 @@ class Ledger_test : public beast::unit_test::suite
"D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000"); "D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000");
// VFALCO NOTE This fails in the original version as well. // VFALCO NOTE This fails in the original version as well.
expect (6125895493223874560 == Ledger::getQuality (uBig)); expect (6125895493223874560 == getQuality (uBig));
} }
public: public:
void run () void run ()

View File

@@ -330,18 +330,10 @@ public:
uint256 getPrevLedgerIndex (uint256 const& uHash, uint256 const& uBegin) const; uint256 getPrevLedgerIndex (uint256 const& uHash, uint256 const& uBegin) const;
// Ledger hash table function // Ledger hash table function
static uint256 getLedgerHashIndex ();
static uint256 getLedgerHashIndex (std::uint32_t desiredLedgerIndex);
static int getLedgerHashOffset (std::uint32_t desiredLedgerIndex);
static int getLedgerHashOffset (
std::uint32_t desiredLedgerIndex, std::uint32_t currentLedgerIndex);
uint256 getLedgerHash (std::uint32_t ledgerIndex); uint256 getLedgerHash (std::uint32_t ledgerIndex);
typedef std::vector<std::pair<std::uint32_t, uint256>> LedgerHashes; typedef std::vector<std::pair<std::uint32_t, uint256>> LedgerHashes;
LedgerHashes getLedgerHashes () const; LedgerHashes getLedgerHashes () const;
static uint256 getLedgerAmendmentIndex ();
static uint256 getLedgerFeeIndex ();
std::vector<uint256> getLedgerAmendments () const; std::vector<uint256> getLedgerAmendments () const;
std::vector<uint256> getNeededTransactionHashes ( std::vector<uint256> getNeededTransactionHashes (
@@ -349,60 +341,24 @@ public:
std::vector<uint256> getNeededAccountStateHashes ( std::vector<uint256> getNeededAccountStateHashes (
int max, SHAMapSyncFilter* filter) const; int max, SHAMapSyncFilter* filter) const;
// index calculation functions
static uint256 getAccountRootIndex (Account const&);
static uint256 getAccountRootIndex (const RippleAddress & account)
{
return getAccountRootIndex (account.getAccountID ());
}
// //
// Generator Map functions // Generator Map functions
// //
SLE::pointer getGenerator (Account const& uGeneratorID) const; SLE::pointer getGenerator (Account const& uGeneratorID) const;
static uint256 getGeneratorIndex (Account const& uGeneratorID);
//
// Order book functions
//
// Order book dirs have a base so we can use next to step through them in
// quality order.
static uint256 getBookBase (Book const&);
// //
// Offer functions // Offer functions
// //
SLE::pointer getOffer (uint256 const& uIndex) const; SLE::pointer getOffer (uint256 const& uIndex) const;
SLE::pointer getOffer (Account const& account, std::uint32_t uSequence) const SLE::pointer getOffer (Account const& account, std::uint32_t uSequence) const;
{
return getOffer (getOfferIndex (account, uSequence));
}
// The index of an offer.
static uint256 getOfferIndex (
Account const& account, std::uint32_t uSequence);
//
// Owner functions
//
// VFALCO NOTE This is a simple math operation that converts the account ID
// into a 256 bit object (I think....need to research this)
//
// All items controlled by an account are here: offers
static uint256 getOwnerDirIndex (Account const&account);
// //
// Directory functions // Directory functions
// Directories are doubly linked lists of nodes. // Directories are doubly linked lists of nodes.
// Given a directory root and and index compute the index of a node. // Given a directory root and and index compute the index of a node.
static uint256 getDirNodeIndex (
uint256 const& uDirRoot, const std::uint64_t uNodeIndex = 0);
static void ownerDirDescriber (SLE::ref, bool, Account const& owner); static void ownerDirDescriber (SLE::ref, bool, Account const& owner);
// Return a node: root or normal // Return a node: root or normal
@@ -412,48 +368,22 @@ public:
// Quality // Quality
// //
static uint256 getQualityIndex (
uint256 const& uBase, const std::uint64_t uNodeDir = 0);
static uint256 getQualityNext (uint256 const& uBase);
static std::uint64_t getQuality (uint256 const& uBase);
static void qualityDirDescriber ( static void qualityDirDescriber (
SLE::ref, bool, SLE::ref, bool,
Currency const& uTakerPaysCurrency, Account const& uTakerPaysIssuer, Currency const& uTakerPaysCurrency, Account const& uTakerPaysIssuer,
Currency const& uTakerGetsCurrency, Account const& uTakerGetsIssuer, Currency const& uTakerGetsCurrency, Account const& uTakerGetsIssuer,
const std::uint64_t & uRate); const std::uint64_t & uRate);
//
// Tickets
//
static uint256 getTicketIndex (
Account const& account, std::uint32_t uSequence);
// //
// Ripple functions : credit lines // Ripple functions : credit lines
// //
//
// Index of node which is the ripple state between two accounts for a
// currency.
//
// VFALCO NOTE Rename these to make it clear they are simple functions that
// don't access global variables. e.g.
// "calculateKeyFromRippleStateAndAddress"
static uint256 getRippleStateIndex (
Account const& a, Account const& b, Currency const& currency);
static uint256 getRippleStateIndex (
Account const& a, Issue const& issue)
{
return getRippleStateIndex (a, issue.account, issue.currency);
}
SLE::pointer getRippleState (uint256 const& uNode) const; SLE::pointer
getRippleState (uint256 const& uNode) const;
SLE::pointer getRippleState (
Account const& a, Account const& b, Currency const& currency) const SLE::pointer
{ getRippleState (
return getRippleState (getRippleStateIndex (a, b, currency)); Account const& a, Account const& b, Currency const& currency) const;
}
std::uint32_t getReferenceFeeUnits () std::uint32_t getReferenceFeeUnits ()
{ {

View File

@@ -384,7 +384,7 @@ bool LedgerEntrySet::threadTx (RippleAddress const& threadTo, Ledger::ref ledger
NodeToLedgerEntry& newMods) NodeToLedgerEntry& newMods)
{ {
SLE::pointer sle = getForMod ( SLE::pointer sle = getForMod (
Ledger::getAccountRootIndex (threadTo.getAccountID ()), ledger, newMods); getAccountRootIndex (threadTo.getAccountID ()), ledger, newMods);
#ifdef META_DEBUG #ifdef META_DEBUG
WriteLog (lsTRACE, LedgerEntrySet) << "Thread to " << threadTo.getAccountID (); WriteLog (lsTRACE, LedgerEntrySet) << "Thread to " << threadTo.getAccountID ();
@@ -591,7 +591,7 @@ TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, std::uint32_t& uCount)
do do
{ {
SLE::pointer sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeDir)); SLE::pointer sleNode = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeDir));
if (sleNode) if (sleNode)
{ {
@@ -617,7 +617,7 @@ bool LedgerEntrySet::dirIsEmpty (uint256 const& uRootIndex)
{ {
std::uint64_t uNodeDir = 0; std::uint64_t uNodeDir = 0;
SLE::pointer sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeDir)); SLE::pointer sleNode = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeDir));
if (!sleNode) if (!sleNode)
return true; return true;
@@ -665,7 +665,7 @@ TER LedgerEntrySet::dirAdd (
if (uNodeDir) if (uNodeDir)
{ {
// Try adding to last node. // Try adding to last node.
sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeDir)); sleNode = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeDir));
assert (sleNode); assert (sleNode);
} }
@@ -698,7 +698,7 @@ TER LedgerEntrySet::dirAdd (
entryModify (sleRoot); entryModify (sleRoot);
// Create the new node. // Create the new node.
sleNode = entryCreate (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeDir)); sleNode = entryCreate (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeDir));
sleNode->setFieldH256 (sfRootIndex, uRootIndex); sleNode->setFieldH256 (sfRootIndex, uRootIndex);
if (uNodeDir != 1) if (uNodeDir != 1)
@@ -734,7 +734,7 @@ TER LedgerEntrySet::dirDelete (
const bool bSoft) // --> True, uNodeDir is not hard and fast (pass uNodeDir=0). const bool bSoft) // --> True, uNodeDir is not hard and fast (pass uNodeDir=0).
{ {
std::uint64_t uNodeCur = uNodeDir; std::uint64_t uNodeCur = uNodeDir;
SLE::pointer sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeCur)); SLE::pointer sleNode = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeCur));
if (!sleNode) if (!sleNode)
{ {
@@ -836,7 +836,7 @@ TER LedgerEntrySet::dirDelete (
else else
{ {
// Have only a root node and a last node. // Have only a root node and a last node.
SLE::pointer sleLast = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeNext)); SLE::pointer sleLast = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeNext));
assert (sleLast); assert (sleLast);
@@ -858,11 +858,11 @@ TER LedgerEntrySet::dirDelete (
{ {
// Not root and not last node. Can delete node. // Not root and not last node. Can delete node.
SLE::pointer slePrevious = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodePrevious)); SLE::pointer slePrevious = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodePrevious));
assert (slePrevious); assert (slePrevious);
SLE::pointer sleNext = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeNext)); SLE::pointer sleNext = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeNext));
assert (slePrevious); assert (slePrevious);
assert (sleNext); assert (sleNext);
@@ -962,7 +962,7 @@ bool LedgerEntrySet::dirNext (
} }
else else
{ {
SLE::pointer sleNext = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeNext)); SLE::pointer sleNext = entryCache (ltDIR_NODE, getDirNodeIndex (uRootIndex, uNodeNext));
uDirEntry = 0; uDirEntry = 0;
if (!sleNext) if (!sleNext)
@@ -1046,7 +1046,7 @@ void LedgerEntrySet::incrementOwnerCount (SLE::ref sleAccount)
void LedgerEntrySet::incrementOwnerCount (Account const& owner) void LedgerEntrySet::incrementOwnerCount (Account const& owner)
{ {
incrementOwnerCount(entryCache (ltACCOUNT_ROOT, incrementOwnerCount(entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (owner))); getAccountRootIndex (owner)));
} }
void LedgerEntrySet::decrementOwnerCount (SLE::ref sleAccount) void LedgerEntrySet::decrementOwnerCount (SLE::ref sleAccount)
@@ -1070,7 +1070,7 @@ void LedgerEntrySet::decrementOwnerCount (SLE::ref sleAccount)
void LedgerEntrySet::decrementOwnerCount (Account const& owner) void LedgerEntrySet::decrementOwnerCount (Account const& owner)
{ {
decrementOwnerCount(entryCache (ltACCOUNT_ROOT, decrementOwnerCount(entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (owner))); getAccountRootIndex (owner)));
} }
TER LedgerEntrySet::offerDelete (SLE::pointer sleOffer) TER LedgerEntrySet::offerDelete (SLE::pointer sleOffer)
@@ -1089,7 +1089,7 @@ TER LedgerEntrySet::offerDelete (SLE::pointer sleOffer)
TER terResult = dirDelete ( TER terResult = dirDelete (
false, uOwnerNode, false, uOwnerNode,
Ledger::getOwnerDirIndex (owner), offerIndex, false, !bOwnerNode); getOwnerDirIndex (owner), offerIndex, false, !bOwnerNode);
TER terResult2 = dirDelete ( TER terResult2 = dirDelete (
false, uBookNode, uDirectory, offerIndex, true, false); false, uBookNode, uDirectory, offerIndex, true, false);
@@ -1112,7 +1112,7 @@ STAmount LedgerEntrySet::rippleHolds (
{ {
STAmount saBalance; STAmount saBalance;
SLE::pointer sleRippleState = entryCache (ltRIPPLE_STATE, SLE::pointer sleRippleState = entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (account, issuer, currency)); getRippleStateIndex (account, issuer, currency));
if (!sleRippleState) if (!sleRippleState)
{ {
@@ -1153,7 +1153,7 @@ STAmount LedgerEntrySet::accountHolds (
if (!currency) if (!currency)
{ {
SLE::pointer sleAccount = entryCache (ltACCOUNT_ROOT, SLE::pointer sleAccount = entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (account)); getAccountRootIndex (account));
std::uint64_t uReserve = mLedger->getReserve ( std::uint64_t uReserve = mLedger->getReserve (
sleAccount->getFieldU32 (sfOwnerCount)); sleAccount->getFieldU32 (sfOwnerCount));
@@ -1191,7 +1191,7 @@ bool LedgerEntrySet::isGlobalFrozen (Account const& issuer)
if (!enforceFreeze () || isXRP (issuer)) if (!enforceFreeze () || isXRP (issuer))
return false; return false;
SLE::pointer sle = entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (issuer)); SLE::pointer sle = entryCache (ltACCOUNT_ROOT, getAccountRootIndex (issuer));
if (sle && sle->isFlag (lsfGlobalFreeze)) if (sle && sle->isFlag (lsfGlobalFreeze))
return true; return true;
@@ -1208,7 +1208,7 @@ bool LedgerEntrySet::isFrozen(
if (!enforceFreeze () || isXRP (currency)) if (!enforceFreeze () || isXRP (currency))
return false; return false;
SLE::pointer sle = entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (issuer)); SLE::pointer sle = entryCache (ltACCOUNT_ROOT, getAccountRootIndex (issuer));
if (sle && sle->isFlag (lsfGlobalFreeze)) if (sle && sle->isFlag (lsfGlobalFreeze))
return true; return true;
@@ -1216,7 +1216,7 @@ bool LedgerEntrySet::isFrozen(
{ {
// Check if the issuer froze the line // Check if the issuer froze the line
sle = entryCache (ltRIPPLE_STATE, sle = entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (account, issuer, currency)); getRippleStateIndex (account, issuer, currency));
if (sle && sle->isFlag ((issuer > account) ? lsfHighFreeze : lsfLowFreeze)) if (sle && sle->isFlag ((issuer > account) ? lsfHighFreeze : lsfLowFreeze))
{ {
return true; return true;
@@ -1320,7 +1320,7 @@ TER LedgerEntrySet::trustCreate (
TER terResult = dirAdd ( TER terResult = dirAdd (
uLowNode, uLowNode,
Ledger::getOwnerDirIndex (uLowAccountID), getOwnerDirIndex (uLowAccountID),
sleRippleState->getIndex (), sleRippleState->getIndex (),
std::bind (&Ledger::ownerDirDescriber, std::bind (&Ledger::ownerDirDescriber,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_1, std::placeholders::_2,
@@ -1330,7 +1330,7 @@ TER LedgerEntrySet::trustCreate (
{ {
terResult = dirAdd ( terResult = dirAdd (
uHighNode, uHighNode,
Ledger::getOwnerDirIndex (uHighAccountID), getOwnerDirIndex (uHighAccountID),
sleRippleState->getIndex (), sleRippleState->getIndex (),
std::bind (&Ledger::ownerDirDescriber, std::bind (&Ledger::ownerDirDescriber,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_1, std::placeholders::_2,
@@ -1402,7 +1402,7 @@ TER LedgerEntrySet::trustDelete (
terResult = dirDelete ( terResult = dirDelete (
false, false,
uLowNode, uLowNode,
Ledger::getOwnerDirIndex (uLowAccountID), getOwnerDirIndex (uLowAccountID),
sleRippleState->getIndex (), sleRippleState->getIndex (),
false, false,
!bLowNode); !bLowNode);
@@ -1414,7 +1414,7 @@ TER LedgerEntrySet::trustDelete (
terResult = dirDelete ( terResult = dirDelete (
false, false,
uHighNode, uHighNode,
Ledger::getOwnerDirIndex (uHighAccountID), getOwnerDirIndex (uHighAccountID),
sleRippleState->getIndex (), sleRippleState->getIndex (),
false, false,
!bHighNode); !bHighNode);
@@ -1446,7 +1446,7 @@ TER LedgerEntrySet::rippleCredit (
assert (uSenderID != uReceiverID); assert (uSenderID != uReceiverID);
bool bSenderHigh = uSenderID > uReceiverID; bool bSenderHigh = uSenderID > uReceiverID;
uint256 uIndex = Ledger::getRippleStateIndex ( uint256 uIndex = getRippleStateIndex (
uSenderID, uReceiverID, saAmount.getCurrency ()); uSenderID, uReceiverID, saAmount.getCurrency ());
auto sleRippleState = entryCache (ltRIPPLE_STATE, uIndex); auto sleRippleState = entryCache (ltRIPPLE_STATE, uIndex);
@@ -1472,7 +1472,7 @@ TER LedgerEntrySet::rippleCredit (
uSenderID, uSenderID,
uReceiverID, uReceiverID,
uIndex, uIndex,
entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uReceiverID)), entryCache (ltACCOUNT_ROOT, getAccountRootIndex (uReceiverID)),
false, false,
false, false,
false, false,
@@ -1636,10 +1636,10 @@ TER LedgerEntrySet::accountSend (
TER terResult (tesSUCCESS); TER terResult (tesSUCCESS);
SLE::pointer sender = uSenderID != beast::zero SLE::pointer sender = uSenderID != beast::zero
? entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uSenderID)) ? entryCache (ltACCOUNT_ROOT, getAccountRootIndex (uSenderID))
: SLE::pointer (); : SLE::pointer ();
SLE::pointer receiver = uReceiverID != beast::zero SLE::pointer receiver = uReceiverID != beast::zero
? entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uReceiverID)) ? entryCache (ltACCOUNT_ROOT, getAccountRootIndex (uReceiverID))
: SLE::pointer (); : SLE::pointer ();
if (ShouldLog (lsTRACE, LedgerEntrySet)) if (ShouldLog (lsTRACE, LedgerEntrySet))
@@ -1708,7 +1708,7 @@ std::uint32_t
rippleTransferRate (LedgerEntrySet& ledger, Account const& issuer) rippleTransferRate (LedgerEntrySet& ledger, Account const& issuer)
{ {
SLE::pointer sleAccount (ledger.entryCache ( SLE::pointer sleAccount (ledger.entryCache (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (issuer))); ltACCOUNT_ROOT, getAccountRootIndex (issuer)));
std::uint32_t quality = QUALITY_ONE; std::uint32_t quality = QUALITY_ONE;

View File

@@ -78,7 +78,7 @@ static void updateHelper (SLE::ref entry,
book.out.account.copyFrom (entry->getFieldH160 (sfTakerGetsIssuer)); book.out.account.copyFrom (entry->getFieldH160 (sfTakerGetsIssuer));
book.out.currency.copyFrom (entry->getFieldH160 (sfTakerGetsCurrency)); book.out.currency.copyFrom (entry->getFieldH160 (sfTakerGetsCurrency));
uint256 index = Ledger::getBookBase (book); uint256 index = getBookBase (book);
if (seen.insert (index).second) if (seen.insert (index).second)
{ {
auto orderBook = std::make_shared<OrderBook> (index, book); auto orderBook = std::make_shared<OrderBook> (index, book);
@@ -156,7 +156,7 @@ void OrderBookDB::addOrderBook(Book const& book)
} }
} }
} }
uint256 index = Ledger::getBookBase(book); uint256 index = getBookBase(book);
auto orderBook = std::make_shared<OrderBook> (index, book); auto orderBook = std::make_shared<OrderBook> (index, book);
mSourceMap[book.in].push_back (orderBook); mSourceMap[book.in].push_back (orderBook);

View File

@@ -24,9 +24,9 @@ BookDirIterator::BookDirIterator(
Currency const& currencyIn, Account const& issuerIn, Currency const& currencyIn, Account const& issuerIn,
Currency const& currencyOut, Account const& issuerOut) Currency const& currencyOut, Account const& issuerOut)
{ {
mBase = Ledger::getBookBase({{currencyIn, issuerIn}, mBase = ripple::getBookBase({{currencyIn, issuerIn},
{currencyOut, issuerOut}}); {currencyOut, issuerOut}});
mEnd = Ledger::getQualityNext(mBase); mEnd = getQualityNext(mBase);
mIndex = mBase; mIndex = mBase;
} }
@@ -94,7 +94,7 @@ DirectoryEntryIterator BookDirIterator::getOfferIterator () const
std::uint64_t BookDirIterator::getRate () const std::uint64_t BookDirIterator::getRate () const
{ {
return Ledger::getQuality(mIndex); return getQuality(mIndex);
} }
bool BookDirIterator::addJson (Json::Value& jv) const bool BookDirIterator::addJson (Json::Value& jv) const

View File

@@ -67,7 +67,7 @@ public:
*/ */
std::uint64_t getCurrentQuality () const std::uint64_t getCurrentQuality () const
{ {
return Ledger::getQuality(mIndex); return getQuality(mIndex);
} }
/** Make this iterator refer to the next book /** Make this iterator refer to the next book

View File

@@ -31,7 +31,7 @@ AccountState::AccountState (RippleAddress const& naAccountID)
mValid = true; mValid = true;
mLedgerEntry = std::make_shared <SerializedLedgerEntry> ( mLedgerEntry = std::make_shared <SerializedLedgerEntry> (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (naAccountID)); ltACCOUNT_ROOT, getAccountRootIndex (naAccountID));
mLedgerEntry->setFieldAccount (sfAccount, naAccountID.getAccountID ()); mLedgerEntry->setFieldAccount (sfAccount, naAccountID.getAccountID ());
} }

View File

@@ -1143,7 +1143,7 @@ Json::Value NetworkOPsImp::getOwnerInfo (
Ledger::pointer lpLedger, RippleAddress const& naAccount) Ledger::pointer lpLedger, RippleAddress const& naAccount)
{ {
Json::Value jvObjects (Json::objectValue); Json::Value jvObjects (Json::objectValue);
auto uRootIndex = lpLedger->getOwnerDirIndex (naAccount.getAccountID ()); auto uRootIndex = getOwnerDirIndex (naAccount.getAccountID ());
auto sleNode = lpLedger->getDirNode (uRootIndex); auto sleNode = lpLedger->getDirNode (uRootIndex);
if (sleNode) if (sleNode)
@@ -1189,7 +1189,7 @@ Json::Value NetworkOPsImp::getOwnerInfo (
if (uNodeDir) if (uNodeDir)
{ {
sleNode = lpLedger->getDirNode ( sleNode = lpLedger->getDirNode (
Ledger::getDirNodeIndex (uRootIndex, uNodeDir)); getDirNodeIndex (uRootIndex, uNodeDir));
assert (sleNode); assert (sleNode);
} }
} }
@@ -2986,8 +2986,8 @@ void NetworkOPsImp::getBookPage (
(jvResult[jss::offers] = Json::Value (Json::arrayValue)); (jvResult[jss::offers] = Json::Value (Json::arrayValue));
std::map<Account, STAmount> umBalance; std::map<Account, STAmount> umBalance;
const uint256 uBookBase = Ledger::getBookBase (book); const uint256 uBookBase = getBookBase (book);
const uint256 uBookEnd = Ledger::getQualityNext (uBookBase); const uint256 uBookEnd = getQualityNext (uBookBase);
uint256 uTipIndex = uBookBase; uint256 uTipIndex = uBookBase;
if (m_journal.trace) if (m_journal.trace)
@@ -3036,7 +3036,7 @@ void NetworkOPsImp::getBookPage (
else else
{ {
uTipIndex = sleOfferDir->getIndex (); uTipIndex = sleOfferDir->getIndex ();
saDirRate = amountFromQuality (Ledger::getQuality (uTipIndex)); saDirRate = amountFromQuality (getQuality (uTipIndex));
lesActive.dirFirst ( lesActive.dirFirst (
uTipIndex, sleOfferDir, uBookEntry, offerIndex); uTipIndex, sleOfferDir, uBookEntry, offerIndex);

View File

@@ -189,7 +189,7 @@ std::vector<uint256> SerializedLedgerEntry::getOwners ()
auto entry = dynamic_cast<const STAccount*> (peekAtPIndex (i)); auto entry = dynamic_cast<const STAccount*> (peekAtPIndex (i));
if ((entry != nullptr) && entry->getValueH160 (account)) if ((entry != nullptr) && entry->getValueH160 (account))
owners.push_back (Ledger::getAccountRootIndex (account)); owners.push_back (getAccountRootIndex (account));
} }
if ((fc == sfLowLimit) || (fc == sfHighLimit)) if ((fc == sfLowLimit) || (fc == sfHighLimit))
@@ -201,7 +201,7 @@ std::vector<uint256> SerializedLedgerEntry::getOwners ()
auto issuer = entry->getIssuer (); auto issuer = entry->getIssuer ();
if (issuer.isNonZero ()) if (issuer.isNonZero ())
owners.push_back (Ledger::getAccountRootIndex (issuer)); owners.push_back (getAccountRootIndex (issuer));
} }
} }
} }

View File

@@ -30,13 +30,12 @@ STAmount creditLimit (
STAmount result ({currency, account}); STAmount result ({currency, account});
auto sleRippleState = ledger.entryCache (ltRIPPLE_STATE, auto sleRippleState = ledger.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (account, issuer, currency)); getRippleStateIndex (account, issuer, currency));
if (sleRippleState) if (sleRippleState)
{ {
result = sleRippleState->getFieldAmount ( result = sleRippleState->getFieldAmount (
account < issuer ? sfLowLimit : sfHighLimit); account < issuer ? sfLowLimit : sfHighLimit);
result.setIssuer (account); result.setIssuer (account);
} }
@@ -54,14 +53,13 @@ STAmount creditBalance (
STAmount result ({currency, account}); STAmount result ({currency, account});
auto sleRippleState = ledger.entryCache (ltRIPPLE_STATE, auto sleRippleState = ledger.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (account, issuer, currency)); getRippleStateIndex (account, issuer, currency));
if (sleRippleState) if (sleRippleState)
{ {
result = sleRippleState->getFieldAmount (sfBalance); result = sleRippleState->getFieldAmount (sfBalance);
if (account < issuer) if (account < issuer)
result.negate (); result.negate ();
result.setIssuer (account); result.setIssuer (account);
} }

View File

@@ -52,8 +52,8 @@ class NodeDirectory {
if (current != zero) if (current != zero)
return false; return false;
current.copyFrom (Ledger::getBookBase (book)); current.copyFrom (getBookBase (book));
next.copyFrom (Ledger::getQualityNext (current)); next.copyFrom (getQualityNext (current));
// TODO(tom): it seems impossible that any actual offers with // TODO(tom): it seems impossible that any actual offers with
// quality == 0 could occur - we should disallow them, and clear // quality == 0 could occur - we should disallow them, and clear

View File

@@ -263,7 +263,7 @@ TER PathState::pushNode (
{ {
auto sleRippleState = lesEntries.entryCache ( auto sleRippleState = lesEntries.entryCache (
ltRIPPLE_STATE, ltRIPPLE_STATE,
Ledger::getRippleStateIndex ( getRippleStateIndex (
backNode.account_, backNode.account_,
node.account_, node.account_,
backNode.issue_.currency)); backNode.issue_.currency));
@@ -290,7 +290,7 @@ TER PathState::pushNode (
auto sleBck = lesEntries.entryCache ( auto sleBck = lesEntries.entryCache (
ltACCOUNT_ROOT, ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (backNode.account_)); getAccountRootIndex (backNode.account_));
// Is the source account the highest numbered account ID? // Is the source account the highest numbered account ID?
bool bHigh = backNode.account_ > node.account_; bool bHigh = backNode.account_ > node.account_;
@@ -623,7 +623,7 @@ void PathState::checkFreeze()
if (nodes_[i].uFlags & STPathElement::typeIssuer) if (nodes_[i].uFlags & STPathElement::typeIssuer)
{ {
sle = lesEntries.entryCache (ltACCOUNT_ROOT, sle = lesEntries.entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (nodes_[i].issue_.account)); getAccountRootIndex (nodes_[i].issue_.account));
if (sle && sle->isFlag (lsfGlobalFreeze)) if (sle && sle->isFlag (lsfGlobalFreeze))
{ {
@@ -642,7 +642,7 @@ void PathState::checkFreeze()
if (inAccount != outAccount) if (inAccount != outAccount)
{ {
sle = lesEntries.entryCache (ltACCOUNT_ROOT, sle = lesEntries.entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (outAccount)); getAccountRootIndex (outAccount));
if (sle && sle->isFlag (lsfGlobalFreeze)) if (sle && sle->isFlag (lsfGlobalFreeze))
{ {
@@ -651,7 +651,7 @@ void PathState::checkFreeze()
} }
sle = lesEntries.entryCache (ltRIPPLE_STATE, sle = lesEntries.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (inAccount, getRippleStateIndex (inAccount,
outAccount, currencyID)); outAccount, currencyID));
if (sle && sle->isFlag ( if (sle && sle->isFlag (
@@ -679,9 +679,9 @@ TER PathState::checkNoRipple (
{ {
// fetch the ripple lines into and out of this node // fetch the ripple lines into and out of this node
SLE::pointer sleIn = lesEntries.entryCache (ltRIPPLE_STATE, SLE::pointer sleIn = lesEntries.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (firstAccount, secondAccount, currency)); getRippleStateIndex (firstAccount, secondAccount, currency));
SLE::pointer sleOut = lesEntries.entryCache (ltRIPPLE_STATE, SLE::pointer sleOut = lesEntries.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (secondAccount, thirdAccount, currency)); getRippleStateIndex (secondAccount, thirdAccount, currency));
if (!sleIn || !sleOut) if (!sleIn || !sleOut)
{ {

View File

@@ -248,14 +248,14 @@ bool Pathfinder::findPaths (int searchLevel)
bool bSrcXrp = isXRP (mSrcCurrency); bool bSrcXrp = isXRP (mSrcCurrency);
bool bDstXrp = isXRP (mDstAmount.getCurrency()); bool bDstXrp = isXRP (mDstAmount.getCurrency());
if (!mLedger->getSLEi (Ledger::getAccountRootIndex (mSrcAccount))) if (!mLedger->getSLEi (getAccountRootIndex (mSrcAccount)))
{ {
// We can't even start without a source account. // We can't even start without a source account.
WriteLog (lsDEBUG, Pathfinder) << "invalid source account"; WriteLog (lsDEBUG, Pathfinder) << "invalid source account";
return false; return false;
} }
if (!mLedger->getSLEi (Ledger::getAccountRootIndex (mDstAccount))) if (!mLedger->getSLEi (getAccountRootIndex (mDstAccount)))
{ {
// Can't find the destination account - we must be funding a new // Can't find the destination account - we must be funding a new
// account. // account.
@@ -637,8 +637,7 @@ int Pathfinder::getPathsOut (
if (!it.second) if (!it.second)
return it.first->second; return it.first->second;
auto sleAccount auto sleAccount = mLedger->getSLEi (getAccountRootIndex (account));
= mLedger->getSLEi (Ledger::getAccountRootIndex (account));
if (!sleAccount) if (!sleAccount)
return 0; return 0;
@@ -775,8 +774,8 @@ bool Pathfinder::isNoRipple (
Account const& toAccount, Account const& toAccount,
Currency const& currency) Currency const& currency)
{ {
SLE::pointer sleRipple = mLedger->getSLEi ( auto sleRipple = mLedger->getSLEi (
Ledger::getRippleStateIndex (toAccount, fromAccount, currency)); getRippleStateIndex (toAccount, fromAccount, currency));
auto const flag ((toAccount > fromAccount) auto const flag ((toAccount > fromAccount)
? lsfHighNoRipple : lsfLowNoRipple); ? lsfHighNoRipple : lsfLowNoRipple);
@@ -849,8 +848,8 @@ void Pathfinder::addLink (
else else
{ {
// search for accounts to add // search for accounts to add
auto sleEnd = mLedger->getSLEi( auto sleEnd = mLedger->getSLEi(getAccountRootIndex (uEndAccount));
Ledger::getAccountRootIndex (uEndAccount));
if (sleEnd) if (sleEnd)
{ {
bool const bRequireAuth ( bool const bRequireAuth (

View File

@@ -104,7 +104,7 @@ TER PathCursor::advanceNode (bool const bReverse) const
// Our quality changed since last iteration. // Our quality changed since last iteration.
// Use the rate from the directory. // Use the rate from the directory.
node().saOfrRate = amountFromQuality ( node().saOfrRate = amountFromQuality (
Ledger::getQuality (node().directory.current)); getQuality (node().directory.current));
// For correct ratio // For correct ratio
node().uEntry = 0; node().uEntry = 0;
node().bEntryAdvance = true; node().bEntryAdvance = true;

View File

@@ -212,7 +212,7 @@ rippleQuality (
if (destination != source) if (destination != source)
{ {
SLE::pointer sleRippleState (ledger.entryCache (ltRIPPLE_STATE, SLE::pointer sleRippleState (ledger.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (destination, source, currency))); getRippleStateIndex (destination, source, currency)));
// we should be able to assert(sleRippleState) here // we should be able to assert(sleRippleState) here

View File

@@ -67,7 +67,7 @@ public:
} }
SLE::pointer sleDst (mEngine->entryCache ( SLE::pointer sleDst (mEngine->entryCache (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID))); ltACCOUNT_ROOT, getAccountRootIndex (uDstAccountID)));
if (sleDst) if (sleDst)
{ {
@@ -105,7 +105,7 @@ public:
// Create the account. // Create the account.
sleDst = mEngine->entryCreate (ltACCOUNT_ROOT, sleDst = mEngine->entryCreate (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (uDstAccountID)); getAccountRootIndex (uDstAccountID));
sleDst->setFieldAccount (sfAccount, uDstAccountID); sleDst->setFieldAccount (sfAccount, uDstAccountID);
sleDst->setFieldU32 (sfSequence, 1); sleDst->setFieldU32 (sfSequence, 1);

View File

@@ -62,11 +62,9 @@ public:
return temBAD_SEQUENCE; return temBAD_SEQUENCE;
} }
uint256 const offerIndex ( uint256 const offerIndex (getOfferIndex (mTxnAccountID, uOfferSequence));
Ledger::getOfferIndex (mTxnAccountID, uOfferSequence));
SLE::pointer sleOffer ( SLE::pointer sleOffer (mEngine->entryCache (ltOFFER, offerIndex));
mEngine->entryCache (ltOFFER, offerIndex));
if (sleOffer) if (sleOffer)
{ {

View File

@@ -70,7 +70,7 @@ public:
std::uint64_t const hint (sleTicket->getFieldU64 (sfOwnerNode)); std::uint64_t const hint (sleTicket->getFieldU64 (sfOwnerNode));
TER const result = mEngine->view ().dirDelete (false, hint, TER const result = mEngine->view ().dirDelete (false, hint,
Ledger::getOwnerDirIndex (ticket_owner), ticketId, false, (hint == 0)); getOwnerDirIndex (ticket_owner), ticketId, false, (hint == 0));
mEngine->view ().decrementOwnerCount (mTxnAccount); mEngine->view ().decrementOwnerCount (mTxnAccount);
mEngine->view ().entryDelete (sleTicket); mEngine->view ().entryDelete (sleTicket);

View File

@@ -112,14 +112,12 @@ private:
{ {
uint256 amendment (mTxn.getFieldH256 (sfAmendment)); uint256 amendment (mTxn.getFieldH256 (sfAmendment));
SLE::pointer amendmentObject (mEngine->entryCache ( auto const index = getLedgerAmendmentIndex ();
ltAMENDMENTS, Ledger::getLedgerAmendmentIndex ()));
SLE::pointer amendmentObject (mEngine->entryCache (ltAMENDMENTS, index));
if (!amendmentObject) if (!amendmentObject)
{ amendmentObject = mEngine->entryCreate(ltAMENDMENTS, index);
amendmentObject = mEngine->entryCreate(
ltAMENDMENTS, Ledger::getLedgerAmendmentIndex());
}
STVector256 amendments (amendmentObject->getFieldV256 (sfAmendments)); STVector256 amendments (amendmentObject->getFieldV256 (sfAmendments));
@@ -143,12 +141,12 @@ private:
TER applyFee () TER applyFee ()
{ {
SLE::pointer feeObject = mEngine->entryCache ( auto const index = getLedgerFeeIndex ();
ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ());
SLE::pointer feeObject = mEngine->entryCache (ltFEE_SETTINGS, index);
if (!feeObject) if (!feeObject)
feeObject = mEngine->entryCreate ( feeObject = mEngine->entryCreate (ltFEE_SETTINGS, index);
ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ());
m_journal.trace << m_journal.trace <<
"Previous fee object: " << feeObject->getJson (0); "Previous fee object: " << feeObject->getJson (0);

View File

@@ -43,7 +43,7 @@ private:
assert (!isXRP (issue.currency)); assert (!isXRP (issue.currency));
SLE::pointer const issuerAccount = mEngine->entryCache ( SLE::pointer const issuerAccount = mEngine->entryCache (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (issue.account)); ltACCOUNT_ROOT, getAccountRootIndex (issue.account));
if (!issuerAccount) if (!issuerAccount)
{ {
@@ -59,7 +59,7 @@ private:
if (issuerAccount->getFieldU32 (sfFlags) & lsfRequireAuth) if (issuerAccount->getFieldU32 (sfFlags) & lsfRequireAuth)
{ {
SLE::pointer const trustLine (mEngine->entryCache ( SLE::pointer const trustLine (mEngine->entryCache (
ltRIPPLE_STATE, Ledger::getRippleStateIndex ( ltRIPPLE_STATE, getRippleStateIndex (
mTxnAccountID, issue.account, issue.currency))); mTxnAccountID, issue.account, issue.currency)));
if (!trustLine) if (!trustLine)
@@ -179,7 +179,7 @@ public:
std::uint32_t const uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence); std::uint32_t const uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence);
std::uint32_t const uSequence = mTxn.getSequence (); std::uint32_t const uSequence = mTxn.getSequence ();
const uint256 uLedgerIndex = Ledger::getOfferIndex (mTxnAccountID, uSequence); const uint256 uLedgerIndex = getOfferIndex (mTxnAccountID, uSequence);
if (m_journal.debug) if (m_journal.debug)
{ {
@@ -211,7 +211,7 @@ public:
view.bumpSeq (); // Begin ledger variance. view.bumpSeq (); // Begin ledger variance.
SLE::pointer sleCreator = mEngine->entryCache ( SLE::pointer sleCreator = mEngine->entryCache (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (mTxnAccountID)); ltACCOUNT_ROOT, getAccountRootIndex (mTxnAccountID));
if (uTxFlags & tfOfferCreateMask) if (uTxFlags & tfOfferCreateMask)
{ {
@@ -309,7 +309,7 @@ public:
if ((terResult == tesSUCCESS) && bHaveCancel) if ((terResult == tesSUCCESS) && bHaveCancel)
{ {
uint256 const uCancelIndex ( uint256 const uCancelIndex (
Ledger::getOfferIndex (mTxnAccountID, uCancelSequence)); getOfferIndex (mTxnAccountID, uCancelSequence));
SLE::pointer sleCancel = mEngine->entryCache (ltOFFER, uCancelIndex); SLE::pointer sleCancel = mEngine->entryCache (ltOFFER, uCancelIndex);
// It's not an error to not find the offer to cancel: it might have // It's not an error to not find the offer to cancel: it might have
@@ -485,7 +485,7 @@ public:
// Add offer to owner's directory. // Add offer to owner's directory.
terResult = view.dirAdd (uOwnerNode, terResult = view.dirAdd (uOwnerNode,
Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex, getOwnerDirIndex (mTxnAccountID), uLedgerIndex,
std::bind ( std::bind (
&Ledger::ownerDirDescriber, std::placeholders::_1, &Ledger::ownerDirDescriber, std::placeholders::_1,
std::placeholders::_2, mTxnAccountID)); std::placeholders::_2, mTxnAccountID));
@@ -495,7 +495,7 @@ public:
// Update owner count. // Update owner count.
view.incrementOwnerCount (sleCreator); view.incrementOwnerCount (sleCreator);
uint256 const uBookBase (Ledger::getBookBase ( uint256 const uBookBase (getBookBase (
{{uPaysCurrency, uPaysIssuerID}, {{uPaysCurrency, uPaysIssuerID},
{uGetsCurrency, uGetsIssuerID}})); {uGetsCurrency, uGetsIssuerID}}));
@@ -507,7 +507,7 @@ public:
"/" << to_string (saTakerGets.getIssuer ()); "/" << to_string (saTakerGets.getIssuer ());
// We use the original rate to place the offer. // We use the original rate to place the offer.
uDirectory = Ledger::getQualityIndex (uBookBase, uRate); uDirectory = getQualityIndex (uBookBase, uRate);
// Add offer to order book. // Add offer to order book.
terResult = view.dirAdd (uBookNode, uDirectory, uLedgerIndex, terResult = view.dirAdd (uBookNode, uDirectory, uLedgerIndex,

View File

@@ -68,7 +68,7 @@ public:
} }
SLE::pointer sleTicket = mEngine->entryCreate (ltTICKET, SLE::pointer sleTicket = mEngine->entryCreate (ltTICKET,
Ledger::getTicketIndex (mTxnAccountID, mTxn.getSequence ())); getTicketIndex (mTxnAccountID, mTxn.getSequence ()));
sleTicket->setFieldAccount (sfAccount, mTxnAccountID); sleTicket->setFieldAccount (sfAccount, mTxnAccountID);
sleTicket->setFieldU32 (sfSequence, mTxn.getSequence ()); sleTicket->setFieldU32 (sfSequence, mTxn.getSequence ());
@@ -81,7 +81,7 @@ public:
Account const target_account (mTxn.getFieldAccount160 (sfTarget)); Account const target_account (mTxn.getFieldAccount160 (sfTarget));
SLE::pointer sleTarget = mEngine->entryCache (ltACCOUNT_ROOT, SLE::pointer sleTarget = mEngine->entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (target_account)); getAccountRootIndex (target_account));
// Destination account does not exist. // Destination account does not exist.
if (!sleTarget) if (!sleTarget)
@@ -101,7 +101,7 @@ public:
}; };
TER result = mEngine->view ().dirAdd ( TER result = mEngine->view ().dirAdd (
hint, hint,
Ledger::getOwnerDirIndex (mTxnAccountID), getOwnerDirIndex (mTxnAccountID),
sleTicket->getIndex (), sleTicket->getIndex (),
describer); describer);

View File

@@ -178,7 +178,7 @@ public:
// //
// Open a ledger for editing. // Open a ledger for editing.
auto const index = Ledger::getAccountRootIndex (uDstAccountID); auto const index = getAccountRootIndex (uDstAccountID);
SLE::pointer sleDst (mEngine->entryCache (ltACCOUNT_ROOT, index)); SLE::pointer sleDst (mEngine->entryCache (ltACCOUNT_ROOT, index));
if (!sleDst) if (!sleDst)
@@ -220,7 +220,7 @@ public:
} }
// Create the account. // Create the account.
auto const newIndex = Ledger::getAccountRootIndex (uDstAccountID); auto const newIndex = getAccountRootIndex (uDstAccountID);
sleDst = mEngine->entryCreate (ltACCOUNT_ROOT, newIndex); sleDst = mEngine->entryCreate (ltACCOUNT_ROOT, newIndex);
sleDst->setFieldAccount (sfAccount, uDstAccountID); sleDst->setFieldAccount (sfAccount, uDstAccountID);
sleDst->setFieldU32 (sfSequence, 1); sleDst->setFieldU32 (sfSequence, 1);

View File

@@ -83,7 +83,7 @@ public:
if (bSetRequireAuth && !(uFlagsIn & lsfRequireAuth)) if (bSetRequireAuth && !(uFlagsIn & lsfRequireAuth))
{ {
if (!mEngine->view().dirIsEmpty (Ledger::getOwnerDirIndex (mTxnAccountID))) if (!mEngine->view().dirIsEmpty (getOwnerDirIndex (mTxnAccountID)))
{ {
m_journal.trace << "Retry: Owner directory not empty."; m_journal.trace << "Retry: Owner directory not empty.";

View File

@@ -126,7 +126,7 @@ public:
{ {
SLE::pointer selDelete ( SLE::pointer selDelete (
mEngine->entryCache (ltRIPPLE_STATE, mEngine->entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex ( getRippleStateIndex (
mTxnAccountID, uDstAccountID, currency))); mTxnAccountID, uDstAccountID, currency)));
if (selDelete) if (selDelete)
@@ -146,7 +146,7 @@ public:
} }
SLE::pointer sleDst (mEngine->entryCache ( SLE::pointer sleDst (mEngine->entryCache (
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID))); ltACCOUNT_ROOT, getAccountRootIndex (uDstAccountID)));
if (!sleDst) if (!sleDst)
{ {
@@ -159,7 +159,7 @@ public:
saLimitAllow.setIssuer (mTxnAccountID); saLimitAllow.setIssuer (mTxnAccountID);
SLE::pointer sleRippleState (mEngine->entryCache (ltRIPPLE_STATE, SLE::pointer sleRippleState (mEngine->entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (mTxnAccountID, uDstAccountID, currency))); getRippleStateIndex (mTxnAccountID, uDstAccountID, currency)));
if (sleRippleState) if (sleRippleState)
{ {
@@ -392,7 +392,7 @@ public:
// Zero balance in currency. // Zero balance in currency.
STAmount saBalance ({currency, noAccount()}); STAmount saBalance ({currency, noAccount()});
uint256 index (Ledger::getRippleStateIndex ( uint256 index (getRippleStateIndex (
mTxnAccountID, uDstAccountID, currency)); mTxnAccountID, uDstAccountID, currency));
m_journal.trace << m_journal.trace <<

View File

@@ -272,7 +272,7 @@ TER Transactor::apply ()
return (terResult); return (terResult);
mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT, mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (mTxnAccountID)); getAccountRootIndex (mTxnAccountID));
calculateFee (); calculateFee ();
// Find source account // Find source account

View File

@@ -139,7 +139,7 @@ TER TransactionEngine::applyTransaction (
mNodes.clear (); mNodes.clear ();
SLE::pointer txnAcct = entryCache (ltACCOUNT_ROOT, SLE::pointer txnAcct = entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (txn.getSourceAccount ())); getAccountRootIndex (txn.getSourceAccount ()));
if (!txnAcct) if (!txnAcct)
terResult = terNO_ACCOUNT; terResult = terNO_ACCOUNT;

View File

@@ -0,0 +1,92 @@
//------------------------------------------------------------------------------
/*
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.
*/
//==============================================================================
#ifndef RIPPLE_PROTOCOL_INDEXES_H_INCLUDED
#define RIPPLE_PROTOCOL_INDEXES_H_INCLUDED
#include <ripple/protocol/LedgerFormats.h>
#include <ripple/protocol/RippleAddress.h>
#include <ripple/protocol/Serializer.h>
#include <ripple/types/base_uint.h>
#include <ripple/types/Book.h>
#include <ripple/types/UintTypes.h>
namespace ripple {
// get the index of the node that holds the last 256 ledgers
uint256
getLedgerHashIndex ();
// Get the index of the node that holds the set of 256 ledgers that includes
// this ledger's hash (or the first ledger after it if it's not a multiple
// of 256).
uint256
getLedgerHashIndex (std::uint32_t desiredLedgerIndex);
// get the index of the node that holds the enabled amendments
uint256
getLedgerAmendmentIndex ();
// get the index of the node that holds the fee schedule
uint256
getLedgerFeeIndex ();
uint256
getAccountRootIndex (Account const& account);
uint256
getAccountRootIndex (const RippleAddress & account);
uint256
getGeneratorIndex (Account const& uGeneratorID);
uint256
getBookBase (Book const& book);
uint256
getOfferIndex (Account const& account, std::uint32_t uSequence);
uint256
getOwnerDirIndex (Account const& account);
uint256
getDirNodeIndex (uint256 const& uDirRoot, const std::uint64_t uNodeIndex);
uint256
getQualityIndex (uint256 const& uBase, const std::uint64_t uNodeDir = 0);
uint256
getQualityNext (uint256 const& uBase);
std::uint64_t
getQuality (uint256 const& uBase);
uint256
getTicketIndex (Account const& account, std::uint32_t uSequence);
uint256
getRippleStateIndex (Account const& a, Account const& b, Currency const& currency);
uint256
getRippleStateIndex (Account const& a, Issue const& issue);
}
#endif

View File

@@ -0,0 +1,228 @@
//------------------------------------------------------------------------------
/*
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 <ripple/protocol/Indexes.h>
#include <ripple/protocol/LedgerFormats.h>
#include <ripple/protocol/RippleAddress.h>
#include <ripple/protocol/Serializer.h>
#include <ripple/types/base_uint.h>
#include <ripple/types/Book.h>
#include <ripple/types/UintTypes.h>
namespace ripple {
// get the index of the node that holds the last 256 ledgers
uint256
getLedgerHashIndex ()
{
Serializer s (2);
s.add16 (spaceSkipList);
return s.getSHA512Half ();
}
// Get the index of the node that holds the set of 256 ledgers that includes
// this ledger's hash (or the first ledger after it if it's not a multiple
// of 256).
uint256
getLedgerHashIndex (std::uint32_t desiredLedgerIndex)
{
Serializer s (6);
s.add16 (spaceSkipList);
s.add32 (desiredLedgerIndex >> 16);
return s.getSHA512Half ();
}
// get the index of the node that holds the enabled amendments
uint256
getLedgerAmendmentIndex ()
{
Serializer s (2);
s.add16 (spaceAmendment);
return s.getSHA512Half ();
}
// get the index of the node that holds the fee schedule
uint256
getLedgerFeeIndex ()
{
Serializer s (2);
s.add16 (spaceFee);
return s.getSHA512Half ();
}
uint256
getAccountRootIndex (Account const& account)
{
Serializer s (22);
s.add16 (spaceAccount);
s.add160 (account);
return s.getSHA512Half ();
}
uint256
getAccountRootIndex (const RippleAddress & account)
{
return getAccountRootIndex (account.getAccountID ());
}
uint256
getGeneratorIndex (Account const& uGeneratorID)
{
Serializer s (22);
s.add16 (spaceGenerator);
s.add160 (uGeneratorID);
return s.getSHA512Half ();
}
uint256
getBookBase (Book const& book)
{
Serializer s (82);
assert (isConsistent (book));
s.add16 (spaceBookDir);
s.add160 (book.in.currency);
s.add160 (book.out.currency);
s.add160 (book.in.account);
s.add160 (book.out.account);
// Return with quality 0.
return getQualityIndex (s.getSHA512Half ());
}
uint256
getOfferIndex (Account const& account, std::uint32_t uSequence)
{
Serializer s (26);
s.add16 (spaceOffer);
s.add160 (account);
s.add32 (uSequence);
return s.getSHA512Half ();
}
uint256
getOwnerDirIndex (Account const& account)
{
Serializer s (22);
s.add16 (spaceOwnerDir);
s.add160 (account);
return s.getSHA512Half ();
}
uint256
getDirNodeIndex (uint256 const& uDirRoot, const std::uint64_t uNodeIndex)
{
if (uNodeIndex)
{
Serializer s (42);
s.add16 (spaceDirNode);
s.add256 (uDirRoot);
s.add64 (uNodeIndex);
return s.getSHA512Half ();
}
else
{
return uDirRoot;
}
}
uint256
getQualityIndex (uint256 const& uBase, const std::uint64_t uNodeDir)
{
// Indexes are stored in big endian format: they print as hex as stored.
// Most significant bytes are first. Least significant bytes represent
// adjacent entries. We place uNodeDir in the 8 right most bytes to be
// adjacent. Want uNodeDir in big endian format so ++ goes to the next
// entry for indexes.
uint256 uNode (uBase);
// TODO(tom): there must be a better way.
((std::uint64_t*) uNode.end ())[-1] = htobe64 (uNodeDir);
return uNode;
}
uint256
getQualityNext (uint256 const& uBase)
{
static uint256 uNext ("10000000000000000");
return uBase + uNext;
}
std::uint64_t
getQuality (uint256 const& uBase)
{
return be64toh (((std::uint64_t*) uBase.end ())[-1]);
}
uint256
getTicketIndex (Account const& account, std::uint32_t uSequence)
{
Serializer s (26);
s.add16 (spaceTicket);
s.add160 (account);
s.add32 (uSequence);
return s.getSHA512Half ();
}
uint256
getRippleStateIndex (Account const& a, Account const& b, Currency const& currency)
{
Serializer s (62);
s.add16 (spaceRipple);
if (a < b)
{
s.add160 (a);
s.add160 (b);
}
else
{
s.add160 (b);
s.add160 (a);
}
s.add160 (currency);
return s.getSHA512Half ();
}
uint256
getRippleStateIndex (Account const& a, Issue const& issue)
{
return getRippleStateIndex (a, issue.account, issue.currency);
}
}

View File

@@ -56,7 +56,7 @@ Json::Value doLedgerEntry (RPC::Context& context)
else else
{ {
uNodeIndex uNodeIndex
= Ledger::getAccountRootIndex (naAccount.getAccountID ()); = getAccountRootIndex (naAccount.getAccountID ());
} }
} }
else if (context.params.isMember ("directory")) else if (context.params.isMember ("directory"))
@@ -82,7 +82,7 @@ Json::Value doLedgerEntry (RPC::Context& context)
uDirRoot.SetHex (context.params["dir_root"].asString ()); uDirRoot.SetHex (context.params["dir_root"].asString ());
uNodeIndex = Ledger::getDirNodeIndex (uDirRoot, uSubIndex); uNodeIndex = getDirNodeIndex (uDirRoot, uSubIndex);
} }
else if (context.params["directory"].isMember ("owner")) else if (context.params["directory"].isMember ("owner"))
{ {
@@ -96,9 +96,9 @@ Json::Value doLedgerEntry (RPC::Context& context)
else else
{ {
uint256 uDirRoot uint256 uDirRoot
= Ledger::getOwnerDirIndex ( = getOwnerDirIndex (
naOwnerID.getAccountID ()); naOwnerID.getAccountID ());
uNodeIndex = Ledger::getDirNodeIndex (uDirRoot, uSubIndex); uNodeIndex = getDirNodeIndex (uDirRoot, uSubIndex);
} }
} }
else else
@@ -132,7 +132,7 @@ Json::Value doLedgerEntry (RPC::Context& context)
na0Public.setAccountPublic (naGenerator, 0); na0Public.setAccountPublic (naGenerator, 0);
uNodeIndex = Ledger::getGeneratorIndex (na0Public.getAccountID ()); uNodeIndex = getGeneratorIndex (na0Public.getAccountID ());
} }
} }
else if (context.params.isMember ("offer")) else if (context.params.isMember ("offer"))
@@ -156,9 +156,8 @@ Json::Value doLedgerEntry (RPC::Context& context)
} }
else else
{ {
auto uSequence = context.params["offer"]["seq"].asUInt (); uNodeIndex = getOfferIndex (naAccountID.getAccountID (),
uNodeIndex = Ledger::getOfferIndex ( context.params["offer"]["seq"].asUInt ());
naAccountID.getAccountID (), uSequence);
} }
} }
else if (context.params.isMember ("ripple_state")) else if (context.params.isMember ("ripple_state"))
@@ -195,7 +194,7 @@ Json::Value doLedgerEntry (RPC::Context& context)
} }
else else
{ {
uNodeIndex = Ledger::getRippleStateIndex ( uNodeIndex = getRippleStateIndex (
naA.getAccountID (), naB.getAccountID (), uCurrency); naA.getAccountID (), naB.getAccountID (), uCurrency);
} }
} }

View File

@@ -290,7 +290,7 @@ transactionSign (
if (verify) if (verify)
{ {
SLE::pointer sleAccountRoot = netOps.getSLEi (lSnapshot, SLE::pointer sleAccountRoot = netOps.getSLEi (lSnapshot,
Ledger::getAccountRootIndex (raSrcAddressID.getAccountID ())); getAccountRootIndex (raSrcAddressID.getAccountID ()));
if (!sleAccountRoot) if (!sleAccountRoot)
// XXX Ignore transactions for accounts not created. // XXX Ignore transactions for accounts not created.

View File

@@ -56,6 +56,8 @@
#include <ripple/basics/KeyCache.h> #include <ripple/basics/KeyCache.h>
#include <ripple/basics/TaggedCache.h> #include <ripple/basics/TaggedCache.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/app/data/Database.h> #include <ripple/app/data/Database.h>
#include <ripple/app/data/DatabaseCon.h> #include <ripple/app/data/DatabaseCon.h>
#include <ripple/app/data/SqliteDatabase.h> #include <ripple/app/data/SqliteDatabase.h>
@@ -113,7 +115,7 @@
#include <ripple/app/paths/PathRequest.h> #include <ripple/app/paths/PathRequest.h>
#include <ripple/app/paths/PathRequests.h> #include <ripple/app/paths/PathRequests.h>
#include <ripple/app/main/ParameterTable.h> #include <ripple/app/main/ParameterTable.h>
#include <ripple/app/paths/PathState.h> #include <ripple/app/paths/PathState.h>
#include <ripple/app/paths/RippleCalc.h> #include <ripple/app/paths/RippleCalc.h>
#endif #endif

View File

@@ -26,6 +26,7 @@
#include <ripple/protocol/impl/BuildInfo.cpp> #include <ripple/protocol/impl/BuildInfo.cpp>
#include <ripple/protocol/impl/SField.cpp> #include <ripple/protocol/impl/SField.cpp>
#include <ripple/protocol/impl/HashPrefix.cpp> #include <ripple/protocol/impl/HashPrefix.cpp>
#include <ripple/protocol/impl/Indexes.cpp>
#include <ripple/protocol/impl/LedgerFormats.cpp> #include <ripple/protocol/impl/LedgerFormats.cpp>
#include <ripple/protocol/impl/RippleAddress.cpp> #include <ripple/protocol/impl/RippleAddress.cpp>
#include <ripple/protocol/impl/STInteger.cpp> #include <ripple/protocol/impl/STInteger.cpp>