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

Classes

struct  Query
 

Public Types

using error_code = boost::system::error_code
 
using rep = typename std::chrono::system_clock ::rep
 
using period = typename std::chrono::system_clock ::period
 
using duration = typename std::chrono::system_clock ::duration
 
using time_point = typename std::chrono::system_clock ::time_point
 
using clock_type = std::chrono::system_clock
 

Public Member Functions

 SNTPClientImp (beast::Journal j)
 
 ~SNTPClientImp () override
 
void run (const std::vector< std::string > &servers) override
 
time_point now () const override
 
duration offset () const override
 
void doRun ()
 
void onTimer (error_code const &ec)
 
void onRead (error_code const &ec, std::size_t bytes_xferd)
 
void addServer (std::string const &server)
 
void queryAll ()
 
bool doQuery ()
 
void resolveComplete (error_code const &ec, boost::asio::ip::udp::resolver::iterator it)
 
void onSend (error_code const &ec, std::size_t)
 
void processReply ()
 
virtual time_point now () const=0
 Returns the current time. More...
 

Static Public Attributes

static const bool is_steady
 

Private Types

template<class Duration >
using sys_time = std::chrono::time_point< clock_type, Duration >
 
using sys_seconds = sys_time< std::chrono::seconds >
 

Private Attributes

const beast::Journal j_
 
std::mutex mutex_
 
std::thread thread_
 
boost::asio::io_service io_service_
 
std::optional< boost::asio::io_service::work > work_
 
std::map< boost::asio::ip::udp::endpoint, Queryqueries_
 
boost::asio::ip::udp::socket socket_
 
boost::asio::basic_waitable_timer< std::chrono::system_clocktimer_
 
boost::asio::ip::udp::resolver resolver_
 
std::vector< std::pair< std::string, sys_seconds > > servers_
 
std::chrono::seconds offset_
 
sys_seconds lastUpdate_
 
std::deque< std::chrono::secondsoffsets_
 
std::vector< uint8_t > buf_
 
boost::asio::ip::udp::endpoint ep_
 

Detailed Description

Definition at line 69 of file SNTPClock.cpp.

Member Typedef Documentation

◆ sys_time

template<class Duration >
using ripple::SNTPClientImp::sys_time = std::chrono::time_point<clock_type, Duration>
private

Definition at line 73 of file SNTPClock.cpp.

◆ sys_seconds

Definition at line 75 of file SNTPClock.cpp.

◆ error_code

using ripple::SNTPClientImp::error_code = boost::system::error_code

Definition at line 107 of file SNTPClock.cpp.

◆ rep

Definition at line 60 of file abstract_clock.h.

◆ period

Definition at line 61 of file abstract_clock.h.

◆ duration

Definition at line 62 of file abstract_clock.h.

◆ time_point

Definition at line 63 of file abstract_clock.h.

◆ clock_type

Definition at line 64 of file abstract_clock.h.

Constructor & Destructor Documentation

◆ SNTPClientImp()

ripple::SNTPClientImp::SNTPClientImp ( beast::Journal  j)
explicit

Definition at line 109 of file SNTPClock.cpp.

◆ ~SNTPClientImp()

ripple::SNTPClientImp::~SNTPClientImp ( )
override

Definition at line 121 of file SNTPClock.cpp.

Member Function Documentation

◆ run()

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

Implements ripple::SNTPClock.

Definition at line 136 of file SNTPClock.cpp.

◆ now() [1/2]

time_point ripple::SNTPClientImp::now ( ) const
override

Definition at line 172 of file SNTPClock.cpp.

◆ offset()

duration ripple::SNTPClientImp::offset ( ) const
overridevirtual

Implements ripple::SNTPClock.

Definition at line 185 of file SNTPClock.cpp.

◆ doRun()

void ripple::SNTPClientImp::doRun ( )

Definition at line 194 of file SNTPClock.cpp.

◆ onTimer()

