mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-23 20:45:51 +00:00
Refactor clock declarations in chrono.h
This commit is contained in:
@@ -1897,6 +1897,8 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\CheckLibraryVersions.h">
|
<ClInclude Include="..\..\src\ripple\basics\CheckLibraryVersions.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\basics\chrono.h">
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\contract.h">
|
<ClInclude Include="..\..\src\ripple\basics\contract.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\CountedObject.h">
|
<ClInclude Include="..\..\src\ripple\basics\CountedObject.h">
|
||||||
@@ -1981,8 +1983,6 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\ResolverAsio.h">
|
<ClInclude Include="..\..\src\ripple\basics\ResolverAsio.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\seconds_clock.h">
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\ripple\basics\SHA512Half.h">
|
<ClInclude Include="..\..\src\ripple\basics\SHA512Half.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\Slice.h">
|
<ClInclude Include="..\..\src\ripple\basics\Slice.h">
|
||||||
|
|||||||
@@ -2637,6 +2637,9 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\basics\CheckLibraryVersions.h">
|
<ClInclude Include="..\..\src\ripple\basics\CheckLibraryVersions.h">
|
||||||
<Filter>ripple\basics</Filter>
|
<Filter>ripple\basics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ripple\basics\chrono.h">
|
||||||
|
<Filter>ripple\basics</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\contract.h">
|
<ClInclude Include="..\..\src\ripple\basics\contract.h">
|
||||||
<Filter>ripple\basics</Filter>
|
<Filter>ripple\basics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -2718,9 +2721,6 @@
|
|||||||
<ClInclude Include="..\..\src\ripple\basics\ResolverAsio.h">
|
<ClInclude Include="..\..\src\ripple\basics\ResolverAsio.h">
|
||||||
<Filter>ripple\basics</Filter>
|
<Filter>ripple\basics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ripple\basics\seconds_clock.h">
|
|
||||||
<Filter>ripple\basics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\ripple\basics\SHA512Half.h">
|
<ClInclude Include="..\..\src\ripple\basics\SHA512Half.h">
|
||||||
<Filter>ripple\basics</Filter>
|
<Filter>ripple\basics</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/app/ledger/AcceptedLedger.h>
|
#include <ripple/app/ledger/AcceptedLedger.h>
|
||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ namespace ripple {
|
|||||||
// Use a dependency injection to give AcceptedLedger access.
|
// Use a dependency injection to give AcceptedLedger access.
|
||||||
//
|
//
|
||||||
TaggedCache <uint256, AcceptedLedger> AcceptedLedger::s_cache (
|
TaggedCache <uint256, AcceptedLedger> AcceptedLedger::s_cache (
|
||||||
"AcceptedLedger", 4, 60, get_seconds_clock (),
|
"AcceptedLedger", 4, 60, stopwatch(),
|
||||||
deprecatedLogs().journal("TaggedCache"));
|
deprecatedLogs().journal("TaggedCache"));
|
||||||
|
|
||||||
AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
|
AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/app/ledger/LedgerHistory.h>
|
#include <ripple/app/ledger/LedgerHistory.h>
|
||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/json/to_string.h>
|
#include <ripple/json/to_string.h>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
@@ -42,9 +42,9 @@ LedgerHistory::LedgerHistory (
|
|||||||
: collector_ (collector)
|
: collector_ (collector)
|
||||||
, mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch"))
|
, mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch"))
|
||||||
, m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
|
, m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
|
||||||
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
|
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||||
, m_consensus_validated ("ConsensusValidated", 64, 300,
|
, m_consensus_validated ("ConsensusValidated", 64, 300,
|
||||||
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
|
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <ripple/app/ledger/LedgerTiming.h>
|
#include <ripple/app/ledger/LedgerTiming.h>
|
||||||
#include <ripple/app/misc/CanonicalTXSet.h>
|
#include <ripple/app/misc/CanonicalTXSet.h>
|
||||||
#include <ripple/app/tx/impl/Transactor.h>
|
#include <ripple/app/tx/impl/Transactor.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/crypto/KeyType.h>
|
#include <ripple/crypto/KeyType.h>
|
||||||
#include <ripple/json/json_value.h>
|
#include <ripple/json/json_value.h>
|
||||||
#include <ripple/protocol/JsonFields.h>
|
#include <ripple/protocol/JsonFields.h>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/ResolverAsio.h>
|
#include <ripple/basics/ResolverAsio.h>
|
||||||
#include <ripple/basics/Sustain.h>
|
#include <ripple/basics/Sustain.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/json/json_reader.h>
|
#include <ripple/json/json_reader.h>
|
||||||
#include <ripple/json/to_string.h>
|
#include <ripple/json/to_string.h>
|
||||||
#include <ripple/core/LoadFeeTrack.h>
|
#include <ripple/core/LoadFeeTrack.h>
|
||||||
@@ -121,9 +121,9 @@ public:
|
|||||||
|
|
||||||
AppFamily (NodeStore::Database& db,
|
AppFamily (NodeStore::Database& db,
|
||||||
CollectorManager& collectorManager)
|
CollectorManager& collectorManager)
|
||||||
: treecache_ ("TreeNodeCache", 65536, 60, get_seconds_clock(),
|
: treecache_ ("TreeNodeCache", 65536, 60, stopwatch(),
|
||||||
deprecatedLogs().journal("TaggedCache"))
|
deprecatedLogs().journal("TaggedCache"))
|
||||||
, fullbelow_ ("full_below", get_seconds_clock(),
|
, fullbelow_ ("full_below", stopwatch(),
|
||||||
collectorManager.collector(),
|
collectorManager.collector(),
|
||||||
fullBelowTargetSize, fullBelowExpirationSeconds)
|
fullBelowTargetSize, fullBelowExpirationSeconds)
|
||||||
, db_ (db)
|
, db_ (db)
|
||||||
@@ -338,7 +338,7 @@ public:
|
|||||||
|
|
||||||
, accountIDCache_(128000)
|
, accountIDCache_(128000)
|
||||||
|
|
||||||
, m_tempNodeCache ("NodeCache", 16384, 90, get_seconds_clock (),
|
, m_tempNodeCache ("NodeCache", 16384, 90, stopwatch(),
|
||||||
m_logs.journal("TaggedCache"))
|
m_logs.journal("TaggedCache"))
|
||||||
|
|
||||||
, m_collectorManager (CollectorManager::New (
|
, m_collectorManager (CollectorManager::New (
|
||||||
@@ -346,7 +346,7 @@ public:
|
|||||||
|
|
||||||
, family_ (*m_nodeStore, *m_collectorManager)
|
, family_ (*m_nodeStore, *m_collectorManager)
|
||||||
|
|
||||||
, m_sleCache ("LedgerEntryCache", 4096, 120, get_seconds_clock (),
|
, m_sleCache ("LedgerEntryCache", 4096, 120, stopwatch(),
|
||||||
m_logs.journal("TaggedCache"))
|
m_logs.journal("TaggedCache"))
|
||||||
|
|
||||||
, m_resourceManager (Resource::make_Manager (
|
, m_resourceManager (Resource::make_Manager (
|
||||||
@@ -375,11 +375,11 @@ public:
|
|||||||
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
||||||
// to dependencies in the destructor.
|
// to dependencies in the destructor.
|
||||||
//
|
//
|
||||||
, m_inboundLedgers (make_InboundLedgers (get_seconds_clock (),
|
, m_inboundLedgers (make_InboundLedgers (stopwatch(),
|
||||||
*m_jobQueue, m_collectorManager->collector ()))
|
*m_jobQueue, m_collectorManager->collector ()))
|
||||||
|
|
||||||
, m_inboundTransactions (make_InboundTransactions
|
, m_inboundTransactions (make_InboundTransactions
|
||||||
( get_seconds_clock ()
|
( stopwatch()
|
||||||
, *m_jobQueue
|
, *m_jobQueue
|
||||||
, m_collectorManager->collector ()
|
, m_collectorManager->collector ()
|
||||||
, [this](uint256 const& setHash,
|
, [this](uint256 const& setHash,
|
||||||
@@ -388,7 +388,7 @@ public:
|
|||||||
gotTXSet (setHash, set);
|
gotTXSet (setHash, set);
|
||||||
}))
|
}))
|
||||||
|
|
||||||
, m_networkOPs (make_NetworkOPs (get_seconds_clock (),
|
, m_networkOPs (make_NetworkOPs (stopwatch(),
|
||||||
getConfig ().RUN_STANDALONE, getConfig ().NETWORK_QUORUM,
|
getConfig ().RUN_STANDALONE, getConfig ().NETWORK_QUORUM,
|
||||||
*m_jobQueue, *m_ledgerMaster, *m_jobQueue,
|
*m_jobQueue, *m_ledgerMaster, *m_jobQueue,
|
||||||
m_logs.journal("NetworkOPs")))
|
m_logs.journal("NetworkOPs")))
|
||||||
@@ -1239,7 +1239,7 @@ bool ApplicationImp::loadOldLedger (
|
|||||||
{
|
{
|
||||||
// Try to build the ledger from the back end
|
// Try to build the ledger from the back end
|
||||||
auto il = std::make_shared <InboundLedger> (hash, 0, InboundLedger::fcGENERIC,
|
auto il = std::make_shared <InboundLedger> (hash, 0, InboundLedger::fcGENERIC,
|
||||||
get_seconds_clock ());
|
stopwatch());
|
||||||
if (il->checkLocal ())
|
if (il->checkLocal ())
|
||||||
loadLedger = il->getLedger ();
|
loadLedger = il->getLedger ();
|
||||||
}
|
}
|
||||||
@@ -1273,7 +1273,7 @@ bool ApplicationImp::loadOldLedger (
|
|||||||
// Try to build the ledger from the back end
|
// Try to build the ledger from the back end
|
||||||
auto il = std::make_shared <InboundLedger> (
|
auto il = std::make_shared <InboundLedger> (
|
||||||
replayLedger->getParentHash(), 0, InboundLedger::fcGENERIC,
|
replayLedger->getParentHash(), 0, InboundLedger::fcGENERIC,
|
||||||
get_seconds_clock ());
|
stopwatch());
|
||||||
if (il->checkLocal ())
|
if (il->checkLocal ())
|
||||||
loadLedger = il->getLedger ();
|
loadLedger = il->getLedger ();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <ripple/app/misc/UniqueNodeList.h>
|
#include <ripple/app/misc/UniqueNodeList.h>
|
||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/StringUtilities.h>
|
#include <ripple/basics/StringUtilities.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/core/JobQueue.h>
|
#include <ripple/core/JobQueue.h>
|
||||||
#include <beast/cxx14/memory.h> // <memory>
|
#include <beast/cxx14/memory.h> // <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@@ -70,7 +70,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ValidationsImp ()
|
ValidationsImp ()
|
||||||
: mValidations ("Validations", 128, 600, get_seconds_clock (),
|
: mValidations ("Validations", 128, 600, stopwatch(),
|
||||||
deprecatedLogs().journal("TaggedCache"))
|
deprecatedLogs().journal("TaggedCache"))
|
||||||
, mWriting (false)
|
, mWriting (false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <ripple/app/misc/AmendmentTable.h>
|
#include <ripple/app/misc/AmendmentTable.h>
|
||||||
#include <ripple/basics/BasicConfig.h>
|
#include <ripple/basics/BasicConfig.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/core/ConfigSections.h>
|
#include <ripple/core/ConfigSections.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,12 @@
|
|||||||
#include <ripple/app/tx/TransactionMaster.h>
|
#include <ripple/app/tx/TransactionMaster.h>
|
||||||
#include <ripple/app/main/Application.h>
|
#include <ripple/app/main/Application.h>
|
||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
TransactionMaster::TransactionMaster ()
|
TransactionMaster::TransactionMaster ()
|
||||||
: mCache ("TransactionCache", 65536, 1800, get_seconds_clock (),
|
: mCache ("TransactionCache", 65536, 1800, stopwatch(),
|
||||||
deprecatedLogs().journal("TaggedCache"))
|
deprecatedLogs().journal("TaggedCache"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include <ripple/app/ledger/LedgerTiming.h>
|
#include <ripple/app/ledger/LedgerTiming.h>
|
||||||
#include <ripple/app/ledger/tests/common_ledger.h>
|
#include <ripple/app/ledger/tests/common_ledger.h>
|
||||||
#include <ripple/app/tx/apply.h>
|
#include <ripple/app/tx/apply.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/protocol/TxFormats.h>
|
#include <ripple/protocol/TxFormats.h>
|
||||||
#include <ripple/protocol/TxFlags.h>
|
#include <ripple/protocol/TxFlags.h>
|
||||||
|
|
||||||
|
|||||||
96
src/ripple/basics/chrono.h
Normal file
96
src/ripple/basics/chrono.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
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_BASICS_CHRONO_H_INCLUDED
|
||||||
|
#define RIPPLE_BASICS_CHRONO_H_INCLUDED
|
||||||
|
|
||||||
|
#include <beast/chrono/abstract_clock.h>
|
||||||
|
#include <beast/chrono/basic_seconds_clock.h>
|
||||||
|
#include <beast/chrono/manual_clock.h>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace ripple {
|
||||||
|
|
||||||
|
// A few handy aliases
|
||||||
|
|
||||||
|
using days = std::chrono::duration
|
||||||
|
<int, std::ratio_multiply<
|
||||||
|
std::chrono::hours::period,
|
||||||
|
std::ratio<24>>>;
|
||||||
|
|
||||||
|
using weeks = std::chrono::duration
|
||||||
|
<int, std::ratio_multiply<
|
||||||
|
days::period, std::ratio<7>>>;
|
||||||
|
|
||||||
|
/** A clock for measuring elapsed time.
|
||||||
|
|
||||||
|
The epoch is unspecified.
|
||||||
|
*/
|
||||||
|
using Stopwatch =
|
||||||
|
beast::abstract_clock<
|
||||||
|
std::chrono::steady_clock>;
|
||||||
|
|
||||||
|
/** A manual clock for unit tests. */
|
||||||
|
using TestClock =
|
||||||
|
beast::manual_clock<
|
||||||
|
Stopwatch::clock_type>;
|
||||||
|
|
||||||
|
/** Clock for measuring Ripple Network Time.
|
||||||
|
|
||||||
|
The epoch is January 1, 2000
|
||||||
|
*/
|
||||||
|
// VFALCO TODO Finish the implementation and make
|
||||||
|
// the network clock instance a member
|
||||||
|
// of the Application object
|
||||||
|
//
|
||||||
|
// epoch_offset = days(10957); // 2000-01-01
|
||||||
|
//
|
||||||
|
class NetClock // : public abstract_clock <std::chrono::seconds>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Unfortunately this is signed for legacy reasons
|
||||||
|
using rep = std::int32_t;
|
||||||
|
|
||||||
|
using period = std::ratio<1>;
|
||||||
|
|
||||||
|
using duration =
|
||||||
|
std::chrono::duration<rep, period>;
|
||||||
|
|
||||||
|
using time_point =
|
||||||
|
std::chrono::time_point<
|
||||||
|
NetClock, duration>;
|
||||||
|
|
||||||
|
// VFALCO now() intentionally omitted for the moment
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Returns an instance of a wall clock. */
|
||||||
|
inline
|
||||||
|
Stopwatch&
|
||||||
|
stopwatch()
|
||||||
|
{
|
||||||
|
return beast::get_abstract_clock<
|
||||||
|
std::chrono::steady_clock,
|
||||||
|
beast::basic_seconds_clock<
|
||||||
|
std::chrono::steady_clock>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ripple
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/basics/make_SSLContext.h>
|
#include <ripple/basics/make_SSLContext.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <beast/container/aged_unordered_set.h>
|
#include <beast/container/aged_unordered_set.h>
|
||||||
#include <beast/module/core/diagnostic/FatalError.h>
|
#include <beast/module/core/diagnostic/FatalError.h>
|
||||||
#include <beast/utility/static_initializer.h>
|
#include <beast/utility/static_initializer.h>
|
||||||
@@ -175,7 +175,7 @@ struct StaticData
|
|||||||
beast::aged_unordered_set <SSL const*> set;
|
beast::aged_unordered_set <SSL const*> set;
|
||||||
|
|
||||||
StaticData()
|
StaticData()
|
||||||
: set (ripple::get_seconds_clock ())
|
: set (ripple::stopwatch())
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +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_BASICS_SECONDS_CLOCK_H_INCLUDED
|
|
||||||
#define RIPPLE_BASICS_SECONDS_CLOCK_H_INCLUDED
|
|
||||||
|
|
||||||
#include <beast/chrono/abstract_clock.h>
|
|
||||||
#include <beast/chrono/basic_seconds_clock.h>
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
namespace ripple {
|
|
||||||
|
|
||||||
using days = std::chrono::duration
|
|
||||||
<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>>;
|
|
||||||
|
|
||||||
using weeks = std::chrono::duration
|
|
||||||
<int, std::ratio_multiply<days::period, std::ratio<7>>>;
|
|
||||||
|
|
||||||
/** Returns an abstract_clock optimized for counting seconds. */
|
|
||||||
inline
|
|
||||||
beast::abstract_clock<std::chrono::steady_clock>&
|
|
||||||
get_seconds_clock()
|
|
||||||
{
|
|
||||||
return beast::get_abstract_clock<std::chrono::steady_clock,
|
|
||||||
beast::basic_seconds_clock<std::chrono::steady_clock>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/KeyCache.h>
|
#include <ripple/basics/KeyCache.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
#include <beast/chrono/manual_clock.h>
|
||||||
@@ -29,7 +30,7 @@ class KeyCache_test : public beast::unit_test::suite
|
|||||||
public:
|
public:
|
||||||
void run ()
|
void run ()
|
||||||
{
|
{
|
||||||
beast::manual_clock <std::chrono::steady_clock> clock;
|
TestClock clock;
|
||||||
clock.set (0);
|
clock.set (0);
|
||||||
|
|
||||||
using Key = std::string;
|
using Key = std::string;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/TaggedCache.h>
|
#include <ripple/basics/TaggedCache.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
#include <beast/chrono/manual_clock.h>
|
||||||
@@ -41,7 +42,7 @@ public:
|
|||||||
{
|
{
|
||||||
beast::Journal const j;
|
beast::Journal const j;
|
||||||
|
|
||||||
beast::manual_clock <std::chrono::steady_clock> clock;
|
TestClock clock;
|
||||||
clock.set (0);
|
clock.set (0);
|
||||||
|
|
||||||
using Key = int;
|
using Key = int;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <ripple/nodestore/impl/Tuning.h>
|
#include <ripple/nodestore/impl/Tuning.h>
|
||||||
#include <ripple/basics/KeyCache.h>
|
#include <ripple/basics/KeyCache.h>
|
||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/SHA512Half.h>
|
#include <ripple/basics/SHA512Half.h>
|
||||||
#include <ripple/basics/Slice.h>
|
#include <ripple/basics/Slice.h>
|
||||||
#include <ripple/basics/TaggedCache.h>
|
#include <ripple/basics/TaggedCache.h>
|
||||||
@@ -72,8 +72,8 @@ public:
|
|||||||
, m_scheduler (scheduler)
|
, m_scheduler (scheduler)
|
||||||
, m_backend (std::move (backend))
|
, m_backend (std::move (backend))
|
||||||
, m_cache ("NodeStore", cacheTargetSize, cacheTargetSeconds,
|
, m_cache ("NodeStore", cacheTargetSize, cacheTargetSeconds,
|
||||||
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
|
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||||
, m_negCache ("NodeStore", get_seconds_clock (),
|
, m_negCache ("NodeStore", stopwatch(),
|
||||||
cacheTargetSize, cacheTargetSeconds)
|
cacheTargetSize, cacheTargetSeconds)
|
||||||
, m_readShut (false)
|
, m_readShut (false)
|
||||||
, m_readGen (0)
|
, m_readGen (0)
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ OverlayImpl::OverlayImpl (
|
|||||||
, serverHandler_(serverHandler)
|
, serverHandler_(serverHandler)
|
||||||
, m_resourceManager (resourceManager)
|
, m_resourceManager (resourceManager)
|
||||||
, m_peerFinder (PeerFinder::make_Manager (*this, io_service,
|
, m_peerFinder (PeerFinder::make_Manager (*this, io_service,
|
||||||
get_seconds_clock(), deprecatedLogs().journal("PeerFinder"), config))
|
stopwatch(), deprecatedLogs().journal("PeerFinder"), config))
|
||||||
, m_resolver (resolver)
|
, m_resolver (resolver)
|
||||||
, next_id_(1)
|
, next_id_(1)
|
||||||
, timer_count_(0)
|
, timer_count_(0)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <ripple/server/Handoff.h>
|
#include <ripple/server/Handoff.h>
|
||||||
#include <ripple/server/ServerHandler.h>
|
#include <ripple/server/ServerHandler.h>
|
||||||
#include <ripple/basics/Resolver.h>
|
#include <ripple/basics/Resolver.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/UnorderedContainers.h>
|
#include <ripple/basics/UnorderedContainers.h>
|
||||||
#include <ripple/peerfinder/Manager.h>
|
#include <ripple/peerfinder/Manager.h>
|
||||||
#include <ripple/resource/Manager.h>
|
#include <ripple/resource/Manager.h>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ private:
|
|||||||
Params m_params;
|
Params m_params;
|
||||||
Journal m_journal;
|
Journal m_journal;
|
||||||
int m_next_node_id;
|
int m_next_node_id;
|
||||||
manual_clock <std::chrono::seconds> m_clock;
|
TestClock m_clock;
|
||||||
Peers m_nodes;
|
Peers m_nodes;
|
||||||
Table m_table;
|
Table m_table;
|
||||||
FunctionQueue m_queue;
|
FunctionQueue m_queue;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/peerfinder/impl/Livecache.h>
|
#include <ripple/peerfinder/impl/Livecache.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
#include <beast/chrono/manual_clock.h>
|
||||||
@@ -28,7 +29,7 @@ namespace PeerFinder {
|
|||||||
class Livecache_test : public beast::unit_test::suite
|
class Livecache_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
beast::manual_clock <std::chrono::steady_clock> m_clock;
|
TestClock m_clock;
|
||||||
|
|
||||||
// Add the address as an endpoint
|
// Add the address as an endpoint
|
||||||
template <class C>
|
template <class C>
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/peerfinder/impl/Logic.h>
|
#include <ripple/peerfinder/impl/Logic.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
namespace PeerFinder {
|
namespace PeerFinder {
|
||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
testcase("backoff 1");
|
testcase("backoff 1");
|
||||||
TestStore store;
|
TestStore store;
|
||||||
TestChecker checker;
|
TestChecker checker;
|
||||||
beast::manual_clock <std::chrono::steady_clock> clock;
|
TestClock clock;
|
||||||
Logic<TestChecker> logic (clock, store, checker, beast::Journal{});
|
Logic<TestChecker> logic (clock, store, checker, beast::Journal{});
|
||||||
logic.addFixedPeer ("test",
|
logic.addFixedPeer ("test",
|
||||||
beast::IP::Endpoint::from_string("65.0.0.1:5"));
|
beast::IP::Endpoint::from_string("65.0.0.1:5"));
|
||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
testcase("backoff 2");
|
testcase("backoff 2");
|
||||||
TestStore store;
|
TestStore store;
|
||||||
TestChecker checker;
|
TestChecker checker;
|
||||||
beast::manual_clock <std::chrono::steady_clock> clock;
|
TestClock clock;
|
||||||
Logic<TestChecker> logic (clock, store, checker, beast::Journal{});
|
Logic<TestChecker> logic (clock, store, checker, beast::Journal{});
|
||||||
logic.addFixedPeer ("test",
|
logic.addFixedPeer ("test",
|
||||||
beast::IP::Endpoint::from_string("65.0.0.1:5"));
|
beast::IP::Endpoint::from_string("65.0.0.1:5"));
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/resource/Manager.h>
|
#include <ripple/resource/Manager.h>
|
||||||
#include <beast/threads/Thread.h>
|
#include <beast/threads/Thread.h>
|
||||||
#include <beast/cxx14/memory.h> // <memory>
|
#include <beast/cxx14/memory.h> // <memory>
|
||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
beast::Journal journal)
|
beast::Journal journal)
|
||||||
: Thread ("Resource::Manager")
|
: Thread ("Resource::Manager")
|
||||||
, m_journal (journal)
|
, m_journal (journal)
|
||||||
, m_logic (collector, get_seconds_clock (), journal)
|
, m_logic (collector, stopwatch(), journal)
|
||||||
{
|
{
|
||||||
startThread ();
|
startThread ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/basics/chrono.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/chrono/chrono_io.h>
|
#include <beast/chrono/chrono_io.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
|
||||||
#include <beast/module/core/maths/Random.h>
|
#include <beast/module/core/maths/Random.h>
|
||||||
#include <boost/utility/base_from_member.hpp>
|
#include <boost/utility/base_from_member.hpp>
|
||||||
|
|
||||||
@@ -31,14 +31,13 @@ class Manager_test : public beast::unit_test::suite
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class TestLogic
|
class TestLogic
|
||||||
: private boost::base_from_member <
|
: private boost::base_from_member<TestClock>
|
||||||
beast::manual_clock <std::chrono::steady_clock>>
|
|
||||||
, public Logic
|
, public Logic
|
||||||
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using clock_type = boost::base_from_member <
|
using clock_type =
|
||||||
beast::manual_clock <std::chrono::steady_clock>>;
|
boost::base_from_member<TestClock>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TestLogic (beast::Journal journal)
|
explicit TestLogic (beast::Journal journal)
|
||||||
@@ -51,7 +50,7 @@ public:
|
|||||||
++member;
|
++member;
|
||||||
}
|
}
|
||||||
|
|
||||||
beast::manual_clock <std::chrono::steady_clock>& clock ()
|
TestClock& clock ()
|
||||||
{
|
{
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#ifndef RIPPLE_SERVER_SERVERIMPL_H_INCLUDED
|
#ifndef RIPPLE_SERVER_SERVERIMPL_H_INCLUDED
|
||||||
#define RIPPLE_SERVER_SERVERIMPL_H_INCLUDED
|
#define RIPPLE_SERVER_SERVERIMPL_H_INCLUDED
|
||||||
|
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/server/Handler.h>
|
#include <ripple/server/Handler.h>
|
||||||
#include <ripple/server/Server.h>
|
#include <ripple/server/Server.h>
|
||||||
#include <beast/intrusive/List.h>
|
#include <beast/intrusive/List.h>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/shamap/SHAMap.h>
|
#include <ripple/shamap/SHAMap.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#define RIPPLE_SHAMAP_TESTS_COMMON_H_INCLUDED
|
#define RIPPLE_SHAMAP_TESTS_COMMON_H_INCLUDED
|
||||||
|
|
||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/shamap/Family.h>
|
#include <ripple/shamap/Family.h>
|
||||||
#include <ripple/shamap/FullBelowCache.h>
|
#include <ripple/shamap/FullBelowCache.h>
|
||||||
#include <ripple/shamap/TreeNodeCache.h>
|
#include <ripple/shamap/TreeNodeCache.h>
|
||||||
@@ -38,8 +39,7 @@ namespace tests {
|
|||||||
class TestFamily : public shamap::Family
|
class TestFamily : public shamap::Family
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
beast::manual_clock <
|
TestClock clock_;
|
||||||
std::chrono::steady_clock> clock_;
|
|
||||||
NodeStore::DummyScheduler scheduler_;
|
NodeStore::DummyScheduler scheduler_;
|
||||||
TreeNodeCache treecache_;
|
TreeNodeCache treecache_;
|
||||||
FullBelowCache fullbelow_;
|
FullBelowCache fullbelow_;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Validators {
|
|||||||
Logic::Logic (Store& store, beast::Journal journal)
|
Logic::Logic (Store& store, beast::Journal journal)
|
||||||
: /*store_ (store)
|
: /*store_ (store)
|
||||||
, */journal_ (journal)
|
, */journal_ (journal)
|
||||||
, ledgers_(get_seconds_clock())
|
, ledgers_(stopwatch())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,10 @@
|
|||||||
|
|
||||||
#include <ripple/protocol/Protocol.h>
|
#include <ripple/protocol/Protocol.h>
|
||||||
#include <ripple/basics/hardened_hash.h>
|
#include <ripple/basics/hardened_hash.h>
|
||||||
#include <ripple/basics/seconds_clock.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/protocol/RippleLedgerHash.h>
|
#include <ripple/protocol/RippleLedgerHash.h>
|
||||||
#include <ripple/validators/impl/Store.h>
|
#include <ripple/validators/impl/Store.h>
|
||||||
#include <ripple/validators/impl/Tuning.h>
|
#include <ripple/validators/impl/Tuning.h>
|
||||||
#include <beast/chrono/manual_clock.h>
|
|
||||||
#include <beast/container/aged_container_utility.h>
|
#include <beast/container/aged_container_utility.h>
|
||||||
#include <beast/container/aged_unordered_map.h>
|
#include <beast/container/aged_unordered_map.h>
|
||||||
#include <beast/container/aged_unordered_set.h>
|
#include <beast/container/aged_unordered_set.h>
|
||||||
@@ -43,9 +42,6 @@ class ConnectionImp;
|
|||||||
|
|
||||||
class Logic
|
class Logic
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
using clock_type = beast::abstract_clock<std::chrono::steady_clock>;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct LedgerMeta
|
struct LedgerMeta
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public:
|
|||||||
newConnection (int id) override
|
newConnection (int id) override
|
||||||
{
|
{
|
||||||
return std::make_unique<ConnectionImp>(
|
return std::make_unique<ConnectionImp>(
|
||||||
id, logic_, get_seconds_clock());
|
id, logic_, stopwatch());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user