mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve BuildInfo interface:
* Remove unnecessary beast::String dependency * Explicitly cast to result type while packing a version * Add unit tests for version formatting
This commit is contained in:
committed by
Vinnie Falco
parent
6c072f37ef
commit
3cfa5a41b1
@@ -125,7 +125,7 @@ PeerImp::make_request()
|
||||
//m.headers.append ("Local-Address", m_socket->
|
||||
m.headers.append ("Remote-Address", m_remoteAddress.to_string());
|
||||
m.headers.append ("Upgrade",
|
||||
std::string("Ripple/")+BuildInfo::getCurrentProtocol().toStdString());
|
||||
std::string("Ripple/") + to_string (BuildInfo::getCurrentProtocol()));
|
||||
m.headers.append ("Connection", "Upgrade");
|
||||
m.headers.append ("Connect-As", "Leaf, Peer");
|
||||
m.headers.append ("Accept-Encoding", "identity, snappy");
|
||||
@@ -585,7 +585,7 @@ PeerImp::on_message (std::shared_ptr <protocol::TMHello> const& m)
|
||||
}
|
||||
#endif
|
||||
|
||||
BuildInfo::Protocol protocol (m->protoversion());
|
||||
auto protocol = BuildInfo::make_protocol(m->protoversion());
|
||||
|
||||
if (m->has_nettime () &&
|
||||
((m->nettime () < minTime) || (m->nettime () > maxTime)))
|
||||
@@ -603,18 +603,12 @@ PeerImp::on_message (std::shared_ptr <protocol::TMHello> const& m)
|
||||
" is off by -" << ourTime - m->nettime ();
|
||||
}
|
||||
}
|
||||
else if (m->protoversionmin () > BuildInfo::getCurrentProtocol().toPacked ())
|
||||
else if (m->protoversionmin () > to_packed (BuildInfo::getCurrentProtocol()))
|
||||
{
|
||||
std::string reqVersion (
|
||||
protocol.toStdString ());
|
||||
|
||||
std::string curVersion (
|
||||
BuildInfo::getCurrentProtocol().toStdString ());
|
||||
|
||||
m_journal.info <<
|
||||
"Hello: Disconnect: Protocol mismatch [" <<
|
||||
"Peer expects " << reqVersion <<
|
||||
" and we run " << curVersion << "]";
|
||||
"Peer expects " << to_string (protocol) <<
|
||||
" and we run " << to_string (BuildInfo::getCurrentProtocol()) << "]";
|
||||
}
|
||||
else if (! m_nodePublicKey.setNodePublic (m->nodepublic ()))
|
||||
{
|
||||
@@ -638,7 +632,7 @@ PeerImp::on_message (std::shared_ptr <protocol::TMHello> const& m)
|
||||
m_journal.active(beast::Journal::Severity::kInfo))
|
||||
{
|
||||
m_journal.info <<
|
||||
"Peer protocol: " << protocol.toStdString ();
|
||||
"Peer protocol: " << to_string (protocol);
|
||||
}
|
||||
|
||||
mHello = *m;
|
||||
|
||||
@@ -554,10 +554,12 @@ public:
|
||||
if (mHello.has_fullversion ())
|
||||
ret["version"] = mHello.fullversion ();
|
||||
|
||||
if (mHello.has_protoversion () &&
|
||||
(mHello.protoversion () != BuildInfo::getCurrentProtocol().toPacked ()))
|
||||
if (mHello.has_protoversion ())
|
||||
{
|
||||
ret["protocol"] = BuildInfo::Protocol (mHello.protoversion ()).toStdString ();
|
||||
auto protocol = BuildInfo::make_protocol (mHello.protoversion ());
|
||||
|
||||
if (protocol != BuildInfo::getCurrentProtocol())
|
||||
ret["protocol"] = to_string (protocol);
|
||||
}
|
||||
|
||||
std::uint32_t minSeq, maxSeq;
|
||||
@@ -876,8 +878,8 @@ private:
|
||||
|
||||
protocol::TMHello h;
|
||||
|
||||
h.set_protoversion (BuildInfo::getCurrentProtocol().toPacked ());
|
||||
h.set_protoversionmin (BuildInfo::getMinimumProtocol().toPacked ());
|
||||
h.set_protoversion (to_packed (BuildInfo::getCurrentProtocol()));
|
||||
h.set_protoversionmin (to_packed (BuildInfo::getMinimumProtocol()));
|
||||
h.set_fullversion (BuildInfo::getFullVersionString ());
|
||||
h.set_nettime (getApp().getOPs ().getNetworkTimeNC ());
|
||||
h.set_nodepublic (getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ());
|
||||
|
||||
@@ -598,9 +598,9 @@ public:
|
||||
ret["version"] = mHello.fullversion ();
|
||||
|
||||
if (mHello.has_protoversion () &&
|
||||
(mHello.protoversion () != BuildInfo::getCurrentProtocol().toPacked ()))
|
||||
(mHello.protoversion () != to_packed (BuildInfo::getCurrentProtocol())))
|
||||
{
|
||||
ret["protocol"] = BuildInfo::Protocol (mHello.protoversion ()).toStdString ();
|
||||
ret["protocol"] = to_string (BuildInfo::make_protocol (mHello.protoversion ()));
|
||||
}
|
||||
|
||||
std::uint32_t minSeq, maxSeq;
|
||||
@@ -960,8 +960,8 @@ private:
|
||||
|
||||
protocol::TMHello h;
|
||||
|
||||
h.set_protoversion (BuildInfo::getCurrentProtocol().toPacked ());
|
||||
h.set_protoversionmin (BuildInfo::getMinimumProtocol().toPacked ());
|
||||
h.set_protoversion (to_packed (BuildInfo::getCurrentProtocol()));
|
||||
h.set_protoversionmin (to_packed (BuildInfo::getMinimumProtocol()));
|
||||
h.set_fullversion (BuildInfo::getFullVersionString ());
|
||||
h.set_nettime (getApp().getOPs ().getNetworkTimeNC ());
|
||||
h.set_nodepublic (getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ());
|
||||
|
||||
Reference in New Issue
Block a user