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/beast/clock/abstract_clock.h>
24 #include <ripple/beast/utility/Journal.h>
25 #include <ripple/basics/chrono.h>
26 #include <string>
27 #include <vector>
28 
29 namespace ripple {
30 
33  : public beast::abstract_clock<NetClock>
34 {
35 public:
36  virtual ~TimeKeeper() = default;
37 
43  virtual
44  void
45  run (std::vector<std::string> const& servers) = 0;
46 
59  virtual
61  now() const override = 0;
62 
73  virtual
75  closeTime() const = 0;
76 
81  virtual
82  void
84 
85  // This may return a negative value
86  virtual
88  nowOffset() const = 0;
89 
90  // This may return a negative value
91  virtual
93  closeOffset() const = 0;
94 };
95 
96 extern
99 
100 } // ripple
101 
102 #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:60
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:129
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