mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Devirtualize LedgerMaster.
This commit is contained in:
committed by
Nik Bougalis
parent
44fcab1081
commit
e1018546ac
@@ -1354,8 +1354,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\impl\LedgerCleaner.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\app\ledger\impl\LedgerConsensusImp.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
|
||||
@@ -1404,6 +1402,8 @@
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\Ledger.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerCleaner.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerConsensus.h">
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\app\ledger\LedgerHistory.cpp">
|
||||
|
||||
@@ -2088,9 +2088,6 @@
|
||||
<ClCompile Include="..\..\src\ripple\app\ledger\impl\LedgerCleaner.cpp">
|
||||
<Filter>ripple\app\ledger\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\impl\LedgerCleaner.h">
|
||||
<Filter>ripple\app\ledger\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\..\src\ripple\app\ledger\impl\LedgerConsensusImp.cpp">
|
||||
<Filter>ripple\app\ledger\impl</Filter>
|
||||
</ClCompile>
|
||||
@@ -2136,6 +2133,9 @@
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\Ledger.h">
|
||||
<Filter>ripple\app\ledger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerCleaner.h">
|
||||
<Filter>ripple\app\ledger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\app\ledger\LedgerConsensus.h">
|
||||
<Filter>ripple\app\ledger</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace detail {
|
||||
|
||||
/** Check the ledger/transaction databases to make sure they have continuity */
|
||||
class LedgerCleaner
|
||||
@@ -58,6 +59,7 @@ std::unique_ptr<LedgerCleaner>
|
||||
make_LedgerCleaner (Application& app,
|
||||
beast::Stoppable& parent, beast::Journal journal);
|
||||
|
||||
} // detail
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
@@ -22,8 +22,12 @@
|
||||
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/app/ledger/LedgerCleaner.h>
|
||||
#include <ripple/app/ledger/LedgerHistory.h>
|
||||
#include <ripple/app/ledger/LedgerHolder.h>
|
||||
#include <ripple/app/misc/CanonicalTXSet.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/basics/RangeSet.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/RippleLedgerHash.h>
|
||||
#include <ripple/protocol/STValidation.h>
|
||||
@@ -58,8 +62,12 @@ struct LedgerReplay
|
||||
class LedgerMaster
|
||||
: public beast::Stoppable
|
||||
{
|
||||
protected:
|
||||
explicit LedgerMaster (Stoppable& parent);
|
||||
public:
|
||||
explicit
|
||||
LedgerMaster(Application& app, Stopwatch& stopwatch,
|
||||
Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector,
|
||||
beast::Journal journal);
|
||||
|
||||
public:
|
||||
using callback = std::function <void (Ledger::ref)>;
|
||||
@@ -67,157 +75,245 @@ public:
|
||||
public:
|
||||
virtual ~LedgerMaster () = default;
|
||||
|
||||
virtual LedgerIndex getCurrentLedgerIndex () = 0;
|
||||
virtual LedgerIndex getValidLedgerIndex () = 0;
|
||||
LedgerIndex getCurrentLedgerIndex ();
|
||||
LedgerIndex getValidLedgerIndex ();
|
||||
|
||||
virtual bool isCompatible (Ledger::pointer,
|
||||
beast::Journal::Stream, const char* reason) = 0;
|
||||
bool isCompatible (Ledger::pointer,
|
||||
beast::Journal::Stream, const char* reason);
|
||||
|
||||
virtual std::recursive_mutex& peekMutex () = 0;
|
||||
std::recursive_mutex& peekMutex ();
|
||||
|
||||
// The current ledger is the ledger we believe new transactions should go in
|
||||
virtual std::shared_ptr<ReadView const> getCurrentLedger () = 0;
|
||||
std::shared_ptr<ReadView const> getCurrentLedger ();
|
||||
|
||||
// The finalized ledger is the last closed/accepted ledger
|
||||
virtual Ledger::pointer getClosedLedger () = 0;
|
||||
Ledger::pointer getClosedLedger ();
|
||||
|
||||
// The validated ledger is the last fully validated ledger
|
||||
virtual Ledger::pointer getValidatedLedger () = 0;
|
||||
Ledger::pointer getValidatedLedger ();
|
||||
|
||||
// The Rules are in the last fully validated ledger if there is one.
|
||||
virtual Rules getValidatedRules() = 0;
|
||||
Rules getValidatedRules();
|
||||
|
||||
// This is the last ledger we published to clients and can lag the validated
|
||||
// ledger
|
||||
virtual Ledger::pointer getPublishedLedger () = 0;
|
||||
Ledger::pointer getPublishedLedger ();
|
||||
|
||||
virtual bool isValidLedger(LedgerInfo const&) = 0;
|
||||
bool isValidLedger(LedgerInfo const&);
|
||||
|
||||
virtual std::chrono::seconds getPublishedLedgerAge () = 0;
|
||||
virtual std::chrono::seconds getValidatedLedgerAge () = 0;
|
||||
virtual bool isCaughtUp(std::string& reason) = 0;
|
||||
std::chrono::seconds getPublishedLedgerAge ();
|
||||
std::chrono::seconds getValidatedLedgerAge ();
|
||||
bool isCaughtUp(std::string& reason);
|
||||
|
||||
virtual int getMinValidations () = 0;
|
||||
int getMinValidations ();
|
||||
|
||||
virtual void setMinValidations (int v, bool strict) = 0;
|
||||
void setMinValidations (int v, bool strict);
|
||||
|
||||
virtual std::uint32_t getEarliestFetch () = 0;
|
||||
std::uint32_t getEarliestFetch ();
|
||||
|
||||
virtual bool storeLedger (Ledger::pointer) = 0;
|
||||
virtual void forceValid (Ledger::pointer) = 0;
|
||||
bool storeLedger (Ledger::pointer);
|
||||
void forceValid (Ledger::pointer);
|
||||
|
||||
virtual void setFullLedger (
|
||||
Ledger::pointer ledger, bool isSynchronous, bool isCurrent) = 0;
|
||||
void setFullLedger (
|
||||
Ledger::pointer ledger, bool isSynchronous, bool isCurrent);
|
||||
|
||||
virtual void switchLCL (Ledger::pointer lastClosed) = 0;
|
||||
void switchLCL (Ledger::pointer lastClosed);
|
||||
|
||||
virtual void failedSave(std::uint32_t seq, uint256 const& hash) = 0;
|
||||
void failedSave(std::uint32_t seq, uint256 const& hash);
|
||||
|
||||
virtual std::string getCompleteLedgers () = 0;
|
||||
std::string getCompleteLedgers ();
|
||||
|
||||
virtual void applyHeldTransactions () = 0;
|
||||
/** Apply held transactions to the open ledger
|
||||
This is normally called as we close the ledger.
|
||||
The open ledger remains open to handle new transactions
|
||||
until a new open ledger is built.
|
||||
*/
|
||||
void applyHeldTransactions ();
|
||||
|
||||
/** Get a ledger's hash by sequence number using the cache
|
||||
*/
|
||||
virtual uint256 getHashBySeq (std::uint32_t index) = 0;
|
||||
uint256 getHashBySeq (std::uint32_t index);
|
||||
|
||||
/** Walk to a ledger's hash using the skip list
|
||||
*/
|
||||
virtual uint256 walkHashBySeq (std::uint32_t index) = 0;
|
||||
virtual uint256 walkHashBySeq (
|
||||
std::uint32_t index, Ledger::ref referenceLedger) = 0;
|
||||
uint256 walkHashBySeq (std::uint32_t index);
|
||||
uint256 walkHashBySeq (
|
||||
std::uint32_t index, Ledger::ref referenceLedger);
|
||||
|
||||
virtual Ledger::pointer getLedgerBySeq (std::uint32_t index) = 0;
|
||||
Ledger::pointer getLedgerBySeq (std::uint32_t index);
|
||||
|
||||
virtual Ledger::pointer getLedgerByHash (uint256 const& hash) = 0;
|
||||
Ledger::pointer getLedgerByHash (uint256 const& hash);
|
||||
|
||||
virtual void setLedgerRangePresent (
|
||||
std::uint32_t minV, std::uint32_t maxV) = 0;
|
||||
void setLedgerRangePresent (
|
||||
std::uint32_t minV, std::uint32_t maxV);
|
||||
|
||||
virtual uint256 getLedgerHash(
|
||||
std::uint32_t desiredSeq, Ledger::ref knownGoodLedger) = 0;
|
||||
uint256 getLedgerHash(
|
||||
std::uint32_t desiredSeq, Ledger::ref knownGoodLedger);
|
||||
|
||||
virtual boost::optional <NetClock::time_point> getCloseTimeBySeq (
|
||||
LedgerIndex ledgerIndex) = 0;
|
||||
boost::optional <NetClock::time_point> getCloseTimeBySeq (
|
||||
LedgerIndex ledgerIndex);
|
||||
|
||||
virtual boost::optional <NetClock::time_point> getCloseTimeByHash (
|
||||
LedgerHash const& ledgerHash) = 0;
|
||||
boost::optional <NetClock::time_point> getCloseTimeByHash (
|
||||
LedgerHash const& ledgerHash);
|
||||
|
||||
virtual void addHeldTransaction (std::shared_ptr<Transaction> const& trans) = 0;
|
||||
virtual void fixMismatch (Ledger::ref ledger) = 0;
|
||||
void addHeldTransaction (std::shared_ptr<Transaction> const& trans);
|
||||
void fixMismatch (Ledger::ref ledger);
|
||||
|
||||
virtual bool haveLedger (std::uint32_t seq) = 0;
|
||||
virtual void clearLedger (std::uint32_t seq) = 0;
|
||||
virtual bool getValidatedRange (
|
||||
std::uint32_t& minVal, std::uint32_t& maxVal) = 0;
|
||||
virtual bool getFullValidatedRange (
|
||||
std::uint32_t& minVal, std::uint32_t& maxVal) = 0;
|
||||
bool haveLedger (std::uint32_t seq);
|
||||
void clearLedger (std::uint32_t seq);
|
||||
bool getValidatedRange (
|
||||
std::uint32_t& minVal, std::uint32_t& maxVal);
|
||||
bool getFullValidatedRange (
|
||||
std::uint32_t& minVal, std::uint32_t& maxVal);
|
||||
|
||||
virtual void tune (int size, int age) = 0;
|
||||
virtual void sweep () = 0;
|
||||
virtual float getCacheHitRate () = 0;
|
||||
void tune (int size, int age);
|
||||
void sweep ();
|
||||
float getCacheHitRate ();
|
||||
|
||||
virtual void checkAccept (Ledger::ref ledger) = 0;
|
||||
virtual void checkAccept (uint256 const& hash, std::uint32_t seq) = 0;
|
||||
virtual void consensusBuilt (Ledger::ref ledger, Json::Value consensus) = 0;
|
||||
void checkAccept (Ledger::ref ledger);
|
||||
void checkAccept (uint256 const& hash, std::uint32_t seq);
|
||||
void consensusBuilt (Ledger::ref ledger, Json::Value consensus);
|
||||
|
||||
virtual LedgerIndex getBuildingLedger () = 0;
|
||||
virtual void setBuildingLedger (LedgerIndex index) = 0;
|
||||
LedgerIndex getBuildingLedger ();
|
||||
void setBuildingLedger (LedgerIndex index);
|
||||
|
||||
virtual void tryAdvance () = 0;
|
||||
virtual void newPathRequest () = 0;
|
||||
virtual bool isNewPathRequest () = 0;
|
||||
virtual void newOrderBookDB () = 0;
|
||||
void tryAdvance ();
|
||||
void newPathRequest ();
|
||||
bool isNewPathRequest ();
|
||||
void newOrderBookDB ();
|
||||
|
||||
virtual bool fixIndex (
|
||||
LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) = 0;
|
||||
virtual void doLedgerCleaner(Json::Value const& parameters) = 0;
|
||||
bool fixIndex (
|
||||
LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
|
||||
void doLedgerCleaner(Json::Value const& parameters);
|
||||
|
||||
virtual beast::PropertyStream::Source& getPropertySource () = 0;
|
||||
beast::PropertyStream::Source& getPropertySource ();
|
||||
|
||||
virtual void clearPriorLedgers (LedgerIndex seq) = 0;
|
||||
void clearPriorLedgers (LedgerIndex seq);
|
||||
|
||||
virtual void clearLedgerCachePrior (LedgerIndex seq) = 0;
|
||||
void clearLedgerCachePrior (LedgerIndex seq);
|
||||
|
||||
// ledger replay
|
||||
virtual void takeReplay (std::unique_ptr<LedgerReplay> replay) = 0;
|
||||
virtual std::unique_ptr<LedgerReplay> releaseReplay () = 0;
|
||||
void takeReplay (std::unique_ptr<LedgerReplay> replay);
|
||||
std::unique_ptr<LedgerReplay> releaseReplay ();
|
||||
|
||||
// Fetch Packs
|
||||
virtual
|
||||
void gotFetchPack (
|
||||
bool progress,
|
||||
std::uint32_t seq) = 0;
|
||||
std::uint32_t seq);
|
||||
|
||||
virtual
|
||||
void addFetchPack (
|
||||
uint256 const& hash,
|
||||
std::shared_ptr<Blob>& data) = 0;
|
||||
std::shared_ptr<Blob>& data);
|
||||
|
||||
virtual
|
||||
bool getFetchPack (
|
||||
uint256 const& hash,
|
||||
Blob& data) = 0;
|
||||
Blob& data);
|
||||
|
||||
virtual
|
||||
void makeFetchPack (
|
||||
std::weak_ptr<Peer> const& wPeer,
|
||||
std::shared_ptr<protocol::TMGetObjectByHash> const& request,
|
||||
uint256 haveLedgerHash,
|
||||
std::uint32_t uUptime) = 0;
|
||||
std::uint32_t uUptime);
|
||||
|
||||
std::size_t getFetchPackCacheSize () const;
|
||||
|
||||
private:
|
||||
void setValidLedger(Ledger::ref l);
|
||||
void setPubLedger(Ledger::ref l);
|
||||
void tryFill(Job& job, Ledger::pointer ledger);
|
||||
void getFetchPack(LedgerHash missingHash, LedgerIndex missingIndex);
|
||||
LedgerHash getLedgerHashForHistory(LedgerIndex index);
|
||||
int getNeededValidations();
|
||||
void advanceThread();
|
||||
// Try to publish ledgers, acquire missing ledgers
|
||||
void doAdvance();
|
||||
bool shouldFetchPack(std::uint32_t seq) const;
|
||||
bool shouldAcquire(
|
||||
std::uint32_t const currentLedger,
|
||||
std::uint32_t const ledgerHistory,
|
||||
std::uint32_t const ledgerHistoryIndex,
|
||||
std::uint32_t const candidateLedger) const;
|
||||
std::vector<Ledger::pointer> findNewLedgersToPublish();
|
||||
void updatePaths(Job& job);
|
||||
void newPFWork(const char *name);
|
||||
|
||||
private:
|
||||
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
|
||||
using ScopedUnlockType = beast::GenericScopedUnlock <std::recursive_mutex>;
|
||||
|
||||
Application& app_;
|
||||
beast::Journal m_journal;
|
||||
|
||||
std::recursive_mutex m_mutex;
|
||||
|
||||
// The ledger that most recently closed.
|
||||
LedgerHolder mClosedLedger;
|
||||
|
||||
// The highest-sequence ledger we have fully accepted.
|
||||
LedgerHolder mValidLedger;
|
||||
|
||||
// The last ledger we have published.
|
||||
Ledger::pointer mPubLedger;
|
||||
|
||||
// The last ledger we did pathfinding against.
|
||||
Ledger::pointer mPathLedger;
|
||||
|
||||
// The last ledger we handled fetching history
|
||||
Ledger::pointer mHistLedger;
|
||||
|
||||
// Fully validated ledger, whether or not we have the ledger resident.
|
||||
std::pair <uint256, LedgerIndex> mLastValidLedger;
|
||||
|
||||
LedgerHistory mLedgerHistory;
|
||||
|
||||
CanonicalTXSet mHeldTransactions;
|
||||
|
||||
// A set of transactions to replay during the next close
|
||||
std::unique_ptr<LedgerReplay> replayData;
|
||||
|
||||
std::recursive_mutex mCompleteLock;
|
||||
RangeSet mCompleteLedgers;
|
||||
|
||||
std::unique_ptr <detail::LedgerCleaner> mLedgerCleaner;
|
||||
|
||||
int mMinValidations; // The minimum validations to publish a ledger.
|
||||
bool mStrictValCount; // Don't raise the minimum
|
||||
uint256 mLastValidateHash;
|
||||
std::uint32_t mLastValidateSeq;
|
||||
|
||||
// Publish thread is running.
|
||||
bool mAdvanceThread;
|
||||
|
||||
// Publish thread has work to do.
|
||||
bool mAdvanceWork;
|
||||
int mFillInProgress;
|
||||
|
||||
int mPathFindThread; // Pathfinder jobs dispatched
|
||||
bool mPathFindNewRequest;
|
||||
|
||||
std::atomic <std::uint32_t> mPubLedgerClose;
|
||||
std::atomic <std::uint32_t> mPubLedgerSeq;
|
||||
std::atomic <std::uint32_t> mValidLedgerSign;
|
||||
std::atomic <std::uint32_t> mValidLedgerSeq;
|
||||
std::atomic <std::uint32_t> mBuildingLedgerSeq;
|
||||
|
||||
// The server is in standalone mode
|
||||
bool const standalone_;
|
||||
|
||||
// How many ledgers before the current ledger do we allow peers to request?
|
||||
std::uint32_t const fetch_depth_;
|
||||
|
||||
// How much history do we want to keep
|
||||
std::uint32_t const ledger_history_;
|
||||
|
||||
int const ledger_fetch_size_;
|
||||
|
||||
TaggedCache<uint256, Blob> fetch_packs_;
|
||||
|
||||
std::uint32_t fetch_seq_;
|
||||
|
||||
virtual
|
||||
std::size_t getFetchPackCacheSize () const = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr <LedgerMaster>
|
||||
make_LedgerMaster (
|
||||
Application& app,
|
||||
Stopwatch& stopwatch,
|
||||
beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector,
|
||||
beast::Journal journal);
|
||||
|
||||
} // ripple
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/ledger/impl/LedgerCleaner.h>
|
||||
#include <ripple/app/ledger/LedgerCleaner.h>
|
||||
#include <ripple/app/ledger/InboundLedgers.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <beast/threads/Thread.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace detail {
|
||||
|
||||
/*
|
||||
|
||||
@@ -502,4 +503,5 @@ make_LedgerCleaner (Application& app,
|
||||
return std::make_unique<LedgerCleanerImp>(app, parent, journal);
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // ripple
|
||||
|
||||
@@ -20,24 +20,20 @@
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/ledger/InboundLedgers.h>
|
||||
#include <ripple/app/ledger/LedgerHistory.h>
|
||||
#include <ripple/app/ledger/OpenLedger.h>
|
||||
#include <ripple/app/ledger/OrderBookDB.h>
|
||||
#include <ripple/app/ledger/PendingSaves.h>
|
||||
#include <ripple/app/ledger/impl/LedgerCleaner.h>
|
||||
#include <ripple/app/tx/apply.h>
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/app/misc/AmendmentTable.h>
|
||||
#include <ripple/app/misc/HashRouter.h>
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/app/misc/CanonicalTXSet.h>
|
||||
#include <ripple/app/misc/SHAMapStore.h>
|
||||
#include <ripple/app/misc/Transaction.h>
|
||||
#include <ripple/app/misc/TxQ.h>
|
||||
#include <ripple/app/misc/Validations.h>
|
||||
#include <ripple/app/paths/PathRequests.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/RangeSet.h>
|
||||
#include <ripple/basics/TaggedCache.h>
|
||||
#include <ripple/basics/UptimeTimer.h>
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
@@ -65,96 +61,16 @@ using namespace std::chrono_literals;
|
||||
// Don't acquire history if ledger is too old
|
||||
auto constexpr MAX_LEDGER_AGE_ACQUIRE = 1min;
|
||||
|
||||
class LedgerMasterImp
|
||||
: public LedgerMaster
|
||||
{
|
||||
public:
|
||||
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
|
||||
using ScopedUnlockType = beast::GenericScopedUnlock <std::recursive_mutex>;
|
||||
|
||||
Application& app_;
|
||||
beast::Journal m_journal;
|
||||
|
||||
std::recursive_mutex m_mutex;
|
||||
|
||||
// The ledger that most recently closed.
|
||||
LedgerHolder mClosedLedger;
|
||||
|
||||
// The highest-sequence ledger we have fully accepted.
|
||||
LedgerHolder mValidLedger;
|
||||
|
||||
// The last ledger we have published.
|
||||
Ledger::pointer mPubLedger;
|
||||
|
||||
// The last ledger we did pathfinding against.
|
||||
Ledger::pointer mPathLedger;
|
||||
|
||||
// The last ledger we handled fetching history
|
||||
Ledger::pointer mHistLedger;
|
||||
|
||||
// Fully validated ledger, whether or not we have the ledger resident.
|
||||
std::pair <uint256, LedgerIndex> mLastValidLedger;
|
||||
|
||||
LedgerHistory mLedgerHistory;
|
||||
|
||||
CanonicalTXSet mHeldTransactions;
|
||||
|
||||
// A set of transactions to replay during the next close
|
||||
std::unique_ptr<LedgerReplay> replayData;
|
||||
|
||||
std::recursive_mutex mCompleteLock;
|
||||
RangeSet mCompleteLedgers;
|
||||
|
||||
std::unique_ptr <LedgerCleaner> mLedgerCleaner;
|
||||
|
||||
int mMinValidations; // The minimum validations to publish a ledger.
|
||||
bool mStrictValCount; // Don't raise the minimum
|
||||
uint256 mLastValidateHash;
|
||||
std::uint32_t mLastValidateSeq;
|
||||
|
||||
// Publish thread is running.
|
||||
bool mAdvanceThread;
|
||||
|
||||
// Publish thread has work to do.
|
||||
bool mAdvanceWork;
|
||||
int mFillInProgress;
|
||||
|
||||
int mPathFindThread; // Pathfinder jobs dispatched
|
||||
bool mPathFindNewRequest;
|
||||
|
||||
std::atomic <std::uint32_t> mPubLedgerClose;
|
||||
std::atomic <std::uint32_t> mPubLedgerSeq;
|
||||
std::atomic <std::uint32_t> mValidLedgerSign;
|
||||
std::atomic <std::uint32_t> mValidLedgerSeq;
|
||||
std::atomic <std::uint32_t> mBuildingLedgerSeq;
|
||||
|
||||
// The server is in standalone mode
|
||||
bool const standalone_;
|
||||
|
||||
// How many ledgers before the current ledger do we allow peers to request?
|
||||
std::uint32_t const fetch_depth_;
|
||||
|
||||
// How much history do we want to keep
|
||||
std::uint32_t const ledger_history_;
|
||||
|
||||
int const ledger_fetch_size_;
|
||||
|
||||
TaggedCache<uint256, Blob> fetch_packs_;
|
||||
|
||||
std::uint32_t fetch_seq_;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
LedgerMasterImp (Application& app, Stopwatch& stopwatch,
|
||||
LedgerMaster::LedgerMaster (Application& app, Stopwatch& stopwatch,
|
||||
Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector, beast::Journal journal)
|
||||
: LedgerMaster (parent)
|
||||
: Stoppable ("LedgerMaster", parent)
|
||||
, app_ (app)
|
||||
, m_journal (journal)
|
||||
, mLastValidLedger (std::make_pair (uint256(), 0))
|
||||
, mLedgerHistory (collector, app)
|
||||
, mHeldTransactions (uint256 ())
|
||||
, mLedgerCleaner (make_LedgerCleaner (
|
||||
, mLedgerCleaner (detail::make_LedgerCleaner (
|
||||
app, *this, app_.journal("LedgerCleaner")))
|
||||
, mMinValidations (0)
|
||||
, mStrictValCount (false)
|
||||
@@ -180,22 +96,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~LedgerMasterImp ()
|
||||
{
|
||||
}
|
||||
|
||||
LedgerIndex getCurrentLedgerIndex () override
|
||||
LedgerIndex
|
||||
LedgerMaster::getCurrentLedgerIndex ()
|
||||
{
|
||||
return app_.openLedger().current()->info().seq;
|
||||
}
|
||||
|
||||
LedgerIndex getValidLedgerIndex () override
|
||||
LedgerIndex
|
||||
LedgerMaster::getValidLedgerIndex ()
|
||||
{
|
||||
return mValidLedgerSeq;
|
||||
}
|
||||
|
||||
bool isCompatible (Ledger::pointer ledger,
|
||||
beast::Journal::Stream s, const char* reason) override
|
||||
bool
|
||||
LedgerMaster::isCompatible (Ledger::pointer ledger,
|
||||
beast::Journal::Stream s, const char* reason)
|
||||
{
|
||||
if (mStrictValCount)
|
||||
{
|
||||
@@ -227,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
std::chrono::seconds
|
||||
getPublishedLedgerAge() override
|
||||
LedgerMaster::getPublishedLedgerAge()
|
||||
{
|
||||
std::chrono::seconds pubClose{mPubLedgerClose.load()};
|
||||
if (pubClose == 0s)
|
||||
@@ -245,7 +160,7 @@ public:
|
||||
}
|
||||
|
||||
std::chrono::seconds
|
||||
getValidatedLedgerAge() override
|
||||
LedgerMaster::getValidatedLedgerAge()
|
||||
{
|
||||
std::chrono::seconds valClose{mValidLedgerSign.load()};
|
||||
if (valClose == 0s)
|
||||
@@ -262,7 +177,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isCaughtUp(std::string& reason) override
|
||||
bool
|
||||
LedgerMaster::isCaughtUp(std::string& reason)
|
||||
{
|
||||
if (getPublishedLedgerAge() > 3min)
|
||||
{
|
||||
@@ -284,7 +200,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void setValidLedger(Ledger::ref l)
|
||||
void
|
||||
LedgerMaster::setValidLedger(Ledger::ref l)
|
||||
{
|
||||
std::vector <NetClock::time_point> times;
|
||||
NetClock::time_point signTime;
|
||||
@@ -313,22 +230,25 @@ public:
|
||||
app_.getAmendmentTable().doValidatedLedger (l);
|
||||
}
|
||||
|
||||
void setPubLedger(Ledger::ref l)
|
||||
void
|
||||
LedgerMaster::setPubLedger(Ledger::ref l)
|
||||
{
|
||||
mPubLedger = l;
|
||||
mPubLedgerClose = l->info().closeTime.time_since_epoch().count();
|
||||
mPubLedgerSeq = l->info().seq;
|
||||
}
|
||||
|
||||
void addHeldTransaction (
|
||||
std::shared_ptr<Transaction> const& transaction) override
|
||||
void
|
||||
LedgerMaster::addHeldTransaction (
|
||||
std::shared_ptr<Transaction> const& transaction)
|
||||
{
|
||||
// returns true if transaction was added
|
||||
ScopedLockType ml (m_mutex);
|
||||
mHeldTransactions.insert (transaction->getSTransaction ());
|
||||
}
|
||||
|
||||
void switchLCL (Ledger::pointer lastClosed) override
|
||||
void
|
||||
LedgerMaster::switchLCL (Ledger::pointer lastClosed)
|
||||
{
|
||||
assert (lastClosed);
|
||||
|
||||
@@ -352,18 +272,20 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
fixIndex (LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) override
|
||||
LedgerMaster::fixIndex (LedgerIndex ledgerIndex, LedgerHash const& ledgerHash)
|
||||
{
|
||||
return mLedgerHistory.fixIndex (ledgerIndex, ledgerHash);
|
||||
}
|
||||
|
||||
bool storeLedger (Ledger::pointer ledger) override
|
||||
bool
|
||||
LedgerMaster::storeLedger (Ledger::pointer ledger)
|
||||
{
|
||||
// Returns true if we already had the ledger
|
||||
return mLedgerHistory.addLedger (ledger, false);
|
||||
}
|
||||
|
||||
void forceValid (Ledger::pointer ledger) override
|
||||
void
|
||||
LedgerMaster::forceValid (Ledger::pointer ledger)
|
||||
{
|
||||
ledger->setValidated();
|
||||
setFullLedger(ledger, true, false);
|
||||
@@ -374,7 +296,8 @@ public:
|
||||
The open ledger remains open to handle new transactions
|
||||
until a new open ledger is built.
|
||||
*/
|
||||
void applyHeldTransactions () override
|
||||
void
|
||||
LedgerMaster::applyHeldTransactions ()
|
||||
{
|
||||
ScopedLockType sl (m_mutex);
|
||||
|
||||
@@ -401,31 +324,36 @@ public:
|
||||
app_.openLedger().current()->info().parentHash);
|
||||
}
|
||||
|
||||
LedgerIndex getBuildingLedger () override
|
||||
LedgerIndex
|
||||
LedgerMaster::getBuildingLedger ()
|
||||
{
|
||||
// The ledger we are currently building, 0 of none
|
||||
return mBuildingLedgerSeq.load ();
|
||||
}
|
||||
|
||||
void setBuildingLedger (LedgerIndex i) override
|
||||
void
|
||||
LedgerMaster::setBuildingLedger (LedgerIndex i)
|
||||
{
|
||||
mBuildingLedgerSeq.store (i);
|
||||
}
|
||||
|
||||
bool haveLedger (std::uint32_t seq) override
|
||||
bool
|
||||
LedgerMaster::haveLedger (std::uint32_t seq)
|
||||
{
|
||||
ScopedLockType sl (mCompleteLock);
|
||||
return mCompleteLedgers.hasValue (seq);
|
||||
}
|
||||
|
||||
void clearLedger (std::uint32_t seq) override
|
||||
void
|
||||
LedgerMaster::clearLedger (std::uint32_t seq)
|
||||
{
|
||||
ScopedLockType sl (mCompleteLock);
|
||||
return mCompleteLedgers.clearValue (seq);
|
||||
}
|
||||
|
||||
// returns Ledgers we have all the nodes for
|
||||
bool getFullValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) override
|
||||
bool
|
||||
LedgerMaster::getFullValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal)
|
||||
{
|
||||
// Validated ledger is likely not stored in the DB yet so we use the
|
||||
// published ledger which is.
|
||||
@@ -448,7 +376,8 @@ public:
|
||||
}
|
||||
|
||||
// Returns Ledgers we have all the nodes for and are indexed
|
||||
bool getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal) override
|
||||
bool
|
||||
LedgerMaster::getValidatedRange (std::uint32_t& minVal, std::uint32_t& maxVal)
|
||||
{
|
||||
// Validated ledger is likely not stored in the DB yet so we use the
|
||||
// published ledger which is.
|
||||
@@ -503,7 +432,8 @@ public:
|
||||
}
|
||||
|
||||
// Get the earliest ledger we will let peers fetch
|
||||
std::uint32_t getEarliestFetch () override
|
||||
std::uint32_t
|
||||
LedgerMaster::getEarliestFetch ()
|
||||
{
|
||||
// The earliest ledger we will let people fetch is ledger zero,
|
||||
// unless that creates a larger range than allowed
|
||||
@@ -516,7 +446,8 @@ public:
|
||||
return e;
|
||||
}
|
||||
|
||||
void tryFill (Job& job, Ledger::pointer ledger)
|
||||
void
|
||||
LedgerMaster::tryFill (Job& job, Ledger::pointer ledger)
|
||||
{
|
||||
std::uint32_t seq = ledger->info().seq;
|
||||
uint256 prevHash = ledger->info().parentHash;
|
||||
@@ -577,7 +508,8 @@ public:
|
||||
|
||||
/** Request a fetch pack to get to the specified ledger
|
||||
*/
|
||||
void getFetchPack (LedgerHash missingHash, LedgerIndex missingIndex)
|
||||
void
|
||||
LedgerMaster::getFetchPack (LedgerHash missingHash, LedgerIndex missingIndex)
|
||||
{
|
||||
uint256 haveHash = getLedgerHashForHistory (missingIndex + 1);
|
||||
|
||||
@@ -624,7 +556,8 @@ public:
|
||||
JLOG (m_journal.debug) << "No peer for fetch pack";
|
||||
}
|
||||
|
||||
void fixMismatch (Ledger::ref ledger) override
|
||||
void
|
||||
LedgerMaster::fixMismatch (Ledger::ref ledger)
|
||||
{
|
||||
int invalidate = 0;
|
||||
boost::optional<uint256> hash;
|
||||
@@ -670,8 +603,9 @@ public:
|
||||
invalidate << " prior ledgers invalidated";
|
||||
}
|
||||
|
||||
void setFullLedger (
|
||||
Ledger::pointer ledger, bool isSynchronous, bool isCurrent) override
|
||||
void
|
||||
LedgerMaster::setFullLedger (
|
||||
Ledger::pointer ledger, bool isSynchronous, bool isCurrent)
|
||||
{
|
||||
// A new ledger has been accepted as part of the trusted chain
|
||||
JLOG (m_journal.debug) << "Ledger " << ledger->info().seq
|
||||
@@ -729,7 +663,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void failedSave(std::uint32_t seq, uint256 const& hash) override
|
||||
void
|
||||
LedgerMaster::failedSave(std::uint32_t seq, uint256 const& hash)
|
||||
{
|
||||
clearLedger(seq);
|
||||
app_.getInboundLedgers().acquire(
|
||||
@@ -738,7 +673,8 @@ public:
|
||||
|
||||
// Check if the specified ledger can become the new last fully-validated
|
||||
// ledger.
|
||||
void checkAccept (uint256 const& hash, std::uint32_t seq) override
|
||||
void
|
||||
LedgerMaster::checkAccept (uint256 const& hash, std::uint32_t seq)
|
||||
{
|
||||
|
||||
int valCount;
|
||||
@@ -800,7 +736,8 @@ public:
|
||||
*
|
||||
* @return Number of validations needed
|
||||
*/
|
||||
int getNeededValidations ()
|
||||
int
|
||||
LedgerMaster::getNeededValidations ()
|
||||
{
|
||||
if (standalone_)
|
||||
return 0;
|
||||
@@ -821,7 +758,8 @@ public:
|
||||
return minVal;
|
||||
}
|
||||
|
||||
void checkAccept (Ledger::ref ledger) override
|
||||
void
|
||||
LedgerMaster::checkAccept (Ledger::ref ledger)
|
||||
{
|
||||
if (ledger->info().seq <= mValidLedgerSeq)
|
||||
return;
|
||||
@@ -885,7 +823,8 @@ public:
|
||||
}
|
||||
|
||||
/** Report that the consensus process built a particular ledger */
|
||||
void consensusBuilt (Ledger::ref ledger, Json::Value consensus) override
|
||||
void
|
||||
LedgerMaster::consensusBuilt (Ledger::ref ledger, Json::Value consensus)
|
||||
{
|
||||
|
||||
// Because we just built a ledger, we are no longer building one
|
||||
@@ -981,7 +920,8 @@ public:
|
||||
mLedgerHistory.builtLedger (ledger, std::move (consensus));
|
||||
}
|
||||
|
||||
void advanceThread()
|
||||
void
|
||||
LedgerMaster::advanceThread()
|
||||
{
|
||||
ScopedLockType sl (m_mutex);
|
||||
assert (!mValidLedger.empty () && mAdvanceThread);
|
||||
@@ -1002,7 +942,8 @@ public:
|
||||
}
|
||||
|
||||
// VFALCO NOTE This should return boost::optional<uint256>
|
||||
LedgerHash getLedgerHashForHistory (LedgerIndex index)
|
||||
LedgerHash
|
||||
LedgerMaster::getLedgerHashForHistory (LedgerIndex index)
|
||||
{
|
||||
// Try to get the hash of a ledger we need to fetch for history
|
||||
boost::optional<LedgerHash> ret;
|
||||
@@ -1020,21 +961,14 @@ public:
|
||||
return *ret;
|
||||
}
|
||||
|
||||
bool shouldFetchPack (std::uint32_t seq) const
|
||||
bool
|
||||
LedgerMaster::shouldFetchPack (std::uint32_t seq) const
|
||||
{
|
||||
return (fetch_seq_ != seq);
|
||||
}
|
||||
|
||||
bool shouldAcquire (
|
||||
std::uint32_t const currentLedger,
|
||||
std::uint32_t const ledgerHistory,
|
||||
std::uint32_t const ledgerHistoryIndex,
|
||||
std::uint32_t const candidateLedger) const;
|
||||
|
||||
// Try to publish ledgers, acquire missing ledgers
|
||||
void doAdvance ();
|
||||
|
||||
std::vector<Ledger::pointer> findNewLedgersToPublish ()
|
||||
std::vector<Ledger::pointer>
|
||||
LedgerMaster::findNewLedgersToPublish ()
|
||||
{
|
||||
std::vector<Ledger::pointer> ret;
|
||||
|
||||
@@ -1126,7 +1060,8 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tryAdvance() override
|
||||
void
|
||||
LedgerMaster::tryAdvance()
|
||||
{
|
||||
ScopedLockType ml (m_mutex);
|
||||
|
||||
@@ -1144,7 +1079,8 @@ public:
|
||||
// Return the hash of the valid ledger with a particular sequence, given a
|
||||
// subsequent ledger known valid.
|
||||
// VFALCO NOTE This should return boost::optional<uint256>
|
||||
uint256 getLedgerHash(std::uint32_t desiredSeq, Ledger::ref knownGoodLedger) override
|
||||
uint256
|
||||
LedgerMaster::getLedgerHash(std::uint32_t desiredSeq, Ledger::ref knownGoodLedger)
|
||||
{
|
||||
assert(desiredSeq < knownGoodLedger->info().seq);
|
||||
|
||||
@@ -1177,7 +1113,8 @@ public:
|
||||
return hash ? *hash : zero; // kludge
|
||||
}
|
||||
|
||||
void updatePaths (Job& job)
|
||||
void
|
||||
LedgerMaster::updatePaths (Job& job)
|
||||
{
|
||||
{
|
||||
ScopedLockType ml (m_mutex);
|
||||
@@ -1254,7 +1191,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void newPathRequest () override
|
||||
void
|
||||
LedgerMaster::newPathRequest ()
|
||||
{
|
||||
ScopedLockType ml (m_mutex);
|
||||
mPathFindNewRequest = true;
|
||||
@@ -1262,7 +1200,8 @@ public:
|
||||
newPFWork("pf:newRequest");
|
||||
}
|
||||
|
||||
bool isNewPathRequest () override
|
||||
bool
|
||||
LedgerMaster::isNewPathRequest ()
|
||||
{
|
||||
ScopedLockType ml (m_mutex);
|
||||
if (!mPathFindNewRequest)
|
||||
@@ -1273,7 +1212,8 @@ public:
|
||||
|
||||
// If the order book is radically updated, we need to reprocess all
|
||||
// pathfinding requests.
|
||||
void newOrderBookDB () override
|
||||
void
|
||||
LedgerMaster::newOrderBookDB ()
|
||||
{
|
||||
ScopedLockType ml (m_mutex);
|
||||
mPathLedger.reset();
|
||||
@@ -1283,7 +1223,8 @@ public:
|
||||
|
||||
/** A thread needs to be dispatched to handle pathfinding work of some kind.
|
||||
*/
|
||||
void newPFWork (const char *name)
|
||||
void
|
||||
LedgerMaster::newPFWork (const char *name)
|
||||
{
|
||||
if (mPathFindThread < 2)
|
||||
{
|
||||
@@ -1294,30 +1235,35 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::recursive_mutex& peekMutex () override
|
||||
std::recursive_mutex&
|
||||
LedgerMaster::peekMutex ()
|
||||
{
|
||||
return m_mutex;
|
||||
}
|
||||
|
||||
// The current ledger is the ledger we believe new transactions should go in
|
||||
std::shared_ptr<ReadView const> getCurrentLedger () override
|
||||
std::shared_ptr<ReadView const>
|
||||
LedgerMaster::getCurrentLedger ()
|
||||
{
|
||||
return app_.openLedger().current();
|
||||
}
|
||||
|
||||
// The finalized ledger is the last closed/accepted ledger
|
||||
Ledger::pointer getClosedLedger () override
|
||||
Ledger::pointer
|
||||
LedgerMaster::getClosedLedger ()
|
||||
{
|
||||
return mClosedLedger.get ();
|
||||
}
|
||||
|
||||
// The validated ledger is the last fully validated ledger
|
||||
Ledger::pointer getValidatedLedger () override
|
||||
Ledger::pointer
|
||||
LedgerMaster::getValidatedLedger ()
|
||||
{
|
||||
return mValidLedger.get ();
|
||||
}
|
||||
|
||||
Rules getValidatedRules () override
|
||||
Rules
|
||||
LedgerMaster::getValidatedRules ()
|
||||
{
|
||||
// Once we have a guarantee that there's always a last validated
|
||||
// ledger then we can dispense with the if.
|
||||
@@ -1331,13 +1277,15 @@ public:
|
||||
|
||||
// This is the last ledger we published to clients and can lag the validated
|
||||
// ledger.
|
||||
Ledger::pointer getPublishedLedger () override
|
||||
Ledger::pointer
|
||||
LedgerMaster::getPublishedLedger ()
|
||||
{
|
||||
ScopedLockType lock(m_mutex);
|
||||
return mPubLedger;
|
||||
}
|
||||
|
||||
bool isValidLedger(LedgerInfo const& info) override
|
||||
bool
|
||||
LedgerMaster::isValidLedger(LedgerInfo const& info)
|
||||
{
|
||||
if (info.validated)
|
||||
return true;
|
||||
@@ -1367,12 +1315,14 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
int getMinValidations () override
|
||||
int
|
||||
LedgerMaster::getMinValidations ()
|
||||
{
|
||||
return mMinValidations;
|
||||
}
|
||||
|
||||
void setMinValidations (int v, bool strict) override
|
||||
void
|
||||
LedgerMaster::setMinValidations (int v, bool strict)
|
||||
{
|
||||
JLOG (m_journal.info) << "Validation quorum: " << v
|
||||
<< (strict ? " strict" : "");
|
||||
@@ -1380,21 +1330,22 @@ public:
|
||||
mStrictValCount = strict;
|
||||
}
|
||||
|
||||
std::string getCompleteLedgers () override
|
||||
std::string
|
||||
LedgerMaster::getCompleteLedgers ()
|
||||
{
|
||||
ScopedLockType sl (mCompleteLock);
|
||||
return mCompleteLedgers.toString ();
|
||||
}
|
||||
|
||||
boost::optional <NetClock::time_point>
|
||||
getCloseTimeBySeq (LedgerIndex ledgerIndex) override
|
||||
LedgerMaster::getCloseTimeBySeq (LedgerIndex ledgerIndex)
|
||||
{
|
||||
uint256 hash = getHashBySeq (ledgerIndex);
|
||||
return hash.isNonZero() ? getCloseTimeByHash (hash) : boost::none;
|
||||
}
|
||||
|
||||
boost::optional <NetClock::time_point>
|
||||
getCloseTimeByHash (LedgerHash const& ledgerHash) override
|
||||
LedgerMaster::getCloseTimeByHash (LedgerHash const& ledgerHash)
|
||||
{
|
||||
auto node = app_.getNodeStore().fetch (ledgerHash);
|
||||
if (node &&
|
||||
@@ -1413,7 +1364,8 @@ public:
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
uint256 getHashBySeq (std::uint32_t index) override
|
||||
uint256
|
||||
LedgerMaster::getHashBySeq (std::uint32_t index)
|
||||
{
|
||||
uint256 hash = mLedgerHistory.getLedgerHash (index);
|
||||
|
||||
@@ -1424,7 +1376,8 @@ public:
|
||||
}
|
||||
|
||||
// VFALCO NOTE This should return boost::optional<uint256>
|
||||
uint256 walkHashBySeq (std::uint32_t index) override
|
||||
uint256
|
||||
LedgerMaster::walkHashBySeq (std::uint32_t index)
|
||||
{
|
||||
uint256 ledgerHash;
|
||||
Ledger::pointer referenceLedger;
|
||||
@@ -1443,7 +1396,8 @@ public:
|
||||
in the node store.
|
||||
*/
|
||||
// VFALCO NOTE This should return boost::optional<uint256>
|
||||
uint256 walkHashBySeq (std::uint32_t index, Ledger::ref referenceLedger) override
|
||||
uint256
|
||||
LedgerMaster::walkHashBySeq (std::uint32_t index, Ledger::ref referenceLedger)
|
||||
{
|
||||
if (!referenceLedger || (referenceLedger->info().seq < index))
|
||||
{
|
||||
@@ -1493,7 +1447,8 @@ public:
|
||||
return ledgerHash ? *ledgerHash : zero; // kludge
|
||||
}
|
||||
|
||||
Ledger::pointer getLedgerBySeq (std::uint32_t index) override
|
||||
Ledger::pointer
|
||||
LedgerMaster::getLedgerBySeq (std::uint32_t index)
|
||||
{
|
||||
if (index <= mValidLedgerSeq)
|
||||
{
|
||||
@@ -1529,7 +1484,8 @@ public:
|
||||
return Ledger::pointer();
|
||||
}
|
||||
|
||||
Ledger::pointer getLedgerByHash (uint256 const& hash) override
|
||||
Ledger::pointer
|
||||
LedgerMaster::getLedgerByHash (uint256 const& hash)
|
||||
{
|
||||
Ledger::pointer ret = mLedgerHistory.getLedgerByHash (hash);
|
||||
if (ret)
|
||||
@@ -1542,38 +1498,46 @@ public:
|
||||
return Ledger::pointer ();
|
||||
}
|
||||
|
||||
void doLedgerCleaner(Json::Value const& parameters) override
|
||||
void
|
||||
LedgerMaster::doLedgerCleaner(Json::Value const& parameters)
|
||||
{
|
||||
mLedgerCleaner->doClean (parameters);
|
||||
}
|
||||
|
||||
void setLedgerRangePresent (std::uint32_t minV, std::uint32_t maxV) override
|
||||
void
|
||||
LedgerMaster::setLedgerRangePresent (std::uint32_t minV, std::uint32_t maxV)
|
||||
{
|
||||
ScopedLockType sl (mCompleteLock);
|
||||
mCompleteLedgers.setRange (minV, maxV);
|
||||
}
|
||||
void tune (int size, int age) override
|
||||
|
||||
void
|
||||
LedgerMaster::tune (int size, int age)
|
||||
{
|
||||
mLedgerHistory.tune (size, age);
|
||||
}
|
||||
|
||||
void sweep () override
|
||||
void
|
||||
LedgerMaster::sweep ()
|
||||
{
|
||||
mLedgerHistory.sweep ();
|
||||
fetch_packs_.sweep ();
|
||||
}
|
||||
|
||||
float getCacheHitRate () override
|
||||
float
|
||||
LedgerMaster::getCacheHitRate ()
|
||||
{
|
||||
return mLedgerHistory.getCacheHitRate ();
|
||||
}
|
||||
|
||||
beast::PropertyStream::Source& getPropertySource () override
|
||||
beast::PropertyStream::Source&
|
||||
LedgerMaster::getPropertySource ()
|
||||
{
|
||||
return *mLedgerCleaner;
|
||||
}
|
||||
|
||||
void clearPriorLedgers (LedgerIndex seq) override
|
||||
void
|
||||
LedgerMaster::clearPriorLedgers (LedgerIndex seq)
|
||||
{
|
||||
ScopedLockType sl (mCompleteLock);
|
||||
for (LedgerIndex i = mCompleteLedgers.getFirst(); i < seq; ++i)
|
||||
@@ -1583,44 +1547,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void clearLedgerCachePrior (LedgerIndex seq) override
|
||||
void
|
||||
LedgerMaster::clearLedgerCachePrior (LedgerIndex seq)
|
||||
{
|
||||
mLedgerHistory.clearLedgerCachePrior (seq);
|
||||
}
|
||||
|
||||
void takeReplay (std::unique_ptr<LedgerReplay> replay) override
|
||||
void
|
||||
LedgerMaster::takeReplay (std::unique_ptr<LedgerReplay> replay)
|
||||
{
|
||||
replayData = std::move (replay);
|
||||
}
|
||||
|
||||
std::unique_ptr<LedgerReplay> releaseReplay () override
|
||||
std::unique_ptr<LedgerReplay>
|
||||
LedgerMaster::releaseReplay ()
|
||||
{
|
||||
return std::move (replayData);
|
||||
}
|
||||
|
||||
// Fetch packs:
|
||||
void gotFetchPack (
|
||||
bool progress,
|
||||
std::uint32_t seq) override;
|
||||
|
||||
void addFetchPack (
|
||||
uint256 const& hash,
|
||||
std::shared_ptr<Blob>& data) override;
|
||||
|
||||
bool getFetchPack (
|
||||
uint256 const& hash,
|
||||
Blob& data) override;
|
||||
|
||||
void makeFetchPack (
|
||||
std::weak_ptr<Peer> const& wPeer,
|
||||
std::shared_ptr<protocol::TMGetObjectByHash> const& request,
|
||||
uint256 haveLedgerHash,
|
||||
std::uint32_t uUptime) override;
|
||||
|
||||
std::size_t getFetchPackCacheSize () const override;
|
||||
};
|
||||
|
||||
bool LedgerMasterImp::shouldAcquire (
|
||||
bool
|
||||
LedgerMaster::shouldAcquire (
|
||||
std::uint32_t const currentLedger,
|
||||
std::uint32_t const ledgerHistory,
|
||||
std::uint32_t const ledgerHistoryIndex,
|
||||
@@ -1639,7 +1585,7 @@ bool LedgerMasterImp::shouldAcquire (
|
||||
}
|
||||
|
||||
// Try to publish ledgers, acquire missing ledgers
|
||||
void LedgerMasterImp::doAdvance ()
|
||||
void LedgerMaster::doAdvance ()
|
||||
{
|
||||
// TODO NIKB: simplify and unindent this a bit!
|
||||
|
||||
@@ -1821,14 +1767,16 @@ void LedgerMasterImp::doAdvance ()
|
||||
} while (mAdvanceWork);
|
||||
}
|
||||
|
||||
void LedgerMasterImp::addFetchPack (
|
||||
void
|
||||
LedgerMaster::addFetchPack (
|
||||
uint256 const& hash,
|
||||
std::shared_ptr< Blob >& data)
|
||||
{
|
||||
fetch_packs_.canonicalize (hash, data);
|
||||
}
|
||||
|
||||
bool LedgerMasterImp::getFetchPack (
|
||||
bool
|
||||
LedgerMaster::getFetchPack (
|
||||
uint256 const& hash,
|
||||
Blob& data)
|
||||
{
|
||||
@@ -1840,7 +1788,8 @@ bool LedgerMasterImp::getFetchPack (
|
||||
return hash == sha512Half(makeSlice(data));
|
||||
}
|
||||
|
||||
void LedgerMasterImp::gotFetchPack (
|
||||
void
|
||||
LedgerMaster::gotFetchPack (
|
||||
bool progress,
|
||||
std::uint32_t seq)
|
||||
{
|
||||
@@ -1853,7 +1802,8 @@ void LedgerMasterImp::gotFetchPack (
|
||||
[&] (Job&) { app_.getInboundLedgers().gotFetchPack(); });
|
||||
}
|
||||
|
||||
void LedgerMasterImp::makeFetchPack (
|
||||
void
|
||||
LedgerMaster::makeFetchPack (
|
||||
std::weak_ptr<Peer> const& wPeer,
|
||||
std::shared_ptr<protocol::TMGetObjectByHash> const& request,
|
||||
uint256 haveLedgerHash,
|
||||
@@ -1992,28 +1942,10 @@ void LedgerMasterImp::makeFetchPack (
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t LedgerMasterImp::getFetchPackCacheSize () const
|
||||
std::size_t
|
||||
LedgerMaster::getFetchPackCacheSize () const
|
||||
{
|
||||
return fetch_packs_.getCacheSize ();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
LedgerMaster::LedgerMaster (Stoppable& parent)
|
||||
: Stoppable ("LedgerMaster", parent)
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<LedgerMaster>
|
||||
make_LedgerMaster (
|
||||
Application& app,
|
||||
Stopwatch& stopwatch,
|
||||
beast::Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector,
|
||||
beast::Journal journal)
|
||||
{
|
||||
return std::make_unique <LedgerMasterImp> (
|
||||
app, stopwatch, parent, collector, journal);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -416,7 +416,7 @@ public:
|
||||
, m_pathRequests (std::make_unique<PathRequests> (
|
||||
*this, logs_->journal("PathRequest"), m_collectorManager->collector ()))
|
||||
|
||||
, m_ledgerMaster (make_LedgerMaster (*this, stopwatch (),
|
||||
, m_ledgerMaster (std::make_unique<LedgerMaster> (*this, stopwatch (),
|
||||
*m_jobQueue, m_collectorManager->collector (),
|
||||
logs_->journal("LedgerMaster")))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user