Pass a bool to the describer telling it if the directory is new.

This commit is contained in:
JoelKatz
2013-09-16 18:12:21 -07:00
parent b45b029ba7
commit 74b2d1f3fa
5 changed files with 16 additions and 15 deletions

View File

@@ -1873,12 +1873,12 @@ std::set<uint32> Ledger::getPendingSaves()
return sPendingSaves; return sPendingSaves;
} }
void Ledger::ownerDirDescriber (SLE::ref sle, const uint160& owner) void Ledger::ownerDirDescriber (SLE::ref sle, bool, const uint160& owner)
{ {
sle->setFieldAccount (sfOwner, owner); sle->setFieldAccount (sfOwner, owner);
} }
void Ledger::qualityDirDescriber (SLE::ref sle, void Ledger::qualityDirDescriber (SLE::ref sle, bool,
const uint160& uTakerPaysCurrency, const uint160& uTakerPaysIssuer, const uint160& uTakerPaysCurrency, const uint160& uTakerPaysIssuer,
const uint160& uTakerGetsCurrency, const uint160& uTakerGetsIssuer, const uint160& uTakerGetsCurrency, const uint160& uTakerGetsIssuer,
const uint64& uRate) const uint64& uRate)

View File

@@ -364,7 +364,7 @@ public:
// 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 uint64 uNodeIndex = 0); static uint256 getDirNodeIndex (uint256 const & uDirRoot, const uint64 uNodeIndex = 0);
static void ownerDirDescriber (SLE::ref, const uint160 & owner); static void ownerDirDescriber (SLE::ref, bool, const uint160 & owner);
// Return a node: root or normal // Return a node: root or normal
SLE::pointer getDirNode (uint256 const & uNodeIndex); SLE::pointer getDirNode (uint256 const & uNodeIndex);
@@ -376,7 +376,7 @@ public:
static uint256 getQualityIndex (uint256 const & uBase, const uint64 uNodeDir = 0); static uint256 getQualityIndex (uint256 const & uBase, const uint64 uNodeDir = 0);
static uint256 getQualityNext (uint256 const & uBase); static uint256 getQualityNext (uint256 const & uBase);
static uint64 getQuality (uint256 const & uBase); static uint64 getQuality (uint256 const & uBase);
static void qualityDirDescriber (SLE::ref, static void qualityDirDescriber (SLE::ref, bool,
const uint160 & uTakerPaysCurrency, const uint160 & uTakerPaysIssuer, const uint160 & uTakerPaysCurrency, const uint160 & uTakerPaysIssuer,
const uint160 & uTakerGetsCurrency, const uint160 & uTakerGetsIssuer, const uint160 & uTakerGetsCurrency, const uint160 & uTakerGetsIssuer,
const uint64 & uRate); const uint64 & uRate);

View File

