From 91ce7807b9134f557d24d0a7347df0f4251bddb3 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Mon, 24 Nov 2014 22:40:30 -0800 Subject: [PATCH] Remove legacy LoadTypes (RIPD-365) --- Builds/VisualStudio2013/RippleD.vcxproj | 5 -- .../VisualStudio2013/RippleD.vcxproj.filters | 6 -- src/ripple/app/main/Application.cpp | 2 +- src/ripple/app/main/LoadManager.cpp | 59 ++---------------- src/ripple/app/main/LoadManager.h | 15 ++--- src/ripple/resource/LegacyFees.h | 59 ------------------ src/ripple/resource/impl/LegacyFees.cpp | 61 ------------------- src/ripple/unity/resource.cpp | 1 - 8 files changed, 12 insertions(+), 196 deletions(-) delete mode 100644 src/ripple/resource/LegacyFees.h delete mode 100644 src/ripple/resource/impl/LegacyFees.cpp diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index d461b818cf..afb4e95513 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -2817,9 +2817,6 @@ - - True - @@ -2830,8 +2827,6 @@ - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 6b2fb30c88..73f67976fe 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -3900,9 +3900,6 @@ ripple\resource\impl - - ripple\resource\impl - ripple\resource\impl @@ -3915,9 +3912,6 @@ ripple\resource\impl - - ripple\resource - ripple\resource diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index ccda2ca971..2fe0194c3d 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -324,7 +324,7 @@ public: , mValidations (make_Validations ()) - , m_loadManager (LoadManager::New (*this, m_logs.journal("LoadManager"))) + , m_loadManager (make_LoadManager (*this, m_logs.journal("LoadManager"))) , m_sweepTimer (this) diff --git a/src/ripple/app/main/LoadManager.cpp b/src/ripple/app/main/LoadManager.cpp index 5994223c34..5ef961f1be 100644 --- a/src/ripple/app/main/LoadManager.cpp +++ b/src/ripple/app/main/LoadManager.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include // namespace ripple { @@ -28,51 +28,6 @@ class LoadManagerImp , public beast::Thread { public: - /* Entry mapping utilization to cost. - - The cost is expressed as a unitless relative quantity. These - mappings are statically loaded at startup with heuristic values. - */ - class Cost - { - public: - // VFALCO TODO Eliminate this default ctor somehow - Cost () - : m_loadType () - , m_cost (0) - , m_resourceFlags (0) - { - } - - Cost (LoadType loadType, int cost, int resourceFlags) - : m_loadType (loadType) - , m_cost (cost) - , m_resourceFlags (resourceFlags) - { - } - - LoadType getLoadType () const - { - return m_loadType; - } - - int getCost () const - { - return m_cost; - } - - int getResourceFlags () const - { - return m_resourceFlags; - } - - public: - // VFALCO TODO Make these private and const - LoadType m_loadType; - int m_cost; - int m_resourceFlags; - }; - //-------------------------------------------------------------------------- beast::Journal m_journal; @@ -83,9 +38,6 @@ public: bool mArmed; int mDeadLock; // Detect server deadlocks - - std::vector mCosts; - //-------------------------------------------------------------------------- LoadManagerImp (Stoppable& parent, beast::Journal journal) @@ -94,7 +46,6 @@ public: , m_journal (journal) , mArmed (false) , mDeadLock (0) - , mCosts (LT_MAX) { UptimeTimer::getInstance ().beginManualUpdates (); } @@ -208,7 +159,8 @@ public: // Another option is using an observer pattern to invert the dependency. if (getApp().getJobQueue ().isOverloaded ()) { - m_journal.info << getApp().getJobQueue ().getJson (0); + if (m_journal.info) + m_journal.info << getApp().getJobQueue ().getJson (0); change = getApp().getFeeTrack ().raiseLocalFee (); } else @@ -249,9 +201,10 @@ LoadManager::LoadManager (Stoppable& parent) //------------------------------------------------------------------------------ -LoadManager* LoadManager::New (Stoppable& parent, beast::Journal journal) +std::unique_ptr +make_LoadManager (beast::Stoppable& parent, beast::Journal journal) { - return new LoadManagerImp (parent, journal); + return std::make_unique (parent, journal); } } // ripple diff --git a/src/ripple/app/main/LoadManager.h b/src/ripple/app/main/LoadManager.h index a11371492b..bd291a2c5c 100644 --- a/src/ripple/app/main/LoadManager.h +++ b/src/ripple/app/main/LoadManager.h @@ -21,6 +21,7 @@ #define RIPPLE_LOADMANAGER_H_INCLUDED #include +#include // namespace ripple { @@ -34,8 +35,6 @@ namespace ripple { The warning system is used instead of merely dropping, because hostile peers can just reconnect anyway. - - @see LoadSource, LoadType */ class LoadManager : public beast::Stoppable { @@ -43,18 +42,11 @@ protected: explicit LoadManager (Stoppable& parent); public: - /** Create a new manager. - - @note The thresholds for warnings and punishments are in - the ctor-initializer - */ - static LoadManager* New (Stoppable& parent, beast::Journal journal); - /** Destroy the manager. The destructor returns only after the thread has stopped. */ - virtual ~LoadManager () { } + virtual ~LoadManager () = default; /** Turn on deadlock detection. @@ -78,6 +70,9 @@ public: virtual void resetDeadlockDetector () = 0; }; +std::unique_ptr +make_LoadManager (beast::Stoppable& parent, beast::Journal journal); + } // ripple #endif diff --git a/src/ripple/resource/LegacyFees.h b/src/ripple/resource/LegacyFees.h deleted file mode 100644 index 3323c53f05..0000000000 --- a/src/ripple/resource/LegacyFees.h +++ /dev/null @@ -1,59 +0,0 @@ -//------------------------------------------------------------------------------ -/* - 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_RESOURCE_LEGACYFEES_H_INCLUDED -#define RIPPLE_RESOURCE_LEGACYFEES_H_INCLUDED - -#include - -namespace ripple { - -enum LoadType -{ - // Bad things - LT_InvalidRequest, // A request that we can immediately tell is invalid - LT_RequestNoReply, // A request that we cannot satisfy - LT_InvalidSignature, // An object whose signature we had to check and it failed - LT_UnwantedData, // Data we have no use for - LT_BadData, // Data we have to verify before rejecting - - // RPC loads - LT_RPCInvalid, // An RPC request that we can immediately tell is invalid. - LT_RPCReference, // A default "reference" unspecified load - LT_RPCException, // An RPC load that causes an exception - LT_RPCBurden, // A particularly burdensome RPC load - - // Good things - LT_NewTrusted, // A new transaction/validation/proposal we trust - LT_NewTransaction, // A new, valid transaction - LT_NeededData, // Data we requested - - // Requests - LT_RequestData, // A request that is hard to satisfy, disk access - LT_CheapQuery, // A query that is trivial, cached data - - LT_MAX // MUST BE LAST -}; - -/** Returns an appropriate Charge based on the legacy LoadType. */ -extern Resource::Charge legacyFee (LoadType t); - -} - -#endif diff --git a/src/ripple/resource/impl/LegacyFees.cpp b/src/ripple/resource/impl/LegacyFees.cpp deleted file mode 100644 index 1164cb5908..0000000000 --- a/src/ripple/resource/impl/LegacyFees.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//------------------------------------------------------------------------------ -/* - 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 - -namespace ripple { -namespace Resource { - -Charge legacyFee (LoadType t) -{ - switch (t) - { - case LT_InvalidRequest: return feeInvalidRequest; - case LT_RequestNoReply: return feeRequestNoReply; - case LT_InvalidSignature: return feeInvalidSignature; - case LT_UnwantedData: return feeUnwantedData; - case LT_BadData: return feeBadData; - - case LT_RPCInvalid: return feeInvalidRPC; - case LT_RPCReference: return feeReferenceRPC; - case LT_RPCException: return feeExceptionRPC; - -#if 0 - case LT_RPCLight: return feeLightRPC; - case LT_RPCBurdenLow: return feeLowBurdenRPC; - case LT_RPCBurdenMedium: return feeMediumBurdenRPC; - case LT_RPCBurdenHigh: return feeHighBurdenRPC; -#endif - - case LT_NewTrusted: return feeNewTrustedNote; - case LT_NewTransaction: return feeNewValidTx; - case LT_NeededData: return feeSatisfiedRequest; - - case LT_RequestData: return feeRequestedData; - - default: - bassertfalse; - case LT_CheapQuery: return feeCheapQuery; - }; - - return feeInvalidRequest; -}; - -} -} diff --git a/src/ripple/unity/resource.cpp b/src/ripple/unity/resource.cpp index 56c842c175..0410a42fdf 100644 --- a/src/ripple/unity/resource.cpp +++ b/src/ripple/unity/resource.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include