Remove legacy LoadTypes (RIPD-365)

This commit is contained in:
Nik Bougalis
2014-11-24 22:40:30 -08:00
parent d26fae9875
commit 91ce7807b9
8 changed files with 12 additions and 196 deletions

View File

@@ -2817,9 +2817,6 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\resource\impl\Kind.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\resource\impl\LegacyFees.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\resource\impl\Logic.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\resource\impl\Manager.cpp">
@@ -2830,8 +2827,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\resource\impl\Tuning.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\resource\LegacyFees.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\resource\Manager.h">
</ClInclude>
<None Include="..\..\src\ripple\resource\README.md">

View File

@@ -3900,9 +3900,6 @@
<ClInclude Include="..\..\src\ripple\resource\impl\Kind.h">
<Filter>ripple\resource\impl</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\resource\impl\LegacyFees.cpp">
<Filter>ripple\resource\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\resource\impl\Logic.h">
<Filter>ripple\resource\impl</Filter>
</ClInclude>
@@ -3915,9 +3912,6 @@
<ClInclude Include="..\..\src\ripple\resource\impl\Tuning.h">
<Filter>ripple\resource\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\resource\LegacyFees.h">
<Filter>ripple\resource</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\resource\Manager.h">
<Filter>ripple\resource</Filter>
</ClInclude>

View File

@@ -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)

View File

@@ -19,7 +19,7 @@
#include <ripple/basics/UptimeTimer.h>
#include <ripple/core/LoadFeeTrack.h>
#include <ripple/resource/LegacyFees.h>
#include <beast/cxx14/memory.h> // <memory>
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 <Cost> 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,6 +159,7 @@ public:
// Another option is using an observer pattern to invert the dependency.
if (getApp().getJobQueue ().isOverloaded ())
{
if (m_journal.info)
m_journal.info << getApp().getJobQueue ().getJson (0);
change = getApp().getFeeTrack ().raiseLocalFee ();
}
@@ -249,9 +201,10 @@ LoadManager::LoadManager (Stoppable& parent)
//------------------------------------------------------------------------------
LoadManager* LoadManager::New (Stoppable& parent, beast::Journal journal)
std::unique_ptr<LoadManager>
make_LoadManager (beast::Stoppable& parent, beast::Journal journal)
{
return new LoadManagerImp (parent, journal);
return std::make_unique <LoadManagerImp> (parent, journal);
}
} // ripple

View File

@@ -21,6 +21,7 @@
#define RIPPLE_LOADMANAGER_H_INCLUDED
#include <beast/threads/Stoppable.h>
#include <beast/cxx14/memory.h> // <memory>
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<LoadManager>
make_LoadManager (beast::Stoppable& parent, beast::Journal journal);
} // ripple
#endif

View File

@@ -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 <ripple/resource/Charge.h>
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

View File

@@ -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 <ripple/resource/LegacyFees.h>
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;
};
}
}

View File

@@ -28,7 +28,6 @@
#include <ripple/resource/impl/Fees.cpp>
#include <ripple/resource/impl/Key.h>
#include <ripple/resource/impl/Kind.h>
#include <ripple/resource/impl/LegacyFees.cpp>
#include <ripple/resource/impl/Manager.cpp>
#include <ripple/resource/impl/Tests.cpp>
#include <ripple/resource/impl/Tuning.h>