diff --git a/src/ripple/ledger/detail/ApplyStateTable.h b/src/ripple/ledger/detail/ApplyStateTable.h index 376578f2e4..d0aea9cf31 100644 --- a/src/ripple/ledger/detail/ApplyStateTable.h +++ b/src/ripple/ledger/detail/ApplyStateTable.h @@ -23,11 +23,10 @@ #include #include #include +#include #include #include #include -// VFALCO TODO Move TxMeta to ripple/ledger/ -#include namespace ripple { namespace detail { @@ -123,7 +122,7 @@ private: std::shared_ptr>; static - bool + void threadItem (TxMeta& meta, std::shared_ptr const& to); @@ -132,12 +131,12 @@ private: key_type const& key, Mods& mods, beast::Journal j); - bool + void threadTx (ReadView const& base, TxMeta& meta, AccountID const& to, Mods& mods, beast::Journal j); - bool + void threadOwners (ReadView const& base, TxMeta& meta, std::shared_ptr< SLE const> const& sle, Mods& mods, diff --git a/src/ripple/ledger/impl/ApplyStateTable.cpp b/src/ripple/ledger/impl/ApplyStateTable.cpp index 320181bc5b..4d5ab9b296 100644 --- a/src/ripple/ledger/impl/ApplyStateTable.cpp +++ b/src/ripple/ledger/impl/ApplyStateTable.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace ripple { @@ -475,27 +476,20 @@ ApplyStateTable::destroyXRP(std::uint64_t feeDrops) //------------------------------------------------------------------------------ -/* Add a tx to the account root's thread - Preconditions: - `to` is an account root in newMods or items_ -*/ -bool +// Insert this transaction to the SLE's threading list +void ApplyStateTable::threadItem (TxMeta& meta, - std::shared_ptr const& to) + std::shared_ptr const& sle) { key_type prevTxID; LedgerIndex prevLgrID; - if (! to->thread(meta.getTxID(), + if (! sle->thread(meta.getTxID(), meta.getLgrSeq(), prevTxID, prevLgrID)) - return false; - if (prevTxID.isZero () || - TxMeta::thread( - meta.getAffectedNode(to, - sfModifiedNode), prevTxID, - prevLgrID)) - return true; - assert (false); - return false; + return; + if (prevTxID.isZero()) + return; + TxMeta::thread(meta.getAffectedNode( + sle, sfModifiedNode), prevTxID, prevLgrID); } std::shared_ptr @@ -544,13 +538,13 @@ ApplyStateTable::getForMod (ReadView const& base, return sle; } -bool +void ApplyStateTable::threadTx (ReadView const& base, TxMeta& meta, AccountID const& to, Mods& mods, beast::Journal j) { - auto const sle = getForMod( - base, keylet::account(to).key, mods, j); + auto const sle = getForMod(base, + keylet::account(to).key, mods, j); assert(sle); if (! sle) { @@ -559,37 +553,44 @@ ApplyStateTable::threadTx (ReadView const& base, JLOG(j.fatal) << "Threading to non-existent account: " << toBase58(to); - return false; + return; } - - return threadItem (meta, sle); + threadItem (meta, sle); } -bool +void ApplyStateTable::threadOwners (ReadView const& base, TxMeta& meta, std::shared_ptr< SLE const> const& sle, Mods& mods, beast::Journal j) { - // thread new or modified sle to owner or owners - // VFALCO Why not isFieldPresent? - if (sle->getType() != ltACCOUNT_ROOT && - sle->getFieldIndex(sfAccount) != -1) + switch(sle->getType()) { - // thread to owner's account - return threadTx (base, meta, sle->getAccountID( - sfAccount), mods, j); - } - else if (sle->getType() == ltRIPPLE_STATE) + case ltACCOUNT_ROOT: { - // thread to owner's accounts - return - threadTx (base, meta, sle->getFieldAmount( - sfLowLimit).getIssuer(), mods, j) && - threadTx (base, meta, sle->getFieldAmount( - sfHighLimit).getIssuer(), mods, j); + // Nothing to do + break; + } + case ltSUSPAY: + { + threadTx (base, meta, (*sle)[sfAccount], mods, j); + threadTx (base, meta, (*sle)[sfDestination], mods, j); + break; + } + case ltRIPPLE_STATE: + { + threadTx (base, meta, (*sle)[sfLowLimit].getIssuer(), mods, j); + threadTx (base, meta, (*sle)[sfHighLimit].getIssuer(), mods, j); + break; + } + default: + { + // If sfAccount is present, thread to that account + if ((*sle)[~sfAccount]) + threadTx (base, meta, (*sle)[sfAccount], mods, j); + break; + } } - return false; } } // detail