diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 55c30d7b2..b76313505 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -1468,6 +1468,12 @@ + + True + True + ..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories) + ..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories) + True True @@ -1508,6 +1514,8 @@ + + True True @@ -1560,6 +1568,8 @@ + + True True diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index a5a1dac66..9e3782d18 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -262,6 +262,9 @@ {CE126498-A44D-30A2-345B-0F672BCDF947} + + {0EF1A571-94CC-4D70-E004-48579DF8AF2B} + {55A76B5B-A18E-E655-1A07-9492C6F8F356} @@ -2169,6 +2172,9 @@ ripple\app\ledger + + ripple\app\ledger\impl + ripple\app\ledger @@ -2199,6 +2205,9 @@ ripple\app\ledger + + ripple\app\ledger + ripple\app\ledger @@ -2241,6 +2250,9 @@ ripple\app\ledger + + ripple\app\ledger + ripple\app\ledger\tests diff --git a/src/ripple/app/ledger/InboundLedger.cpp b/src/ripple/app/ledger/InboundLedger.cpp index 8aeb6ccbc..38c2e2439 100644 --- a/src/ripple/app/ledger/InboundLedger.cpp +++ b/src/ripple/app/ledger/InboundLedger.cpp @@ -161,14 +161,15 @@ bool InboundLedger::tryLocal () if (m_journal.trace) m_journal.trace << "Ledger header found in fetch pack"; - mLedger = std::make_shared (data, true); + mLedger = std::make_shared ( + data.data(), data.size(), true); getApp().getNodeStore ().store ( hotLEDGER, std::move (data), mHash); } else { - mLedger = std::make_shared ( - strCopy (node->getData ()), true); + mLedger = std::make_shared( + node->getData().data(), node->getData().size(), true); } if (mLedger->getHash () != mHash) @@ -761,7 +762,8 @@ bool InboundLedger::takeHeader (std::string const& data) if (mComplete || mFailed || mHaveHeader) return true; - mLedger = std::make_shared (data, false); + mLedger = std::make_shared( + data.data(), data.size(), false); if (mLedger->getHash () != mHash) { diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 6b5ddf482..223fc2d10 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -55,10 +56,6 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount) , mParentCloseTime (0) , mCloseResolution (ledgerDefaultTimeResolution) , mCloseFlags (0) - , mClosed (false) - , mValidated (false) - , mValidHash (false) - , mAccepted (false) , mImmutable (false) , mTransactionMap (std::make_shared (SHAMapType::TRANSACTION, getApp().family(), deprecatedLogs().journal("SHAMap"))) @@ -77,8 +74,6 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount) writeBack (lepCREATE, startAccount->getSLE ()); mAccountStateMap->flushDirty (hotACCOUNT_NODE, mLedgerSeq); - - initializeFees (); } Ledger::Ledger (uint256 const& parentHash, @@ -100,10 +95,6 @@ Ledger::Ledger (uint256 const& parentHash, , mParentCloseTime (parentCloseTime) , mCloseResolution (closeResolution) , mCloseFlags (closeFlags) - , mClosed (false) - , mValidated (false) - , mValidHash (false) - , mAccepted (false) , mImmutable (true) , mTransactionMap (std::make_shared ( SHAMapType::TRANSACTION, transHash, getApp().family(), @@ -130,8 +121,6 @@ Ledger::Ledger (uint256 const& parentHash, mTransactionMap->setImmutable (); mAccountStateMap->setImmutable (); - - initializeFees (); } // Create a new ledger that's a snapshot of this one @@ -146,14 +135,12 @@ Ledger::Ledger (Ledger& ledger, , mCloseFlags (ledger.mCloseFlags) , mClosed (ledger.mClosed) , mValidated (ledger.mValidated) - , mValidHash (false) , mAccepted (ledger.mAccepted) , mImmutable (!isMutable) , mTransactionMap (ledger.mTransactionMap->snapShot (isMutable)) , mAccountStateMap (ledger.mAccountStateMap->snapShot (isMutable)) { updateHash (); - initializeFees (); } // Create a new ledger that follows this one @@ -164,10 +151,6 @@ Ledger::Ledger (bool /* dummy */, , mParentCloseTime (prevLedger.mCloseTime) , mCloseResolution (prevLedger.mCloseResolution) , mCloseFlags (0) - , mClosed (false) - , mValidated (false) - , mValidHash (false) - , mAccepted (false) , mImmutable (false) , mTransactionMap (std::make_shared (SHAMapType::TRANSACTION, getApp().family(), deprecatedLogs().journal("SHAMap"))) @@ -191,60 +174,34 @@ Ledger::Ledger (bool /* dummy */, { mCloseTime = prevLedger.mCloseTime + mCloseResolution; } - - initializeFees (); } -Ledger::Ledger (Blob const& rawLedger, - bool hasPrefix) - : mClosed (false) - , mValidated (false) - , mValidHash (false) - , mAccepted (false) - , mImmutable (true) +Ledger::Ledger (void const* data, + std::size_t size, bool hasPrefix) + : mImmutable (true) { - Serializer s (rawLedger); - - setRaw (s, hasPrefix); - - initializeFees (); + SerialIter sit (data, size); + setRaw (sit, hasPrefix); } -Ledger::Ledger (std::string const& rawLedger, bool hasPrefix) - : mClosed (false) - , mValidated (false) - , mValidHash (false) - , mAccepted (false) - , mImmutable (true) -{ - Serializer s (rawLedger); - setRaw (s, hasPrefix); - initializeFees (); -} - -/** Used for ledgers loaded from JSON files */ Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime) - : mTotCoins (0), - mLedgerSeq (ledgerSeq), - mCloseTime (closeTime), - mParentCloseTime (0), - mCloseResolution (ledgerDefaultTimeResolution), - mCloseFlags (0), - mClosed (false), - mValidated (false), - mValidHash (false), - mAccepted (false), - mImmutable (false), - mTransactionMap (std::make_shared ( + : mTotCoins (0) + , mLedgerSeq (ledgerSeq) + , mCloseTime (closeTime) + , mParentCloseTime (0) + , mCloseResolution (ledgerDefaultTimeResolution) + , mCloseFlags (0) + , mImmutable (false) + , mTransactionMap (std::make_shared ( SHAMapType::TRANSACTION, getApp().family(), - deprecatedLogs().journal("SHAMap"))), - mAccountStateMap (std::make_shared ( + deprecatedLogs().journal("SHAMap"))) + , mAccountStateMap (std::make_shared ( SHAMapType::STATE, getApp().family(), deprecatedLogs().journal("SHAMap"))) { - initializeFees (); } +//------------------------------------------------------------------------------ Ledger::~Ledger () { @@ -296,10 +253,8 @@ void Ledger::updateHash () mValidHash = true; } -void Ledger::setRaw (Serializer& s, bool hasPrefix) +void Ledger::setRaw (SerialIter& sit, bool hasPrefix) { - SerialIter sit (s); - if (hasPrefix) sit.get32 (); @@ -660,12 +615,9 @@ bool Ledger::saveValidatedLedger (bool current) { WriteLog (lsWARNING, Ledger) << "An accepted ledger was missing nodes"; getApp().getLedgerMaster().failedSave(mLedgerSeq, mHash); - { - // Clients can now trust the database for information about this - // ledger sequence. - StaticScopedLockType sl (sPendingSaveLock); - sPendingSaves.erase(getLedgerSeq()); - } + // Clients can now trust the database for information about this + // ledger sequence. + getApp().pendingSaves().erase(getLedgerSeq()); return false; } @@ -760,12 +712,9 @@ bool Ledger::saveValidatedLedger (bool current) to_string (mAccountHash) % to_string (mTransHash)); } - { - // Clients can now trust the database for information about this ledger - // sequence. - StaticScopedLockType sl (sPendingSaveLock); - sPendingSaves.erase(getLedgerSeq()); - } + // Clients can now trust the database for + // information about this ledger sequence. + getApp().pendingSaves().erase(getLedgerSeq()); return true; } @@ -1666,14 +1615,11 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent) assert (isImmutable ()); + if (!getApp().pendingSaves().insert(getLedgerSeq())) { - StaticScopedLockType sl (sPendingSaveLock); - if (!sPendingSaves.insert(getLedgerSeq()).second) - { - WriteLog (lsDEBUG, Ledger) - << "Pend save with seq in pending saves " << getLedgerSeq(); - return true; - } + WriteLog (lsDEBUG, Ledger) + << "Pend save with seq in pending saves " << getLedgerSeq(); + return true; } if (isSynchronous) @@ -1696,12 +1642,6 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent) return true; } -std::set Ledger::getPendingSaves() -{ - StaticScopedLockType sl (sPendingSaveLock); - return sPendingSaves; -} - void Ledger::ownerDirDescriber (SLE::ref sle, bool, Account const& owner) { sle->setFieldAccount (sfOwner, owner); @@ -1726,15 +1666,7 @@ void Ledger::qualityDirDescriber ( } } -void Ledger::initializeFees () -{ - mBaseFee = 0; - mReferenceFeeUnits = 0; - mReserveBase = 0; - mReserveIncrement = 0; -} - -void Ledger::updateFees () +void Ledger::deprecatedUpdateCachedFees() const { if (mBaseFee) return; @@ -1762,7 +1694,9 @@ void Ledger::updateFees () } { - StaticScopedLockType sl (sPendingSaveLock); + // VFALCO Why not do this before calling getASNode? + std::lock_guard< + std::mutex> lock(mutex_); if (mBaseFee == 0) { mBaseFee = baseFee; @@ -1773,21 +1707,6 @@ void Ledger::updateFees () } } -std::uint64_t Ledger::scaleFeeBase (std::uint64_t fee) -{ - // Converts a fee in fee units to a fee in drops - updateFees (); - return getApp().getFeeTrack ().scaleFeeBase ( - fee, mBaseFee, mReferenceFeeUnits); -} - -std::uint64_t Ledger::scaleFeeLoad (std::uint64_t fee, bool bAdmin) -{ - updateFees (); - return getApp().getFeeTrack ().scaleFeeLoad ( - fee, mBaseFee, mReferenceFeeUnits, bAdmin); -} - std::vector Ledger::getNeededTransactionHashes ( int max, SHAMapSyncFilter* filter) const { @@ -1820,7 +1739,4 @@ std::vector Ledger::getNeededAccountStateHashes ( return ret; } -Ledger::StaticLockType Ledger::sPendingSaveLock; -std::set Ledger::sPendingSaves; - } // ripple diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index d7cda5e80..ba8d07f92 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace ripple { @@ -119,6 +119,7 @@ public: // used for the starting bootstrap ledger Ledger (const RippleAddress & masterID, std::uint64_t startAmount); + // Used for ledgers loaded from JSON files Ledger (uint256 const& parentHash, uint256 const& transHash, uint256 const& accountHash, std::uint64_t totCoins, std::uint32_t closeTime, @@ -127,8 +128,8 @@ public: // used for database ledgers Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime); - Ledger (Blob const & rawLedger, bool hasPrefix); - Ledger (std::string const& rawLedger, bool hasPrefix); + Ledger (void const* data, + std::size_t size, bool hasPrefix); Ledger (bool dummy, Ledger & previous); // ledger after this one Ledger (Ledger & target, bool isMutable); // snapshot @@ -182,8 +183,8 @@ public: } // ledger signature operations - void addRaw (Serializer & s) const; - void setRaw (Serializer & s, bool hasPrefix); + void addRaw (Serializer& s) const; + void setRaw (SerialIter& sit, bool hasPrefix); uint256 const& getHash (); uint256 const& getParentHash () const @@ -380,39 +381,34 @@ public: getRippleState ( Account const& a, Account const& b, Currency const& currency) const; - std::uint32_t getReferenceFeeUnits () + std::uint32_t getReferenceFeeUnits() const { // Returns the cost of the reference transaction in fee units - updateFees (); + deprecatedUpdateCachedFees (); return mReferenceFeeUnits; } - std::uint64_t getBaseFee () + std::uint64_t getBaseFee() const { // Returns the cost of the reference transaction in drops - updateFees (); + deprecatedUpdateCachedFees (); return mBaseFee; } - std::uint64_t getReserve (int increments) + std::uint64_t getReserve (int increments) const { // Returns the required reserve in drops - updateFees (); + deprecatedUpdateCachedFees (); return static_cast (increments) * mReserveIncrement + mReserveBase; } - std::uint64_t getReserveInc () + std::uint64_t getReserveInc () const { - updateFees (); + deprecatedUpdateCachedFees (); return mReserveIncrement; } - std::uint64_t scaleFeeBase (std::uint64_t fee); - std::uint64_t scaleFeeLoad (std::uint64_t fee, bool bAdmin); - - static std::set getPendingSaves(); - /** Const version of getHash() which gets the current value without calling updateHash(). */ uint256 const& getRawHash () const @@ -437,11 +433,15 @@ protected: bool saveValidatedLedger (bool current); private: - void initializeFees (); - void updateFees (); + // Updates the fees cached in the ledger. + // Safe to call concurrently. We shouldn't be storing + // fees in the Ledger object, they should be a local side-structure + // associated with a particular module (rpc, tx processing, consensus) + // + void deprecatedUpdateCachedFees() const; // The basic Ledger structure, can be opened, closed, or synching - uint256 mHash; + uint256 mHash; // VFALCO This could be boost::optional uint256 mParentHash; uint256 mTransHash; uint256 mAccountHash; @@ -459,28 +459,28 @@ private: // flags indicating how this ledger close took place std::uint32_t mCloseFlags; - bool mClosed, mValidated, mValidHash, mAccepted, mImmutable; - - // Fee units for the reference transaction - std::uint32_t mReferenceFeeUnits; - - // Reserve basse and increment in fee units - std::uint32_t mReserveBase, mReserveIncrement; - - // Ripple cost of the reference transaction - std::uint64_t mBaseFee; + bool mClosed = false; + bool mValidated = false; + bool mValidHash = false; + bool mAccepted = false; + bool mImmutable; std::shared_ptr mTransactionMap; std::shared_ptr mAccountStateMap; - typedef RippleMutex StaticLockType; - typedef std::lock_guard StaticScopedLockType; + // Protects fee variables + std::mutex mutable mutex_; - // Ledgers not fully saved, validated ledger present but DB may not be - // correct yet. - static StaticLockType sPendingSaveLock; + // Ripple cost of the reference transaction + std::uint64_t mutable mBaseFee = 0; - static std::set sPendingSaves; + // Fee units for the reference transaction + std::uint32_t mutable mReferenceFeeUnits = 0; + + // Reserve base in fee units + std::uint32_t mutable mReserveBase = 0; + // Reserve increment in fee units + std::uint32_t mutable mReserveIncrement = 0; }; inline LedgerStateParms operator| ( diff --git a/src/ripple/app/ledger/LedgerFees.h b/src/ripple/app/ledger/LedgerFees.h new file mode 100644 index 000000000..be2aebc37 --- /dev/null +++ b/src/ripple/app/ledger/LedgerFees.h @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------------ +/* + 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_APP_FEES_H_INCLUDED +#define RIPPLE_APP_FEES_H_INCLUDED + +#include +#include + +namespace ripple { + +// VFALCO Replace std::uint64_t with a real type, maybe Amount? +// Converts a fee in fee units to a fee in drops +std::uint64_t +scaleFeeBase (LoadFeeTrack& track, + Ledger const& ledger, std::uint64_t fee); + +std::uint64_t +scaleFeeLoad (LoadFeeTrack& track, + Ledger const& ledger, std::uint64_t fee, bool admin); + +} + +#endif diff --git a/src/ripple/app/ledger/LedgerMaster.cpp b/src/ripple/app/ledger/LedgerMaster.cpp index 70d3c6616..25b71439c 100644 --- a/src/ripple/app/ledger/LedgerMaster.cpp +++ b/src/ripple/app/ledger/LedgerMaster.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -480,20 +481,21 @@ public: // Remove from the validated range any ledger sequences that may not be // fully updated in the database yet - std::set sPendingSaves = Ledger::getPendingSaves(); + auto const pendingSaves = + getApp().pendingSaves().getSnapshot(); - if (!sPendingSaves.empty() && ((minVal != 0) || (maxVal != 0))) + if (!pendingSaves.empty() && ((minVal != 0) || (maxVal != 0))) { // Ensure we shrink the tips as much as possible // If we have 7-9 and 8,9 are invalid, we don't want to see the 8 and shrink to just 9 // because then we'll have nothing when we could have 7. - while (sPendingSaves.count(maxVal) > 0) + while (pendingSaves.count(maxVal) > 0) --maxVal; - while (sPendingSaves.count(minVal) > 0) + while (pendingSaves.count(minVal) > 0) ++minVal; // Best effort for remaining exclusions - for(auto v : sPendingSaves) + for(auto v : pendingSaves) { if ((v >= minVal) && (v <= maxVal)) { diff --git a/src/ripple/app/ledger/PendingSaves.h b/src/ripple/app/ledger/PendingSaves.h new file mode 100644 index 000000000..bc644cf21 --- /dev/null +++ b/src/ripple/app/ledger/PendingSaves.h @@ -0,0 +1,86 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012-2015 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_APP_PENDINGSAVES_H_INCLUDED +#define RIPPLE_APP_PENDINGSAVES_H_INCLUDED + +#include +#include +#include + +namespace ripple { + +/** Keeps track of which ledgers haven't been fully saved. + + During the ledger building process this collection will keep + track of those ledgers that are being built but have not yet + been completely written. +*/ +class PendingSaves +{ +private: + std::mutex mutable mutex_; + boost::container::flat_set set_; + +public: + /** Add a ledger to the list. + + This is called when the ledger is built but before + we have updated the SQLite indexes. Clients querying + the indexes will not see results from this ledger. + + @return `true` If the ledger indexes was not + already in the list. + */ + bool + insert (LedgerIndex seq) + { + std::lock_guard< + std::mutex> lock(mutex_); + return set_.insert(seq).second; + } + + /** Remove a ledger from the list. + + This is called after the ledger has been fully saved, + indicating that the SQLite indexes will produce correct + results in response to client requests. + */ + void + erase (LedgerIndex seq) + { + std::lock_guard< + std::mutex> lock(mutex_); + set_.erase(seq); + } + + /** Returns a copy of the current set. */ + auto + getSnapshot() const -> + decltype(set_) + { + std::lock_guard< + std::mutex> lock(mutex_); + return set_; + } +}; + +} + +#endif diff --git a/src/ripple/app/ledger/impl/LedgerFees.cpp b/src/ripple/app/ledger/impl/LedgerFees.cpp new file mode 100644 index 000000000..32da76eca --- /dev/null +++ b/src/ripple/app/ledger/impl/LedgerFees.cpp @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +/* + 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 +#include + +namespace ripple { + +std::uint64_t +scaleFeeBase (LoadFeeTrack& track, + Ledger const& ledger, std::uint64_t fee) +{ + return track.scaleFeeBase (fee, + ledger.getBaseFee(), ledger.getReferenceFeeUnits()); +} + +std::uint64_t +scaleFeeLoad (LoadFeeTrack& track, + Ledger const& ledger, std::uint64_t fee, bool admin) +{ + return track.scaleFeeLoad (fee, + ledger.getBaseFee(), ledger.getReferenceFeeUnits(), + admin); +} + +} // ripple diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 75f768185..b3b4046e5 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -257,6 +258,7 @@ public: NodeStoreScheduler m_nodeStoreScheduler; std::unique_ptr m_shaMapStore; std::unique_ptr m_nodeStore; + PendingSaves pendingSaves_; // These are not Stoppable-derived NodeCache m_tempNodeCache; @@ -591,6 +593,11 @@ public: return *m_shaMapStore; } + PendingSaves& pendingSaves() override + { + return pendingSaves_; + } + Overlay& overlay () { return *m_overlay; diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index 830778f99..58f9cf9ea 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -56,6 +56,7 @@ class NetworkOPs; class OrderBookDB; class Overlay; class PathRequests; +class PendingSaves; class STLedgerEntry; class TransactionMaster; class Validations; @@ -114,7 +115,7 @@ public: virtual Resource::Manager& getResourceManager () = 0; virtual PathRequests& getPathRequests () = 0; virtual SHAMapStore& getSHAMapStore () = 0; - + virtual PendingSaves& pendingSaves() = 0; virtual DatabaseCon& getTxnDB () = 0; virtual DatabaseCon& getLedgerDB () = 0; diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h index d40ddde37..5371c719e 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/ripple/app/paths/PathRequest.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include namespace ripple { diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 289d05d09..071d73c75 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -18,6 +18,8 @@ //============================================================================== #include +#include +#include #include #include #include @@ -100,8 +102,8 @@ Transactor::Transactor ( void Transactor::calculateFee () { - mFeeDue = STAmount (mEngine->getLedger ()->scaleFeeLoad ( - calculateBaseFee (), mParams & tapADMIN)); + mFeeDue = STAmount (scaleFeeLoad (getApp().getFeeTrack(), + *mEngine->getLedger(), calculateBaseFee (), mParams & tapADMIN)); } std::uint64_t Transactor::calculateBaseFee () diff --git a/src/ripple/protocol/Protocol.h b/src/ripple/protocol/Protocol.h index d9970ff55..6b319e3f8 100644 --- a/src/ripple/protocol/Protocol.h +++ b/src/ripple/protocol/Protocol.h @@ -59,18 +59,18 @@ public: /** A ledger index. */ // VFALCO TODO pick one. I like Index since its not an abbreviation -typedef std::uint32_t LedgerIndex; +using LedgerIndex = std::uint32_t; // VFALCO NOTE "LedgerSeq" appears in some SQL statement text -typedef std::uint32_t LedgerSeq; +using LedgerSeq = std::uint32_t; /** A transaction identifier. + The value is computed as the hash of the + canonicalized, serialized transaction object. */ -// VFALCO TODO maybe rename to TxHash -typedef uint256 TxID; +using TxID = uint256; -/** A transaction index. -*/ -typedef std::uint32_t TxSeq; // VFALCO NOTE Should read TxIndex or TxNum +/** A transaction index. */ +using TxSeq = std::uint32_t; } // ripple diff --git a/src/ripple/rpc/handlers/NoRippleCheck.cpp b/src/ripple/rpc/handlers/NoRippleCheck.cpp index 5deca1972..69180c22e 100644 --- a/src/ripple/rpc/handlers/NoRippleCheck.cpp +++ b/src/ripple/rpc/handlers/NoRippleCheck.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -32,7 +33,8 @@ static void fillTransaction ( { txArray["Sequence"] = Json::UInt (sequence++); txArray["Account"] = account.humanAccountID (); - txArray["Fee"] = Json::UInt (ledger->scaleFeeLoad (10, false)); + txArray["Fee"] = Json::UInt (scaleFeeLoad ( + getApp().getFeeTrack(), *ledger, 10, false)); } // { diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index cc10730fc..99dad4ccf 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include #include @@ -172,7 +173,8 @@ std::uint64_t TxnSignApiFacade::scaleFeeBase (std::uint64_t fee) const if (!ledger_) // Unit testing. return fee; - return ledger_->scaleFeeBase (fee); + return ripple::scaleFeeBase( + getApp().getFeeTrack(), *ledger_, fee); } std::uint64_t @@ -181,7 +183,9 @@ TxnSignApiFacade::scaleFeeLoad (std::uint64_t fee, bool bAdmin) const if (!ledger_) // Unit testing. return fee; - return ledger_->scaleFeeLoad (fee, bAdmin); + return ripple::scaleFeeLoad ( + getApp().getFeeTrack(), + *ledger_, fee, bAdmin); } bool TxnSignApiFacade::hasAccountRoot () const diff --git a/src/ripple/unity/app3.cpp b/src/ripple/unity/app3.cpp index 2528ca9ad..1be28f760 100644 --- a/src/ripple/unity/app3.cpp +++ b/src/ripple/unity/app3.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include