CatapultServer  v0.5.0.1 (Elephant)
TimeSynchronizationSample.h
Go to the documentation of this file.
1 
21 #pragma once
23 #include "catapult/ionet/Node.h"
25 #include <set>
26 
27 namespace catapult { namespace timesync {
28 
31  public:
34 
39  const ionet::Node& node,
42 
43  public:
45  const ionet::Node& node() const;
46 
49 
52 
53  public:
55  utils::TimeSpan duration() const;
56 
58  int64_t localDuration() const;
59 
61  int64_t remoteDuration() const;
62 
64  int64_t timeOffsetToRemote() const;
65 
66  public:
68  bool operator<(const TimeSynchronizationSample& rhs) const;
69 
71  bool operator==(const TimeSynchronizationSample& rhs) const;
72 
74  bool operator!=(const TimeSynchronizationSample& rhs) const;
75 
76  private:
80  };
81 
83  using TimeSynchronizationSamples = std::set<TimeSynchronizationSample>;
84 }}
catapult::timesync::TimeSynchronizationSample::remoteDuration
int64_t remoteDuration() const
Gets the remote duration.
Definition: TimeSynchronizationSample.cpp:66
CommunicationTimestamps.h
catapult::timesync::TimeSynchronizationSample::TimeSynchronizationSample
TimeSynchronizationSample()
Creates a default time synchronization sample.
Definition: TimeSynchronizationSample.cpp:31
catapult::timesync::CommunicationTimestamps
Represents the network timestamps for sending and receiving a time synchronization request / response...
Definition: CommunicationTimestamps.h:29
catapult::timesync::TimeSynchronizationSample::remoteTimestamps
const CommunicationTimestamps & remoteTimestamps() const
Gets the remote timestamps.
Definition: TimeSynchronizationSample.cpp:54
catapult::ionet::Node::identityKey
const Key & identityKey() const
Gets the unique identifier (a public key).
Definition: Node.cpp:60
catapult::utils::TimeSpan::FromDifference
static constexpr TimeSpan FromDifference(Timestamp end, Timestamp start)
Creates a time span from the difference between start and end.
Definition: TimeSpan.h:64
catapult::timesync::TimeSynchronizationSample::operator!=
bool operator!=(const TimeSynchronizationSample &rhs) const
Returns true if this time synchronization sample is not equal to rhs.
Definition: TimeSynchronizationSample.cpp:97
catapult::utils::TimeSpan
Represents a time duration.
Definition: TimeSpan.h:30
TimeSynchronizationSample.h
catapult::timesync::TimeSynchronizationSample::m_remoteTimestamps
CommunicationTimestamps m_remoteTimestamps
Definition: TimeSynchronizationSample.h:79
catapult::timesync::TimeSynchronizationSample::localDuration
int64_t localDuration() const
Gets the local duration.
Definition: TimeSynchronizationSample.cpp:62
catapult::timesync::TimeSynchronizationSample
Represents a sample in the time synchronization process.
Definition: TimeSynchronizationSample.h:30
catapult::timesync::TimeSynchronizationSample::m_localTimestamps
CommunicationTimestamps m_localTimestamps
Definition: TimeSynchronizationSample.h:78
catapult::timesync::TimeSynchronizationSample::node
const ionet::Node & node() const
Gets the node.
Definition: TimeSynchronizationSample.cpp:46
catapult::timesync::TimeSynchronizationSample::duration
utils::TimeSpan duration() const
Gets the duration of the complete cycle.
Definition: TimeSynchronizationSample.cpp:58
catapult::timesync::TimeSynchronizationSample::timeOffsetToRemote
int64_t timeOffsetToRemote() const
Gets the offset of the local node's network time relative to the remote node's network time.
Definition: TimeSynchronizationSample.cpp:76
Node.h
catapult::timesync::TimeSynchronizationSamples
std::set< TimeSynchronizationSample > TimeSynchronizationSamples
A set of time synchronization samples.
Definition: TimeSynchronizationSample.h:83
catapult::timesync::TimeSynchronizationSample::localTimestamps
const CommunicationTimestamps & localTimestamps() const
Gets the local timestamps.
Definition: TimeSynchronizationSample.cpp:50
catapult::timesync::CommunicationTimestamps::SendTimestamp
Timestamp SendTimestamp
Time when the request/response was sent.
Definition: CommunicationTimestamps.h:53
catapult::timesync::TimeSynchronizationSample::operator<
bool operator<(const TimeSynchronizationSample &rhs) const
Returns true if this time synchronization sample is less than rhs.
Definition: TimeSynchronizationSample.cpp:81
catapult::timesync::CommunicationTimestamps::ReceiveTimestamp
Timestamp ReceiveTimestamp
Time when the request/response was received.
Definition: CommunicationTimestamps.h:56
TimeSpan.h
catapult::Timestamp
utils::BaseValue< uint64_t, Timestamp_tag > Timestamp
Definition: src/catapult/types.h:73
catapult::timesync::TimeSynchronizationSample::m_node
ionet::Node m_node
Definition: TimeSynchronizationSample.h:77
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::timesync::TimeSynchronizationSample::operator==
bool operator==(const TimeSynchronizationSample &rhs) const
Returns true if this time synchronization sample is equal to rhs.
Definition: TimeSynchronizationSample.cpp:93
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82