@@ -625,10 +625,10 @@ TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, uint32& uCount)
// Only append. This allow for things that watch append only structure to just monitor from the last node on ward. // Only append. This allow for things that watch append only structure to just monitor from the last node on ward.
// Within a node with no deletions order of elements is sequential. Otherwise, order of elements is random. // Within a node with no deletions order of elements is sequential. Otherwise, order of elements is random.
TER LedgerEntrySet::dirAdd ( TER LedgerEntrySet::dirAdd (
uint64& uNodeDir, uint64& uNodeDir,
uint256 const& uRootIndex, uint256 const& uRootIndex,
uint256 const& uLedgerIndex, uint256 const& uLedgerIndex,
FUNCTION_TYPE<void (SLE::ref)> fDescriber) FUNCTION_TYPE<void (SLE::ref, bool)> fDescriber)
{ {
WriteLog (lsTRACE, LedgerEntrySet) << boost::str (boost::format ("dirAdd: uRootIndex=%s uLedgerIndex=%s") WriteLog (lsTRACE, LedgerEntrySet) << boost::str (boost::format ("dirAdd: uRootIndex=%s uLedgerIndex=%s")
% uRootIndex.ToString () % uRootIndex.ToString ()
@@ -643,7 +643,7 @@ TER LedgerEntrySet::dirAdd (
// No root, make it. // No root, make it.
sleRoot = entryCreate (ltDIR_NODE, uRootIndex); sleRoot = entryCreate (ltDIR_NODE, uRootIndex);
sleRoot->setFieldH256 (sfRootIndex, uRootIndex); sleRoot->setFieldH256 (sfRootIndex, uRootIndex);
fDescriber (sleRoot); fDescriber (sleRoot, true);
sleNode = sleRoot; sleNode = sleRoot;
uNodeDir = 0; uNodeDir = 0;
@@ -694,7 +694,7 @@ TER LedgerEntrySet::dirAdd (
if (uNodeDir != 1) if (uNodeDir != 1)
sleNode->setFieldU64 (sfIndexPrevious, uNodeDir - 1); sleNode->setFieldU64 (sfIndexPrevious, uNodeDir - 1);
fDescriber (sleNode); fDescriber (sleNode, false);
svIndexes = STVector256 (); svIndexes = STVector256 ();
} }
@@ -1350,7 +1350,7 @@ TER LedgerEntrySet::trustCreate (
uLowNode, uLowNode,
Ledger::getOwnerDirIndex (uLowAccountID), Ledger::getOwnerDirIndex (uLowAccountID),
sleRippleState->getIndex (), sleRippleState->getIndex (),
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, uLowAccountID)); BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, uLowAccountID));
if (tesSUCCESS == terResult) if (tesSUCCESS == terResult)
{ {
@@ -1358,7 +1358,7 @@ TER LedgerEntrySet::trustCreate (
uHighNode, uHighNode,
Ledger::getOwnerDirIndex (uHighAccountID), Ledger::getOwnerDirIndex (uHighAccountID),
sleRippleState->getIndex (), sleRippleState->getIndex (),
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, uHighAccountID)); BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, uHighAccountID));
} }
if (tesSUCCESS == terResult) if (tesSUCCESS == terResult)

View File

@@ -147,7 +147,7 @@ public:
uint64 & uNodeDir, // Node of entry. uint64 & uNodeDir, // Node of entry.
uint256 const & uRootIndex, uint256 const & uRootIndex,
uint256 const & uLedgerIndex, uint256 const & uLedgerIndex,
FUNCTION_TYPE<void (SLE::ref)> fDescriber); FUNCTION_TYPE<void (SLE::ref, bool)> fDescriber);
TER dirDelete ( TER dirDelete (
const bool bKeepRoot, const bool bKeepRoot,

View File

@@ -637,7 +637,7 @@ TER OfferCreateTransactor::doApply ()
// Add offer to owner's directory. // Add offer to owner's directory.
terResult = lesActive.dirAdd (uOwnerNode, Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex, terResult = lesActive.dirAdd (uOwnerNode, Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex,
BIND_TYPE (&Ledger::ownerDirDescriber, P_1, mTxnAccountID)); BIND_TYPE (&Ledger::ownerDirDescriber, P_1, P_2, mTxnAccountID));
if (tesSUCCESS == terResult) if (tesSUCCESS == terResult)
@@ -657,7 +657,8 @@ TER OfferCreateTransactor::doApply ()
// Add offer to order book. // Add offer to order book.
terResult = lesActive.dirAdd (uBookNode, uDirectory, uLedgerIndex, terResult = lesActive.dirAdd (uBookNode, uDirectory, uLedgerIndex,
BIND_TYPE (&Ledger::qualityDirDescriber, P_1, saTakerPays.getCurrency (), uPaysIssuerID, BIND_TYPE (&Ledger::qualityDirDescriber, P_1, P_2,
saTakerPays.getCurrency (), uPaysIssuerID,
saTakerGets.getCurrency (), uGetsIssuerID, uRate)); saTakerGets.getCurrency (), uGetsIssuerID, uRate));
} }