mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 06:10:58 +00:00
refactor: Clean up pong replies
This commit is contained in:
@@ -293,14 +293,15 @@ message TMLedgerData {
|
||||
}
|
||||
|
||||
message TMPing {
|
||||
// Previously used - don't reuse.
|
||||
reserved 3, 4;
|
||||
|
||||
enum pingType {
|
||||
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
|
||||
optional uint64 pingTime = 3; // know when we think we sent the ping
|
||||
optional uint64 netTime = 4;
|
||||
optional uint32 seq = 2; // detect stale replies, ensure other side is reading
|
||||
}
|
||||
|
||||
message TMSquelch {
|
||||
|
||||
@@ -1113,10 +1113,13 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMPing> const& m)
|
||||
{
|
||||
if (m->type() == protocol::TMPing::ptPING)
|
||||
{
|
||||
// We have received a ping request, reply with a pong
|
||||
// We have received a ping request, reply with a pong.
|
||||
fee_.update(Resource::kFeeModerateBurdenPeer, "ping request");
|
||||
m->set_type(protocol::TMPing::ptPONG);
|
||||
send(std::make_shared<Message>(*m, protocol::mtPING));
|
||||
protocol::TMPing pong;
|
||||
pong.set_type(protocol::TMPing::ptPONG);
|
||||
if (m->has_seq())
|
||||
pong.set_seq(m->seq());
|
||||
send(std::make_shared<Message>(pong, protocol::mtPING));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user