mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Refactor Ledger:
* Consolidate constructors * Use pointer/size instead of Serializer * Factor out PendingSaves * Make some members free functions * Reduce size of constructor initializer lists
This commit is contained in:
@@ -1468,6 +1468,12 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\ripple\app\ledger\DirectoryEntryIterator.h">
|
<ClInclude Include="..\..\src\ripple\app\ledger\DirectoryEntryIterator.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClCompile Include="..\..\src\ripple\app\ledger\impl\LedgerFees.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
|
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\ripple\app\ledger\InboundLedger.cpp">
|
<ClCompile Include="..\..\src\ripple\app\ledger\InboundLedger.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
@@ -1508,6 +1514,8 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerEntrySet.h">
|
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerEntrySet.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerFees.h">
|
||||||
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\ripple\app\ledger\LedgerHistory.cpp">
|
<ClCompile Include="..\..\src\ripple\app\ledger\LedgerHistory.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
@@ -1560,6 +1568,8 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\ripple\app\ledger\OrderBookIterator.h">
|
<ClInclude Include="..\..\src\ripple\app\ledger\OrderBookIterator.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\app\ledger\PendingSaves.h">
|
||||||
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\ripple\app\ledger\tests\DeferredCredits.test.cpp">
|
<ClCompile Include="..\..\src\ripple\app\ledger\tests\DeferredCredits.test.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||||
|
|||||||
@@ -262,6 +262,9 @@
|
|||||||
<Filter Include="ripple\app\ledger">
|
<Filter Include="ripple\app\ledger">
|
||||||
<UniqueIdentifier>{CE126498-A44D-30A2-345B-0F672BCDF947}</UniqueIdentifier>
|
<UniqueIdentifier>{CE126498-A44D-30A2-345B-0F672BCDF947}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="ripple\app\ledger\impl">
|
||||||
|
<UniqueIdentifier>{0EF1A571-94CC-4D70-E004-48579DF8AF2B}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
<Filter Include="ripple\app\ledger\tests">
|
<Filter Include="ripple\app\ledger\tests">
|
||||||
<UniqueIdentifier>{55A76B5B-A18E-E655-1A07-9492C6F8F356}</UniqueIdentifier>
|
<UniqueIdentifier>{55A76B5B-A18E-E655-1A07-9492C6F8F356}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -2169,6 +2172,9 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\app\ledger\DirectoryEntryIterator.h">
|
<ClInclude Include="..\..\src\ripple\app\ledger\DirectoryEntryIterator.h">
|
||||||
<Filter>ripple\app\ledger</Filter>
|
<Filter>ripple\app\ledger</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClCompile Include="..\..\src\ripple\app\ledger\impl\LedgerFees.cpp">
|
||||||
|
<Filter>ripple\app\ledger\impl</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\ripple\app\ledger\InboundLedger.cpp">
|
<ClCompile Include="..\..\src\ripple\app\ledger\InboundLedger.cpp">
|
||||||
<Filter>ripple\app\ledger</Filter>
|
<Filter>ripple\app\ledger</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -2199,6 +2205,9 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerEntrySet.h">
|
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerEntrySet.h">
|
||||||
<Filter>ripple\app\ledger</Filter>
|
<Filter>ripple\app\ledger</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerFees.h">
|
||||||
|
<Filter>ripple\app\ledger</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\ripple\app\ledger\LedgerHistory.cpp">
|
<ClCompile Include="..\..\src\ripple\app\ledger\LedgerHistory.cpp">
|
||||||
<Filter>ripple\app\ledger</Filter>
|
<Filter>ripple\app\ledger</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -2241,6 +2250,9 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\app\ledger\OrderBookIterator.h">
|
<ClInclude Include="..\..\src\ripple\app\ledger\OrderBookIterator.h">
|
||||||
<Filter>ripple\app\ledger</Filter>
|
<Filter>ripple\app\ledger</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\app\ledger\PendingSaves.h">
|
||||||
|
<Filter>ripple\app\ledger</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\ripple\app\ledger\tests\DeferredCredits.test.cpp">
|
<ClCompile Include="..\..\src\ripple\app\ledger\tests\DeferredCredits.test.cpp">
|
||||||
<Filter>ripple\app\ledger\tests</Filter>
|
<Filter>ripple\app\ledger\tests</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -161,14 +161,15 @@ bool InboundLedger::tryLocal ()
|
|||||||
|
|
||||||
if (m_journal.trace) m_journal.trace <<
|
if (m_journal.trace) m_journal.trace <<
|
||||||
"Ledger header found in fetch pack";
|
"Ledger header found in fetch pack";
|
||||||
mLedger = std::make_shared<Ledger> (data, true);
|
mLedger = std::make_shared<Ledger> (
|
||||||
|
data.data(), data.size(), true);
|
||||||
getApp().getNodeStore ().store (
|
getApp().getNodeStore ().store (
|
||||||
hotLEDGER, std::move (data), mHash);
|
hotLEDGER, std::move (data), mHash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLedger = std::make_shared<Ledger> (
|
mLedger = std::make_shared<Ledger>(
|
||||||
strCopy (node->getData ()), true);
|
node->getData().data(), node->getData().size(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLedger->getHash () != mHash)
|
if (mLedger->getHash () != mHash)
|
||||||
@@ -761,7 +762,8 @@ bool InboundLedger::takeHeader (std::string const& data)
|
|||||||
if (mComplete || mFailed || mHaveHeader)
|
if (mComplete || mFailed || mHaveHeader)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
mLedger = std::make_shared<Ledger> (data, false);
|
mLedger = std::make_shared<Ledger>(
|
||||||
|
data.data(), data.size(), false);
|
||||||
|
|
||||||
if (mLedger->getHash () != mHash)
|
if (mLedger->getHash () != mHash)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <ripple/app/ledger/LedgerTiming.h>
|
#include <ripple/app/ledger/LedgerTiming.h>
|
||||||
#include <ripple/app/ledger/LedgerToJson.h>
|
#include <ripple/app/ledger/LedgerToJson.h>
|
||||||
#include <ripple/app/ledger/OrderBookDB.h>
|
#include <ripple/app/ledger/OrderBookDB.h>
|
||||||
|
#include <ripple/app/ledger/PendingSaves.h>
|
||||||
#include <ripple/app/data/DatabaseCon.h>
|
#include <ripple/app/data/DatabaseCon.h>
|
||||||
#include <ripple/app/data/SociDB.h>
|
#include <ripple/app/data/SociDB.h>
|
||||||
#include <ripple/app/main/Application.h>
|
#include <ripple/app/main/Application.h>
|
||||||
@@ -55,10 +56,6 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount)
|
|||||||
, mParentCloseTime (0)
|
, mParentCloseTime (0)
|
||||||
, mCloseResolution (ledgerDefaultTimeResolution)
|
, mCloseResolution (ledgerDefaultTimeResolution)
|
||||||
, mCloseFlags (0)
|
, mCloseFlags (0)
|
||||||
, mClosed (false)
|
|
||||||
, mValidated (false)
|
|
||||||
, mValidHash (false)
|
|
||||||
, mAccepted (false)
|
|
||||||
, mImmutable (false)
|
, mImmutable (false)
|
||||||
, mTransactionMap (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
, mTransactionMap (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||||
@@ -77,8 +74,6 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount)
|
|||||||
writeBack (lepCREATE, startAccount->getSLE ());
|
writeBack (lepCREATE, startAccount->getSLE ());
|
||||||
|
|
||||||
mAccountStateMap->flushDirty (hotACCOUNT_NODE, mLedgerSeq);
|
mAccountStateMap->flushDirty (hotACCOUNT_NODE, mLedgerSeq);
|
||||||
|
|
||||||
initializeFees ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ledger::Ledger (uint256 const& parentHash,
|
Ledger::Ledger (uint256 const& parentHash,
|
||||||
@@ -100,10 +95,6 @@ Ledger::Ledger (uint256 const& parentHash,
|
|||||||
, mParentCloseTime (parentCloseTime)
|
, mParentCloseTime (parentCloseTime)
|
||||||
, mCloseResolution (closeResolution)
|
, mCloseResolution (closeResolution)
|
||||||
, mCloseFlags (closeFlags)
|
, mCloseFlags (closeFlags)
|
||||||
, mClosed (false)
|
|
||||||
, mValidated (false)
|
|
||||||
, mValidHash (false)
|
|
||||||
, mAccepted (false)
|
|
||||||
, mImmutable (true)
|
, mImmutable (true)
|
||||||
, mTransactionMap (std::make_shared <SHAMap> (
|
, mTransactionMap (std::make_shared <SHAMap> (
|
||||||
SHAMapType::TRANSACTION, transHash, getApp().family(),
|
SHAMapType::TRANSACTION, transHash, getApp().family(),
|
||||||
@@ -130,8 +121,6 @@ Ledger::Ledger (uint256 const& parentHash,
|
|||||||
|
|
||||||
mTransactionMap->setImmutable ();
|
mTransactionMap->setImmutable ();
|
||||||
mAccountStateMap->setImmutable ();
|
mAccountStateMap->setImmutable ();
|
||||||
|
|
||||||
initializeFees ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new ledger that's a snapshot of this one
|
// Create a new ledger that's a snapshot of this one
|
||||||
@@ -146,14 +135,12 @@ Ledger::Ledger (Ledger& ledger,
|
|||||||
, mCloseFlags (ledger.mCloseFlags)
|
, mCloseFlags (ledger.mCloseFlags)
|
||||||
, mClosed (ledger.mClosed)
|
, mClosed (ledger.mClosed)
|
||||||
, mValidated (ledger.mValidated)
|
, mValidated (ledger.mValidated)
|
||||||
, mValidHash (false)
|
|
||||||
, mAccepted (ledger.mAccepted)
|
, mAccepted (ledger.mAccepted)
|
||||||
, mImmutable (!isMutable)
|
, mImmutable (!isMutable)
|
||||||
, mTransactionMap (ledger.mTransactionMap->snapShot (isMutable))
|
, mTransactionMap (ledger.mTransactionMap->snapShot (isMutable))
|
||||||
, mAccountStateMap (ledger.mAccountStateMap->snapShot (isMutable))
|
, mAccountStateMap (ledger.mAccountStateMap->snapShot (isMutable))
|
||||||
{
|
{
|
||||||
updateHash ();
|
updateHash ();
|
||||||
initializeFees ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new ledger that follows this one
|
// Create a new ledger that follows this one
|
||||||
@@ -164,10 +151,6 @@ Ledger::Ledger (bool /* dummy */,
|
|||||||
, mParentCloseTime (prevLedger.mCloseTime)
|
, mParentCloseTime (prevLedger.mCloseTime)
|
||||||
, mCloseResolution (prevLedger.mCloseResolution)
|
, mCloseResolution (prevLedger.mCloseResolution)
|
||||||
, mCloseFlags (0)
|
, mCloseFlags (0)
|
||||||
, mClosed (false)
|
|
||||||
, mValidated (false)
|
|
||||||
, mValidHash (false)
|
|
||||||
, mAccepted (false)
|
|
||||||
, mImmutable (false)
|
, mImmutable (false)
|
||||||
, mTransactionMap (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
, mTransactionMap (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||||
@@ -191,60 +174,34 @@ Ledger::Ledger (bool /* dummy */,
|
|||||||
{
|
{
|
||||||
mCloseTime = prevLedger.mCloseTime + mCloseResolution;
|
mCloseTime = prevLedger.mCloseTime + mCloseResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeFees ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ledger::Ledger (Blob const& rawLedger,
|
Ledger::Ledger (void const* data,
|
||||||
bool hasPrefix)
|
std::size_t size, bool hasPrefix)
|
||||||
: mClosed (false)
|
: mImmutable (true)
|
||||||
, mValidated (false)
|
|
||||||
, mValidHash (false)
|
|
||||||
, mAccepted (false)
|
|
||||||
, mImmutable (true)
|
|
||||||
{
|
{
|
||||||
Serializer s (rawLedger);
|
SerialIter sit (data, size);
|
||||||
|
setRaw (sit, hasPrefix);
|
||||||
setRaw (s, hasPrefix);
|
|
||||||
|
|
||||||
initializeFees ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
|
||||||
: mTotCoins (0),
|
: mTotCoins (0)
|
||||||
mLedgerSeq (ledgerSeq),
|
, mLedgerSeq (ledgerSeq)
|
||||||
mCloseTime (closeTime),
|
, mCloseTime (closeTime)
|
||||||
mParentCloseTime (0),
|
, mParentCloseTime (0)
|
||||||
mCloseResolution (ledgerDefaultTimeResolution),
|
, mCloseResolution (ledgerDefaultTimeResolution)
|
||||||
mCloseFlags (0),
|
, mCloseFlags (0)
|
||||||
mClosed (false),
|
, mImmutable (false)
|
||||||
mValidated (false),
|
, mTransactionMap (std::make_shared <SHAMap> (
|
||||||
mValidHash (false),
|
|
||||||
mAccepted (false),
|
|
||||||
mImmutable (false),
|
|
||||||
mTransactionMap (std::make_shared <SHAMap> (
|
|
||||||
SHAMapType::TRANSACTION, getApp().family(),
|
SHAMapType::TRANSACTION, getApp().family(),
|
||||||
deprecatedLogs().journal("SHAMap"))),
|
deprecatedLogs().journal("SHAMap")))
|
||||||
mAccountStateMap (std::make_shared <SHAMap> (
|
, mAccountStateMap (std::make_shared <SHAMap> (
|
||||||
SHAMapType::STATE, getApp().family(),
|
SHAMapType::STATE, getApp().family(),
|
||||||
deprecatedLogs().journal("SHAMap")))
|
deprecatedLogs().journal("SHAMap")))
|
||||||
{
|
{
|
||||||
initializeFees ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
Ledger::~Ledger ()
|
Ledger::~Ledger ()
|
||||||
{
|
{
|
||||||
@@ -296,10 +253,8 @@ void Ledger::updateHash ()
|
|||||||
mValidHash = true;
|
mValidHash = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ledger::setRaw (Serializer& s, bool hasPrefix)
|
void Ledger::setRaw (SerialIter& sit, bool hasPrefix)
|
||||||
{
|
{
|
||||||
SerialIter sit (s);
|
|
||||||
|
|
||||||
if (hasPrefix)
|
if (hasPrefix)
|
||||||
sit.get32 ();
|
sit.get32 ();
|
||||||
|
|
||||||
@@ -660,12 +615,9 @@ bool Ledger::saveValidatedLedger (bool current)
|
|||||||
{
|
{
|
||||||
WriteLog (lsWARNING, Ledger) << "An accepted ledger was missing nodes";
|
WriteLog (lsWARNING, Ledger) << "An accepted ledger was missing nodes";
|
||||||
getApp().getLedgerMaster().failedSave(mLedgerSeq, mHash);
|
getApp().getLedgerMaster().failedSave(mLedgerSeq, mHash);
|
||||||
{
|
// Clients can now trust the database for information about this
|
||||||
// Clients can now trust the database for information about this
|
// ledger sequence.
|
||||||
// ledger sequence.
|
getApp().pendingSaves().erase(getLedgerSeq());
|
||||||
StaticScopedLockType sl (sPendingSaveLock);
|
|
||||||
sPendingSaves.erase(getLedgerSeq());
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,12 +712,9 @@ bool Ledger::saveValidatedLedger (bool current)
|
|||||||
to_string (mAccountHash) % to_string (mTransHash));
|
to_string (mAccountHash) % to_string (mTransHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// Clients can now trust the database for
|
||||||
// Clients can now trust the database for information about this ledger
|
// information about this ledger sequence.
|
||||||
// sequence.
|
getApp().pendingSaves().erase(getLedgerSeq());
|
||||||
StaticScopedLockType sl (sPendingSaveLock);
|
|
||||||
sPendingSaves.erase(getLedgerSeq());
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1666,14 +1615,11 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent)
|
|||||||
|
|
||||||
assert (isImmutable ());
|
assert (isImmutable ());
|
||||||
|
|
||||||
|
if (!getApp().pendingSaves().insert(getLedgerSeq()))
|
||||||
{
|
{
|
||||||
StaticScopedLockType sl (sPendingSaveLock);
|
WriteLog (lsDEBUG, Ledger)
|
||||||
if (!sPendingSaves.insert(getLedgerSeq()).second)
|
<< "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)
|
if (isSynchronous)
|
||||||
@@ -1696,12 +1642,6 @@ bool Ledger::pendSaveValidated (bool isSynchronous, bool isCurrent)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::uint32_t> Ledger::getPendingSaves()
|
|
||||||
{
|
|
||||||
StaticScopedLockType sl (sPendingSaveLock);
|
|
||||||
return sPendingSaves;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Ledger::ownerDirDescriber (SLE::ref sle, bool, Account const& owner)
|
void Ledger::ownerDirDescriber (SLE::ref sle, bool, Account const& owner)
|
||||||
{
|
{
|
||||||
sle->setFieldAccount (sfOwner, owner);
|
sle->setFieldAccount (sfOwner, owner);
|
||||||
@@ -1726,15 +1666,7 @@ void Ledger::qualityDirDescriber (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ledger::initializeFees ()
|
void Ledger::deprecatedUpdateCachedFees() const
|
||||||
{
|
|
||||||
mBaseFee = 0;
|
|
||||||
mReferenceFeeUnits = 0;
|
|
||||||
mReserveBase = 0;
|
|
||||||
mReserveIncrement = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Ledger::updateFees ()
|
|
||||||
{
|
{
|
||||||
if (mBaseFee)
|
if (mBaseFee)
|
||||||
return;
|
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)
|
if (mBaseFee == 0)
|
||||||
{
|
{
|
||||||
mBaseFee = baseFee;
|
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<uint256> Ledger::getNeededTransactionHashes (
|
std::vector<uint256> Ledger::getNeededTransactionHashes (
|
||||||
int max, SHAMapSyncFilter* filter) const
|
int max, SHAMapSyncFilter* filter) const
|
||||||
{
|
{
|
||||||
@@ -1820,7 +1739,4 @@ std::vector<uint256> Ledger::getNeededAccountStateHashes (
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ledger::StaticLockType Ledger::sPendingSaveLock;
|
|
||||||
std::set<std::uint32_t> Ledger::sPendingSaves;
|
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include <ripple/basics/CountedObject.h>
|
#include <ripple/basics/CountedObject.h>
|
||||||
#include <ripple/protocol/Serializer.h>
|
#include <ripple/protocol/Serializer.h>
|
||||||
#include <ripple/protocol/Book.h>
|
#include <ripple/protocol/Book.h>
|
||||||
#include <set>
|
#include <mutex>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
@@ -119,6 +119,7 @@ public:
|
|||||||
// used for the starting bootstrap ledger
|
// used for the starting bootstrap ledger
|
||||||
Ledger (const RippleAddress & masterID, std::uint64_t startAmount);
|
Ledger (const RippleAddress & masterID, std::uint64_t startAmount);
|
||||||
|
|
||||||
|
// Used for ledgers loaded from JSON files
|
||||||
Ledger (uint256 const& parentHash, uint256 const& transHash,
|
Ledger (uint256 const& parentHash, uint256 const& transHash,
|
||||||
uint256 const& accountHash,
|
uint256 const& accountHash,
|
||||||
std::uint64_t totCoins, std::uint32_t closeTime,
|
std::uint64_t totCoins, std::uint32_t closeTime,
|
||||||
@@ -127,8 +128,8 @@ public:
|
|||||||
// used for database ledgers
|
// used for database ledgers
|
||||||
|
|
||||||
Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime);
|
Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime);
|
||||||
Ledger (Blob const & rawLedger, bool hasPrefix);
|
Ledger (void const* data,
|
||||||
Ledger (std::string const& rawLedger, bool hasPrefix);
|
std::size_t size, bool hasPrefix);
|
||||||
Ledger (bool dummy, Ledger & previous); // ledger after this one
|
Ledger (bool dummy, Ledger & previous); // ledger after this one
|
||||||
Ledger (Ledger & target, bool isMutable); // snapshot
|
Ledger (Ledger & target, bool isMutable); // snapshot
|
||||||
|
|
||||||
@@ -182,8 +183,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ledger signature operations
|
// ledger signature operations
|
||||||
void addRaw (Serializer & s) const;
|
void addRaw (Serializer& s) const;
|
||||||
void setRaw (Serializer & s, bool hasPrefix);
|
void setRaw (SerialIter& sit, bool hasPrefix);
|
||||||
|
|
||||||
uint256 const& getHash ();
|
uint256 const& getHash ();
|
||||||
uint256 const& getParentHash () const
|
uint256 const& getParentHash () const
|
||||||
@@ -380,39 +381,34 @@ public:
|
|||||||
getRippleState (
|
getRippleState (
|
||||||
Account const& a, Account const& b, Currency const& currency) const;
|
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
|
// Returns the cost of the reference transaction in fee units
|
||||||
updateFees ();
|
deprecatedUpdateCachedFees ();
|
||||||
return mReferenceFeeUnits;
|
return mReferenceFeeUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t getBaseFee ()
|
std::uint64_t getBaseFee() const
|
||||||
{
|
{
|
||||||
// Returns the cost of the reference transaction in drops
|
// Returns the cost of the reference transaction in drops
|
||||||
updateFees ();
|
deprecatedUpdateCachedFees ();
|
||||||
return mBaseFee;
|
return mBaseFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t getReserve (int increments)
|
std::uint64_t getReserve (int increments) const
|
||||||
{
|
{
|
||||||
// Returns the required reserve in drops
|
// Returns the required reserve in drops
|
||||||
updateFees ();
|
deprecatedUpdateCachedFees ();
|
||||||
return static_cast<std::uint64_t> (increments) * mReserveIncrement
|
return static_cast<std::uint64_t> (increments) * mReserveIncrement
|
||||||
+ mReserveBase;
|
+ mReserveBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t getReserveInc ()
|
std::uint64_t getReserveInc () const
|
||||||
{
|
{
|
||||||
updateFees ();
|
deprecatedUpdateCachedFees ();
|
||||||
return mReserveIncrement;
|
return mReserveIncrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t scaleFeeBase (std::uint64_t fee);
|
|
||||||
std::uint64_t scaleFeeLoad (std::uint64_t fee, bool bAdmin);
|
|
||||||
|
|
||||||
static std::set<std::uint32_t> getPendingSaves();
|
|
||||||
|
|
||||||
/** Const version of getHash() which gets the current value without calling
|
/** Const version of getHash() which gets the current value without calling
|
||||||
updateHash(). */
|
updateHash(). */
|
||||||
uint256 const& getRawHash () const
|
uint256 const& getRawHash () const
|
||||||
@@ -437,11 +433,15 @@ protected:
|
|||||||
bool saveValidatedLedger (bool current);
|
bool saveValidatedLedger (bool current);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeFees ();
|
// Updates the fees cached in the ledger.
|
||||||
void updateFees ();
|
// 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
|
// The basic Ledger structure, can be opened, closed, or synching
|
||||||
uint256 mHash;
|
uint256 mHash; // VFALCO This could be boost::optional<uint256>
|
||||||
uint256 mParentHash;
|
uint256 mParentHash;
|
||||||
uint256 mTransHash;
|
uint256 mTransHash;
|
||||||
uint256 mAccountHash;
|
uint256 mAccountHash;
|
||||||
@@ -459,28 +459,28 @@ private:
|
|||||||
|
|
||||||
// flags indicating how this ledger close took place
|
// flags indicating how this ledger close took place
|
||||||
std::uint32_t mCloseFlags;
|
std::uint32_t mCloseFlags;
|
||||||
bool mClosed, mValidated, mValidHash, mAccepted, mImmutable;
|
bool mClosed = false;
|
||||||
|
bool mValidated = false;
|
||||||
// Fee units for the reference transaction
|
bool mValidHash = false;
|
||||||
std::uint32_t mReferenceFeeUnits;
|
bool mAccepted = false;
|
||||||
|
bool mImmutable;
|
||||||
// Reserve basse and increment in fee units
|
|
||||||
std::uint32_t mReserveBase, mReserveIncrement;
|
|
||||||
|
|
||||||
// Ripple cost of the reference transaction
|
|
||||||
std::uint64_t mBaseFee;
|
|
||||||
|
|
||||||
std::shared_ptr<SHAMap> mTransactionMap;
|
std::shared_ptr<SHAMap> mTransactionMap;
|
||||||
std::shared_ptr<SHAMap> mAccountStateMap;
|
std::shared_ptr<SHAMap> mAccountStateMap;
|
||||||
|
|
||||||
typedef RippleMutex StaticLockType;
|
// Protects fee variables
|
||||||
typedef std::lock_guard <StaticLockType> StaticScopedLockType;
|
std::mutex mutable mutex_;
|
||||||
|
|
||||||
// Ledgers not fully saved, validated ledger present but DB may not be
|
// Ripple cost of the reference transaction
|
||||||
// correct yet.
|
std::uint64_t mutable mBaseFee = 0;
|
||||||
static StaticLockType sPendingSaveLock;
|
|
||||||
|
|
||||||
static std::set<std::uint32_t> 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| (
|
inline LedgerStateParms operator| (
|
||||||
|
|||||||
40
src/ripple/app/ledger/LedgerFees.h
Normal file
40
src/ripple/app/ledger/LedgerFees.h
Normal file
@@ -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 <ripple/app/ledger/Ledger.h>
|
||||||
|
#include <ripple/core/LoadFeeTrack.h>
|
||||||
|
|
||||||
|
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
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <ripple/app/ledger/LedgerHistory.h>
|
#include <ripple/app/ledger/LedgerHistory.h>
|
||||||
#include <ripple/app/ledger/LedgerHolder.h>
|
#include <ripple/app/ledger/LedgerHolder.h>
|
||||||
#include <ripple/app/ledger/OrderBookDB.h>
|
#include <ripple/app/ledger/OrderBookDB.h>
|
||||||
|
#include <ripple/app/ledger/PendingSaves.h>
|
||||||
#include <ripple/app/main/Application.h>
|
#include <ripple/app/main/Application.h>
|
||||||
#include <ripple/app/misc/IHashRouter.h>
|
#include <ripple/app/misc/IHashRouter.h>
|
||||||
#include <ripple/app/misc/NetworkOPs.h>
|
#include <ripple/app/misc/NetworkOPs.h>
|
||||||
@@ -480,20 +481,21 @@ public:
|
|||||||
// Remove from the validated range any ledger sequences that may not be
|
// Remove from the validated range any ledger sequences that may not be
|
||||||
// fully updated in the database yet
|
// fully updated in the database yet
|
||||||
|
|
||||||
std::set<std::uint32_t> 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
|
// 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
|
// 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.
|
// because then we'll have nothing when we could have 7.
|
||||||
while (sPendingSaves.count(maxVal) > 0)
|
while (pendingSaves.count(maxVal) > 0)
|
||||||
--maxVal;
|
--maxVal;
|
||||||
while (sPendingSaves.count(minVal) > 0)
|
while (pendingSaves.count(minVal) > 0)
|
||||||
++minVal;
|
++minVal;
|
||||||
|
|
||||||
// Best effort for remaining exclusions
|
// Best effort for remaining exclusions
|
||||||
for(auto v : sPendingSaves)
|
for(auto v : pendingSaves)
|
||||||
{
|
{
|
||||||
if ((v >= minVal) && (v <= maxVal))
|
if ((v >= minVal) && (v <= maxVal))
|
||||||
{
|
{
|
||||||
|
|||||||
86
src/ripple/app/ledger/PendingSaves.h
Normal file
86
src/ripple/app/ledger/PendingSaves.h
Normal file
@@ -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 <ripple/protocol/Protocol.h>
|
||||||
|
#include <boost/container/flat_set.hpp>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
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<LedgerIndex> 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
|
||||||
42
src/ripple/app/ledger/impl/LedgerFees.cpp
Normal file
42
src/ripple/app/ledger/impl/LedgerFees.cpp
Normal file
@@ -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 <BeastConfig.h>
|
||||||
|
#include <ripple/app/ledger/LedgerFees.h>
|
||||||
|
|
||||||
|
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
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <ripple/app/ledger/InboundLedgers.h>
|
#include <ripple/app/ledger/InboundLedgers.h>
|
||||||
#include <ripple/app/ledger/LedgerMaster.h>
|
#include <ripple/app/ledger/LedgerMaster.h>
|
||||||
#include <ripple/app/ledger/OrderBookDB.h>
|
#include <ripple/app/ledger/OrderBookDB.h>
|
||||||
|
#include <ripple/app/ledger/PendingSaves.h>
|
||||||
#include <ripple/app/main/CollectorManager.h>
|
#include <ripple/app/main/CollectorManager.h>
|
||||||
#include <ripple/app/main/LoadManager.h>
|
#include <ripple/app/main/LoadManager.h>
|
||||||
#include <ripple/app/main/LocalCredentials.h>
|
#include <ripple/app/main/LocalCredentials.h>
|
||||||
@@ -257,6 +258,7 @@ public:
|
|||||||
NodeStoreScheduler m_nodeStoreScheduler;
|
NodeStoreScheduler m_nodeStoreScheduler;
|
||||||
std::unique_ptr <SHAMapStore> m_shaMapStore;
|
std::unique_ptr <SHAMapStore> m_shaMapStore;
|
||||||
std::unique_ptr <NodeStore::Database> m_nodeStore;
|
std::unique_ptr <NodeStore::Database> m_nodeStore;
|
||||||
|
PendingSaves pendingSaves_;
|
||||||
|
|
||||||
// These are not Stoppable-derived
|
// These are not Stoppable-derived
|
||||||
NodeCache m_tempNodeCache;
|
NodeCache m_tempNodeCache;
|
||||||
@@ -591,6 +593,11 @@ public:
|
|||||||
return *m_shaMapStore;
|
return *m_shaMapStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PendingSaves& pendingSaves() override
|
||||||
|
{
|
||||||
|
return pendingSaves_;
|
||||||
|
}
|
||||||
|
|
||||||
Overlay& overlay ()
|
Overlay& overlay ()
|
||||||
{
|
{
|
||||||
return *m_overlay;
|
return *m_overlay;
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class NetworkOPs;
|
|||||||
class OrderBookDB;
|
class OrderBookDB;
|
||||||
class Overlay;
|
class Overlay;
|
||||||
class PathRequests;
|
class PathRequests;
|
||||||
|
class PendingSaves;
|
||||||
class STLedgerEntry;
|
class STLedgerEntry;
|
||||||
class TransactionMaster;
|
class TransactionMaster;
|
||||||
class Validations;
|
class Validations;
|
||||||
@@ -114,7 +115,7 @@ public:
|
|||||||
virtual Resource::Manager& getResourceManager () = 0;
|
virtual Resource::Manager& getResourceManager () = 0;
|
||||||
virtual PathRequests& getPathRequests () = 0;
|
virtual PathRequests& getPathRequests () = 0;
|
||||||
virtual SHAMapStore& getSHAMapStore () = 0;
|
virtual SHAMapStore& getSHAMapStore () = 0;
|
||||||
|
virtual PendingSaves& pendingSaves() = 0;
|
||||||
virtual DatabaseCon& getTxnDB () = 0;
|
virtual DatabaseCon& getTxnDB () = 0;
|
||||||
virtual DatabaseCon& getLedgerDB () = 0;
|
virtual DatabaseCon& getLedgerDB () = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include <ripple/app/paths/RippleLineCache.h>
|
#include <ripple/app/paths/RippleLineCache.h>
|
||||||
#include <ripple/json/json_value.h>
|
#include <ripple/json/json_value.h>
|
||||||
#include <ripple/net/InfoSub.h>
|
#include <ripple/net/InfoSub.h>
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/app/ledger/LedgerFees.h>
|
||||||
|
#include <ripple/app/main/Application.h>
|
||||||
#include <ripple/app/tx/impl/Transactor.h>
|
#include <ripple/app/tx/impl/Transactor.h>
|
||||||
#include <ripple/app/tx/impl/SignerEntries.h>
|
#include <ripple/app/tx/impl/SignerEntries.h>
|
||||||
#include <ripple/core/Config.h>
|
#include <ripple/core/Config.h>
|
||||||
@@ -100,8 +102,8 @@ Transactor::Transactor (
|
|||||||
|
|
||||||
void Transactor::calculateFee ()
|
void Transactor::calculateFee ()
|
||||||
{
|
{
|
||||||
mFeeDue = STAmount (mEngine->getLedger ()->scaleFeeLoad (
|
mFeeDue = STAmount (scaleFeeLoad (getApp().getFeeTrack(),
|
||||||
calculateBaseFee (), mParams & tapADMIN));
|
*mEngine->getLedger(), calculateBaseFee (), mParams & tapADMIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t Transactor::calculateBaseFee ()
|
std::uint64_t Transactor::calculateBaseFee ()
|
||||||
|
|||||||
@@ -59,18 +59,18 @@ public:
|
|||||||
|
|
||||||
/** A ledger index. */
|
/** A ledger index. */
|
||||||
// VFALCO TODO pick one. I like Index since its not an abbreviation
|
// 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
|
// VFALCO NOTE "LedgerSeq" appears in some SQL statement text
|
||||||
typedef std::uint32_t LedgerSeq;
|
using LedgerSeq = std::uint32_t;
|
||||||
|
|
||||||
/** A transaction identifier.
|
/** A transaction identifier.
|
||||||
|
The value is computed as the hash of the
|
||||||
|
canonicalized, serialized transaction object.
|
||||||
*/
|
*/
|
||||||
// VFALCO TODO maybe rename to TxHash
|
using TxID = uint256;
|
||||||
typedef uint256 TxID;
|
|
||||||
|
|
||||||
/** A transaction index.
|
/** A transaction index. */
|
||||||
*/
|
using TxSeq = std::uint32_t;
|
||||||
typedef std::uint32_t TxSeq; // VFALCO NOTE Should read TxIndex or TxNum
|
|
||||||
|
|
||||||
} // ripple
|
} // ripple
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/rpc/impl/Tuning.h>
|
#include <ripple/rpc/impl/Tuning.h>
|
||||||
|
#include <ripple/app/ledger/LedgerFees.h>
|
||||||
#include <ripple/app/paths/RippleState.h>
|
#include <ripple/app/paths/RippleState.h>
|
||||||
#include <ripple/protocol/TxFlags.h>
|
#include <ripple/protocol/TxFlags.h>
|
||||||
|
|
||||||
@@ -32,7 +33,8 @@ static void fillTransaction (
|
|||||||
{
|
{
|
||||||
txArray["Sequence"] = Json::UInt (sequence++);
|
txArray["Sequence"] = Json::UInt (sequence++);
|
||||||
txArray["Account"] = account.humanAccountID ();
|
txArray["Account"] = account.humanAccountID ();
|
||||||
txArray["Fee"] = Json::UInt (ledger->scaleFeeLoad (10, false));
|
txArray["Fee"] = Json::UInt (scaleFeeLoad (
|
||||||
|
getApp().getFeeTrack(), *ledger, 10, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/app/ledger/LedgerFees.h>
|
||||||
#include <ripple/rpc/impl/TransactionSign.h>
|
#include <ripple/rpc/impl/TransactionSign.h>
|
||||||
#include <ripple/rpc/impl/KeypairForSignature.h>
|
#include <ripple/rpc/impl/KeypairForSignature.h>
|
||||||
#include <ripple/app/paths/FindPaths.h>
|
#include <ripple/app/paths/FindPaths.h>
|
||||||
@@ -172,7 +173,8 @@ std::uint64_t TxnSignApiFacade::scaleFeeBase (std::uint64_t fee) const
|
|||||||
if (!ledger_) // Unit testing.
|
if (!ledger_) // Unit testing.
|
||||||
return fee;
|
return fee;
|
||||||
|
|
||||||
return ledger_->scaleFeeBase (fee);
|
return ripple::scaleFeeBase(
|
||||||
|
getApp().getFeeTrack(), *ledger_, fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t
|
std::uint64_t
|
||||||
@@ -181,7 +183,9 @@ TxnSignApiFacade::scaleFeeLoad (std::uint64_t fee, bool bAdmin) const
|
|||||||
if (!ledger_) // Unit testing.
|
if (!ledger_) // Unit testing.
|
||||||
return fee;
|
return fee;
|
||||||
|
|
||||||
return ledger_->scaleFeeLoad (fee, bAdmin);
|
return ripple::scaleFeeLoad (
|
||||||
|
getApp().getFeeTrack(),
|
||||||
|
*ledger_, fee, bAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TxnSignApiFacade::hasAccountRoot () const
|
bool TxnSignApiFacade::hasAccountRoot () const
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
|
||||||
#include <ripple/app/ledger/Ledger.cpp>
|
#include <ripple/app/ledger/Ledger.cpp>
|
||||||
|
#include <ripple/app/ledger/impl/LedgerFees.cpp>
|
||||||
#include <ripple/app/misc/AccountState.cpp>
|
#include <ripple/app/misc/AccountState.cpp>
|
||||||
|
|
||||||
#include <ripple/app/tests/common_ledger.cpp>
|
#include <ripple/app/tests/common_ledger.cpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user