Make offerDelete and fill Items more robust.

This commit is contained in:
David Schwartz
2014-01-02 10:55:34 -08:00
committed by Vinnie Falco
parent 990fb20a2a
commit 486539b3d3
2 changed files with 19 additions and 14 deletions

View File

@@ -1074,21 +1074,17 @@ TER LedgerEntrySet::offerDelete (SLE::ref sleOffer, uint256 const& uOfferIndex,
bool bOwnerNode = sleOffer->isFieldPresent (sfOwnerNode); // Detect legacy dirs.
uint64 uOwnerNode = sleOffer->getFieldU64 (sfOwnerNode);
TER terResult = dirDelete (false, uOwnerNode, Ledger::getOwnerDirIndex (uOwnerID), uOfferIndex, false, !bOwnerNode);
if (tesSUCCESS == terResult)
{
ownerCountAdjust (uOwnerID, -1);
uint256 uDirectory = sleOffer->getFieldH256 (sfBookDirectory);
uint64 uBookNode = sleOffer->getFieldU64 (sfBookNode);
// Offer delete is always hard. Always have hints.
terResult = dirDelete (false, uBookNode, uDirectory, uOfferIndex, true, true);
}
// Offer delete is always hard. Always have hints.
uint256 uDirectory = sleOffer->getFieldH256 (sfBookDirectory);
uint64 uBookNode = sleOffer->getFieldU64 (sfBookNode);
TER terResult2 = dirDelete ( false, uBookNode, uDirectory, uOfferIndex, true, false);
entryDelete (sleOffer);
return terResult;
return (terResult == tesSUCCESS) ? terResult2 : terResult;
}
TER LedgerEntrySet::offerDelete (uint256 const& uOfferIndex)

View File

@@ -47,12 +47,21 @@ void AccountItems::fillItems (const uint160& accountID, Ledger::ref ledger)
// VFALCO TODO rename getSLEi() to something legible.
SLE::pointer sleCur = ledger->getSLEi (uNode);
AccountItem::pointer item = mOfType->makeItem (accountID, sleCur);
// VFALCO NOTE Under what conditions would makeItem() return nullptr?
if (item)
if (!sleCur)
{
mItems.push_back (item);
// item in directory not in ledger
}
else
{
AccountItem::pointer item = mOfType->makeItem (accountID, sleCur);
// VFALCO NOTE Under what conditions would makeItem() return nullptr?
// DJS NOTE If the item wasn't one this particular AccountItems was interested in
// (For example, if the owner is only interested in ripple lines and this is an offer)
if (item)
{
mItems.push_back (item);
}
}
}