Refactor LedgerEntrySet:

* Remove duplicate:
    This changes behavior to fix an apparent bug. The
    copy will now correctly inherit mParams instead
    of reverting to tapNONE

* Tidy up LedgerEntrySet declarations
* Tidy up TransactionEngine
* Tidy PathCursor declarations
* Add LedgerEntrySet::apply
* Add LedgerEntrySet ctor
* Add Keylet, keylet namespace
* Add defaulted copy members
* Use optional in TransactionEngine
* Use optional<LedgerEntrySet> in PathState
* Return shared_ptr in Ledger::fetch
* Don't call entryCache with zero
* Deprecate invalidate
* Remove default constructor
* Remove unused container API
* Remove CountedObject base class
* Remove insert, clear
* Remove entryCreate overload
* Remove unused and tidy up STLedgerEntry
* Make getEntry private and tidy
* Replace members with adjustOwnerCount free function
* Replace accountFunds with funds free function
This commit is contained in:
Vinnie Falco
2015-06-09 10:37:13 -04:00
committed by Nik Bougalis
parent aead038215
commit d21171b21e
32 changed files with 746 additions and 526 deletions

View File

@@ -101,11 +101,9 @@ private:
{
if (offer.fully_consumed ())
return true;
auto const funds (view.accountFunds (offer.owner(),
offer.amount().out, fhZERO_IF_FROZEN));
return (funds <= zero);
auto const amount = funds(view, offer.owner(),
offer.amount().out, fhZERO_IF_FROZEN);
return (amount <= zero);
}
static
@@ -202,7 +200,7 @@ private:
m_journal.debug << " in: " << offers_direct.tip ().amount().in;
m_journal.debug << " out: " << offers_direct.tip ().amount ().out;
m_journal.debug << " owner: " << offers_direct.tip ().owner ();
m_journal.debug << " funds: " << view.accountFunds (
m_journal.debug << " funds: " << funds(view,
offers_direct.tip ().owner (),
offers_direct.tip ().amount ().out,
fhIGNORE_FREEZE);
@@ -222,12 +220,12 @@ private:
{
if (m_journal.debug)
{
auto const owner1_funds_before = view.accountFunds (
auto const owner1_funds_before = funds(view,
offers_leg1.tip ().owner (),
offers_leg1.tip ().amount ().out,
fhIGNORE_FREEZE);
auto const owner2_funds_before = view.accountFunds (
auto const owner2_funds_before = funds(view,
offers_leg2.tip ().owner (),
offers_leg2.tip ().amount ().out,
fhIGNORE_FREEZE);
@@ -321,7 +319,7 @@ private:
m_journal.debug << " in: " << offer.amount ().in;
m_journal.debug << " out: " << offer.amount ().out;
m_journal.debug << " owner: " << offer.owner ();
m_journal.debug << " funds: " << view.accountFunds (
m_journal.debug << " funds: " << funds(view,
offer.owner (), offer.amount ().out, fhIGNORE_FREEZE);
}
@@ -604,7 +602,7 @@ public:
result = tecFROZEN;
}
else if (view.accountFunds (
else if (funds(view,
mTxnAccountID, saTakerGets, fhZERO_IF_FROZEN) <= zero)
{
if (m_journal.debug) m_journal.debug <<
@@ -795,7 +793,7 @@ public:
if (result == tesSUCCESS)
{
// Update owner count.
view.incrementOwnerCount (sleCreator);
adjustOwnerCount(view, sleCreator, 1);
if (m_journal.trace) m_journal.trace <<
"adding to book: " << to_string (saTakerPays.issue ()) <<
@@ -818,8 +816,7 @@ public:
if (result == tesSUCCESS)
{
SLE::pointer sleOffer (mEngine->view().entryCreate (ltOFFER, offer_index));
auto sleOffer = std::make_shared<SLE>(ltOFFER, offer_index);
sleOffer->setFieldAccount (sfAccount, mTxnAccountID);
sleOffer->setFieldU32 (sfSequence, uSequence);
sleOffer->setFieldH256 (sfBookDirectory, uDirectory);
@@ -827,15 +824,13 @@ public:
sleOffer->setFieldAmount (sfTakerGets, saTakerGets);
sleOffer->setFieldU64 (sfOwnerNode, uOwnerNode);
sleOffer->setFieldU64 (sfBookNode, uBookNode);
if (uExpiration)
sleOffer->setFieldU32 (sfExpiration, uExpiration);
if (bPassive)
sleOffer->setFlag (lsfPassive);
if (bSell)
sleOffer->setFlag (lsfSell);
mEngine->view().entryCreate(sleOffer);
}
if (result != tesSUCCESS)