mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
first
This commit is contained in:
46
TimingService.cpp
Normal file
46
TimingService.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "TimingService.h"
|
||||
#include "Config.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
/*
|
||||
Only needs to start once we determine the network time
|
||||
*/
|
||||
|
||||
TimingService::TimingService()
|
||||
{
|
||||
mLedgerTimer=NULL;
|
||||
mPropTimer=NULL;
|
||||
}
|
||||
|
||||
void TimingService::start(boost::asio::io_service& ioService)
|
||||
{
|
||||
// TODO: calculate the amount of seconds left in the current ledger
|
||||
mLedgerTimer=new asio::deadline_timer(ioService, posix_time::seconds(theConfig.LEDGER_SECONDS)),
|
||||
mLedgerTimer->async_wait(boost::bind(&TimingService::handleLedger, this));
|
||||
|
||||
mPropTimer=new asio::deadline_timer(ioService, posix_time::seconds(theConfig.LEDGER_PROPOSAL_DELAY_SECONDS));
|
||||
|
||||
}
|
||||
|
||||
void TimingService::handleLedger()
|
||||
{
|
||||
cout << "publish ledger" << endl;
|
||||
theApp->getLedgerMaster().nextLedger();
|
||||
mLedgerTimer->expires_at(mLedgerTimer->expires_at() + boost::posix_time::seconds(theConfig.LEDGER_SECONDS));
|
||||
mLedgerTimer->async_wait(boost::bind(&TimingService::handleLedger, this));
|
||||
|
||||
mPropTimer->expires_at(mLedgerTimer->expires_at() + boost::posix_time::seconds(theConfig.LEDGER_PROPOSAL_DELAY_SECONDS));
|
||||
mPropTimer->async_wait(boost::bind(&TimingService::handleProp, this));
|
||||
}
|
||||
|
||||
void TimingService::handleProp()
|
||||
{
|
||||
theApp->getLedgerMaster().sendProposal();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user