rippled
TimeKeeper.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_CORE_TIMEKEEPER_H_INCLUDED
21 #define RIPPLE_CORE_TIMEKEEPER_H_INCLUDED
22 
23 #include <ripple/basics/chrono.h>
24 #include <ripple/beast/clock/abstract_clock.h>
25 #include <ripple/beast/utility/Journal.h>
26 #include <string>
27 #include <vector>
28 
29 namespace ripple {
30 
32 class TimeKeeper : public beast::abstract_clock<NetClock>
33 {
34 public:
35  virtual ~TimeKeeper() = default;
36 
42  virtual void
43  run(std::vector<std::string> const& servers) = 0;
44 
57  virtual time_point
58  now() const override = 0;
59 
70  virtual time_point
71  closeTime() const = 0;
72 
77  virtual void
79 
80  // This may return a negative value
82  nowOffset() const = 0;
83 
84  // This may return a negative value
86  closeOffset() const = 0;
87 };
88 
91 
92 } // namespace ripple
93 
94 #endif
ripple::TimeKeeper::nowOffset
virtual std::chrono::duration< std::int32_t > nowOffset() const =0
ripple::TimeKeeper::adjustCloseTime
virtual void adjustCloseTime(std::chrono::duration< std::int32_t > amount)=0
Adjust the close time.
ripple::TimeKeeper::run
virtual void run(std::vector< std::string > const &servers)=0
Launch the internal thread.
vector
std::chrono::duration< std::int32_t >
ripple::TimeKeeper::closeTime
virtual time_point closeTime() const =0
Returns the close time, in network time.
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::TimeKeeper
Manages various times used by the server.
Definition: TimeKeeper.h:32
beast::abstract_clock
Abstract interface to a clock.
Definition: abstract_clock.h:57
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::TimeKeeper::~TimeKeeper
virtual ~TimeKeeper()=default
ripple::make_TimeKeeper
std::unique_ptr< TimeKeeper > make_TimeKeeper(beast::Journal j)
Definition: TimeKeeper.cpp:119
ripple::TimeKeeper::now
virtual time_point now() const override=0
Returns the estimate of wall time, in network time.
std::unique_ptr
STL class.
beast::abstract_clock< NetClock >::time_point
typename NetClock ::time_point time_point
Definition: abstract_clock.h:63
ripple::TimeKeeper::closeOffset
virtual std::chrono::duration< std::int32_t > closeOffset() const =0
string