void ripple::SNTPClientImp::onTimer ( error_code const &  ec)

Definition at line 201 of file SNTPClock.cpp.

◆ onRead()

void ripple::SNTPClientImp::onRead ( error_code const &  ec,
std::size_t  bytes_xferd 
)

Definition at line 219 of file SNTPClock.cpp.

◆ addServer()

void ripple::SNTPClientImp::addServer ( std::string const &  server)

Definition at line 287 of file SNTPClock.cpp.

◆ queryAll()

void ripple::SNTPClientImp::queryAll ( )

Definition at line 294 of file SNTPClock.cpp.

◆ doQuery()

bool ripple::SNTPClientImp::doQuery ( )

Definition at line 302 of file SNTPClock.cpp.

◆ resolveComplete()

void ripple::SNTPClientImp::resolveComplete ( error_code const &  ec,
boost::asio::ip::udp::resolver::iterator  it 
)

Definition at line 344 of file SNTPClock.cpp.

◆ onSend()

void ripple::SNTPClientImp::onSend ( error_code const &  ec,
std::size_t   
)

Definition at line 410 of file SNTPClock.cpp.

◆ processReply()

void ripple::SNTPClientImp::processReply ( )

Definition at line 423 of file SNTPClock.cpp.

◆ now() [2/2]

virtual time_point beast::abstract_clock< std::chrono::system_clock >::now
pure virtualinherited

Returns the current time.

Member Data Documentation

◆ j_

const beast::Journal ripple::SNTPClientImp::j_
private

Definition at line 89 of file SNTPClock.cpp.

◆ mutex_

std::mutex ripple::SNTPClientImp::mutex_
mutableprivate

Definition at line 90 of file SNTPClock.cpp.

◆ thread_

std::thread ripple::SNTPClientImp::thread_
private

Definition at line 91 of file SNTPClock.cpp.

◆ io_service_

boost::asio::io_service ripple::SNTPClientImp::io_service_
private

Definition at line 92 of file SNTPClock.cpp.

◆ work_

std::optional<boost::asio::io_service::work> ripple::SNTPClientImp::work_
private

Definition at line 93 of file SNTPClock.cpp.

◆ queries_

std::map<boost::asio::ip::udp::endpoint, Query> ripple::SNTPClientImp::queries_
private

Definition at line 95 of file SNTPClock.cpp.

◆ socket_

boost::asio::ip::udp::socket ripple::SNTPClientImp::socket_
private

Definition at line 96 of file SNTPClock.cpp.

◆ timer_

boost::asio::basic_waitable_timer<std::chrono::system_clock> ripple::SNTPClientImp::timer_
private

Definition at line 97 of file SNTPClock.cpp.

◆ resolver_

boost::asio::ip::udp::resolver ripple::SNTPClientImp::resolver_
private

Definition at line 98 of file SNTPClock.cpp.

◆ servers_

std::vector<std::pair<std::string, sys_seconds> > ripple::SNTPClientImp::servers_
private

Definition at line 99 of file SNTPClock.cpp.

◆ offset_

std::chrono::seconds ripple::SNTPClientImp::offset_
private

Definition at line 100 of file SNTPClock.cpp.

◆ lastUpdate_

sys_seconds ripple::SNTPClientImp::lastUpdate_
private

Definition at line 101 of file SNTPClock.cpp.

◆ offsets_

std::deque<std::chrono::seconds> ripple::SNTPClientImp::offsets_
private

Definition at line 102 of file SNTPClock.cpp.

◆ buf_

std::vector<uint8_t> ripple::SNTPClientImp::buf_
private

Definition at line 103 of file SNTPClock.cpp.

◆ ep_

boost::asio::ip::udp::endpoint ripple::SNTPClientImp::ep_
private

Definition at line 104 of file SNTPClock.cpp.

◆ is_steady

const bool beast::abstract_clock< std::chrono::system_clock >::is_steady
staticinherited

Definition at line 66 of file abstract_clock.h.