mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Handle pongs. Ready timer for ping timing.
This commit is contained in:
@@ -27,9 +27,10 @@ DECLARE_INSTANCE(Peer);
|
||||
Peer::Peer(boost::asio::io_service& io_service, boost::asio::ssl::context& ctx, uint64 peerID) :
|
||||
mHelloed(false),
|
||||
mDetaching(false),
|
||||
mActive(true),
|
||||
mPeerId(peerID),
|
||||
mSocketSsl(io_service, ctx),
|
||||
mVerifyTimer(io_service)
|
||||
mActivityTimer(io_service)
|
||||
{
|
||||
cLog(lsDEBUG) << "CREATING PEER: " << ADDRESS(this);
|
||||
}
|
||||
@@ -91,7 +92,7 @@ void Peer::detach(const char *rsn)
|
||||
|
||||
mSendQ.clear();
|
||||
|
||||
(void) mVerifyTimer.cancel();
|
||||
(void) mActivityTimer.cancel();
|
||||
mSocketSsl.async_shutdown(boost::bind(&Peer::handleShutdown, shared_from_this(), boost::asio::placeholders::error));
|
||||
|
||||
if (mNodePublic.isValid())
|
||||
@@ -168,8 +169,8 @@ void Peer::connect(const std::string& strIp, int iPort)
|
||||
}
|
||||
else
|
||||
{
|
||||
mVerifyTimer.expires_from_now(boost::posix_time::seconds(NODE_VERIFY_SECONDS), err);
|
||||
mVerifyTimer.async_wait(boost::bind(&Peer::handleVerifyTimer, shared_from_this(),
|
||||
mActivityTimer.expires_from_now(boost::posix_time::seconds(NODE_VERIFY_SECONDS), err);
|
||||
mActivityTimer.async_wait(boost::bind(&Peer::handleVerifyTimer, shared_from_this(),
|
||||
boost::asio::placeholders::error));
|
||||
|
||||
if (err)
|
||||
@@ -611,8 +612,8 @@ void Peer::recvHello(ripple::TMHello& packet)
|
||||
{
|
||||
bool bDetach = true;
|
||||
|
||||
// Cancel verification timeout.
|
||||
(void) mVerifyTimer.cancel();
|
||||
// Cancel verification timeout. - FIXME Start ping/pong timer
|
||||
(void) mActivityTimer.cancel();
|
||||
|
||||
uint32 ourTime = theApp->getOPs().getNetworkTimeNC();
|
||||
uint32 minTime = ourTime - 20;
|
||||
@@ -1157,11 +1158,15 @@ void Peer::recvGetObjectByHash(ripple::TMGetObjectByHash& packet)
|
||||
|
||||
void Peer::recvPing(ripple::TMPing& packet)
|
||||
{
|
||||
if (packet.type() == ripple::TMPing::PING)
|
||||
if (packet.type() == ripple::TMPing::ptPING)
|
||||
{
|
||||
packet.set_type(ripple::TMPing::PONG);
|
||||
packet.set_type(ripple::TMPing::ptPONG);
|
||||
sendPacket(boost::make_shared<PackedMessage>(packet, ripple::mtPING));
|
||||
}
|
||||
else if (packet.type() == ripple::TMPing::ptPONG)
|
||||
{
|
||||
mActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Peer::recvErrorMessage(ripple::TMErrorMsg& packet)
|
||||
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
bool mClientConnect; // In process of connecting as client.
|
||||
bool mHelloed; // True, if hello accepted.
|
||||
bool mDetaching; // True, if detaching.
|
||||
bool mActive;
|
||||
RippleAddress mNodePublic; // Node public key of peer.
|
||||
ipPort mIpPort;
|
||||
ipPort mIpPortConnect;
|
||||
@@ -50,7 +51,7 @@ private:
|
||||
|
||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> mSocketSsl;
|
||||
|
||||
boost::asio::deadline_timer mVerifyTimer;
|
||||
boost::asio::deadline_timer mActivityTimer;
|
||||
|
||||
void handleStart(const boost::system::error_code& ecResult);
|
||||
void handleVerifyTimer(const boost::system::error_code& ecResult);
|
||||
|
||||
@@ -292,8 +292,8 @@ message TMLedgerData {
|
||||
|
||||
message TMPing {
|
||||
enum pingType {
|
||||
PING = 0; // we want a reply
|
||||
PONG = 1; // this is a reply
|
||||
ptPING = 0; // we want a reply
|
||||
ptPONG = 1; // this is a reply
|
||||
}
|
||||
required pingType type = 1;
|
||||
optional uint32 seq = 2; // detect stale replies, ensure other side is reading
|
||||
|
||||
Reference in New Issue
Block a user