rippled
Public Types | Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | List of all members
ripple::test::ManualTimeKeeper Class Referenceabstract
Inheritance diagram for ripple::test::ManualTimeKeeper:
Inheritance graph
[legend]
Collaboration diagram for ripple::test::ManualTimeKeeper:
Collaboration graph
[legend]

Public Types

using rep = typename NetClock ::rep
 
using period = typename NetClock ::period
 
using duration = typename NetClock ::duration
 
using time_point = typename NetClock ::time_point
 
using clock_type = NetClock
 

Public Member Functions

 ManualTimeKeeper ()
 
void run (std::vector< std::string > const &servers) override
 Launch the internal thread. More...
 
time_point now () const override
 Returns the estimate of wall time, in network time. More...
 
time_point closeTime () const override
 Returns the close time, in network time. More...
 
void adjustCloseTime (std::chrono::duration< std::int32_t > amount) override
 Adjust the close time. More...
 
std::chrono::duration< std::int32_tnowOffset () const override
 
std::chrono::duration< std::int32_tcloseOffset () const override
 
void set (time_point now)
 
virtual time_point now () const=0
 Returns the current time. More...
 

Static Public Attributes

static const bool is_steady
 

Static Private Member Functions

static time_point adjust (std::chrono::system_clock::time_point when)
 

Private Attributes

std::mutex mutex_
 
std::chrono::duration< std::int32_tcloseOffset_
 
time_point now_
 

Detailed Description

Definition at line 29 of file ManualTimeKeeper.h.

Member Typedef Documentation

◆ rep

using beast::abstract_clock< NetClock >::rep = typename NetClock ::rep
inherited

Definition at line 60 of file abstract_clock.h.

◆ period

using beast::abstract_clock< NetClock >::period = typename NetClock ::period
inherited

Definition at line 61 of file abstract_clock.h.

◆ duration

using beast::abstract_clock< NetClock >::duration = typename NetClock ::duration
inherited

Definition at line 62 of file abstract_clock.h.

◆ time_point

using beast::abstract_clock< NetClock >::time_point = typename NetClock ::time_point
inherited

Definition at line 63 of file abstract_clock.h.

◆ clock_type

Definition at line 64 of file abstract_clock.h.

Constructor & Destructor Documentation

◆ ManualTimeKeeper()

ripple::test::ManualTimeKeeper::ManualTimeKeeper ( )

Definition at line 27 of file ManualTimeKeeper.cpp.

Member Function Documentation

◆ run()

void ripple::test::ManualTimeKeeper::run ( std::vector< std::string > const &  servers)
overridevirtual

Launch the internal thread.

The internal thread synchronizes local network time using the provided list of SNTP servers.

Implements ripple::TimeKeeper.

Definition at line 32 of file ManualTimeKeeper.cpp.

◆ now() [1/2]

auto ripple::test::ManualTimeKeeper::now ( ) const
overridevirtual

Returns the estimate of wall time, in network time.

The network time is wall time adjusted for the Ripple epoch, the beginning of January 1st, 2000 UTC. Each server can compute a different value for network time. Other servers value for network time is not directly observable, but good guesses can be made by looking at validators' positions on close times.

Servers compute network time by adjusting a local wall clock using SNTP and then adjusting for the epoch.

Implements ripple::TimeKeeper.

Definition at line 37 of file ManualTimeKeeper.cpp.

◆ closeTime()

auto ripple::test::ManualTimeKeeper::closeTime ( ) const
overridevirtual

Returns the close time, in network time.

Close time is the time the network would agree that a ledger closed, if a ledger closed right now.

The close time represents the notional "center" of the network. Each server assumes its clock is correct, and tries to pull the close time towards its measure of network time.

Implements ripple::TimeKeeper.

Definition at line 44 of file ManualTimeKeeper.cpp.

◆ adjustCloseTime()

void ripple::test::ManualTimeKeeper::adjustCloseTime ( std::chrono::duration< std::int32_t amount)
overridevirtual

Adjust the close time.

This is called in response to received validations.

Implements ripple::TimeKeeper.

Definition at line 51 of file ManualTimeKeeper.cpp.

◆ nowOffset()

std::chrono::duration< std::int32_t > ripple::test::ManualTimeKeeper::nowOffset ( ) const
overridevirtual

Implements ripple::TimeKeeper.

Definition at line 68 of file ManualTimeKeeper.cpp.

◆ closeOffset()

std::chrono::duration< std::int32_t > ripple::test::ManualTimeKeeper::closeOffset ( ) const
overridevirtual

Implements ripple::TimeKeeper.

Definition at line 74 of file ManualTimeKeeper.cpp.

◆ set()

void ripple::test::ManualTimeKeeper::set ( time_point  now)

Definition at line 81 of file ManualTimeKeeper.cpp.

◆ adjust()

auto ripple::test::ManualTimeKeeper::adjust ( std::chrono::system_clock::time_point  when)
staticprivate

Definition at line 88 of file ManualTimeKeeper.cpp.

◆ now() [2/2]

virtual time_point beast::abstract_clock< NetClock >::now ( ) const
pure virtualinherited

Returns the current time.

Member Data Documentation

◆ mutex_

std::mutex ripple::test::ManualTimeKeeper::mutex_
mutableprivate

Definition at line 60 of file ManualTimeKeeper.h.

◆ closeOffset_

std::chrono::duration<std::int32_t> ripple::test::ManualTimeKeeper::closeOffset_
private

Definition at line 61 of file ManualTimeKeeper.h.

◆ now_

time_point ripple::test::ManualTimeKeeper::now_
private

Definition at line 62 of file ManualTimeKeeper.h.

◆ is_steady

const bool beast::abstract_clock< NetClock >::is_steady
staticinherited

Definition at line 66 of file abstract_clock.h.