CatapultServer  v0.5.0.1 (Elephant)
TimeSynchronizationState.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "types.h"
23 #include <atomic>
24 
25 namespace catapult { namespace timesync {
26 
28  enum class TimeOffsetDirection : uint8_t {
30  Positive = 0,
31 
33  Negative = 1
34  };
35 
38  public:
41  explicit TimeSynchronizationState(uint64_t clockAdjustmentThreshold);
42 
43  public:
45  TimeOffset offset() const;
46 
48  uint64_t absoluteOffset() const;
49 
52 
54  NodeAge nodeAge() const;
55 
56  public:
58  Timestamp networkTime() const;
59 
61  void update(TimeOffset offset);
62 
63  private:
65  std::atomic<int64_t> m_offset;
66  std::atomic<int64_t> m_nodeAge;
67  };
68 }}
m_offset
size_t m_offset
Definition: BlockElementParser.cpp:64
constants.h
catapult::timesync::TimeOffsetDirection::Positive
Time offset is in positive direction.
catapult::timesync::TimeSynchronizationState::update
void update(TimeOffset offset)
Updates the current offset using offset.
Definition: TimeSynchronizationState.cpp:54
catapult::timesync::TimeOffsetDirection
TimeOffsetDirection
Direction of a time offset.
Definition: TimeSynchronizationState.h:28
catapult::timesync::TimeSynchronizationState::TimeSynchronizationState
TimeSynchronizationState(uint64_t clockAdjustmentThreshold)
Definition: TimeSynchronizationState.cpp:28
catapult::timesync::TimeSynchronizationState::networkTime
Timestamp networkTime() const
Gets the network time.
Definition: TimeSynchronizationState.cpp:50
catapult::timesync::TimeSynchronizationState::m_clockAdjustmentThreshold
uint64_t m_clockAdjustmentThreshold
Definition: TimeSynchronizationState.h:64
catapult::utils::BasicBaseValue::unwrap
constexpr ValueType unwrap() const
Unwraps this value and returns the underlying raw value.
Definition: BaseValue.h:53
catapult::timesync::NodeAge
utils::BaseValue< int64_t, NodeAge_tag > NodeAge
Definition: extensions/timesync/src/types.h:32
catapult::utils::BaseValue
Immutable wrapper for basic types, to provide some type-safety.
Definition: BaseValue.h:100
catapult::timesync::TimeSynchronizationState::m_offset
std::atomic< int64_t > m_offset
Definition: TimeSynchronizationState.h:65
catapult::timesync::TimeSynchronizationState::nodeAge
NodeAge nodeAge() const
Gets the node age.
Definition: TimeSynchronizationState.cpp:46
TimeSynchronizationState.h
catapult::timesync::TimeSynchronizationState::offset
TimeOffset offset() const
Gets the offset.
Definition: TimeSynchronizationState.cpp:34
catapult::timesync::TimeSynchronizationState
Time synchronization state.
Definition: TimeSynchronizationState.h:37
catapult::Timestamp
utils::BaseValue< uint64_t, Timestamp_tag > Timestamp
Definition: src/catapult/types.h:73
Casting.h
catapult::timesync::TimeSynchronizationState::offsetDirection
TimeOffsetDirection offsetDirection() const
Gets the offset direction.
Definition: TimeSynchronizationState.cpp:42
catapult::timesync::TimeSynchronizationState::m_nodeAge
std::atomic< int64_t > m_nodeAge
Definition: TimeSynchronizationState.h:66
NetworkTime.h
catapult::timesync::TimeSynchronizationState::absoluteOffset
uint64_t absoluteOffset() const
Gets the absolute value of the current offset.
Definition: TimeSynchronizationState.cpp:38
catapult::timesync::TimeOffset
utils::BaseValue< int64_t, TimeOffset_tag > TimeOffset
Definition: extensions/timesync/src/types.h:28
catapult
Definition: AddressExtractionExtension.cpp:28
types.h
catapult::timesync::TimeOffsetDirection::Negative
Time offset is in negative direction.
catapult::utils::NetworkTime
Timestamp NetworkTime()
Returns the network time, i.e. the number of milliseconds since Epoch_Time.
Definition: NetworkTime.cpp:27