mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Rework version logic as agreed.
This commit is contained in:
37
src/Peer.cpp
37
src/Peer.cpp
@@ -566,18 +566,16 @@ void Peer::processReadBuffer()
|
||||
|
||||
void Peer::recvHello(newcoin::TMHello& packet)
|
||||
{
|
||||
Log(lsTRACE) << "Recv(Hello) v=" << packet.versionmajor() << "." << packet.versionminor();
|
||||
bool bDetach = true;
|
||||
|
||||
// Cancel verification timeout.
|
||||
(void) mVerifyTimer.cancel();
|
||||
|
||||
if ((packet.minprotoversionmajor() > PROTO_VERSION_MAJ) ||
|
||||
((packet.minprotoversionmajor() == PROTO_VERSION_MAJ) && (packet.minprotoversionminor() > PROTO_VERSION_MIN)))
|
||||
if (packet.protoversionmin() < MAKE_VERSION_INT(MIN_PROTO_MAJOR, MIN_PROTO_MINOR))
|
||||
{
|
||||
Log(lsINFO) << "Recv(Hello): Server requires protocol version " <<
|
||||
packet.minprotoversionmajor() << "." << packet.minprotoversionminor() << " we run " <<
|
||||
PROTO_VERSION_MAJ << "." << PROTO_VERSION_MIN;
|
||||
GET_VERSION_MAJOR(packet.protoversion()) << "." << GET_VERSION_MINOR(packet.protoversion())
|
||||
<< " we run " << PROTO_VERSION_MAJOR << "." << PROTO_VERSION_MINOR;
|
||||
}
|
||||
else if (!mNodePublic.setNodePublic(packet.nodepublic()))
|
||||
{
|
||||
@@ -590,16 +588,11 @@ void Peer::recvHello(newcoin::TMHello& packet)
|
||||
else
|
||||
{ // Successful connection.
|
||||
Log(lsINFO) << "Recv(Hello): Connect: " << mNodePublic.humanNodePublic();
|
||||
if (packet.protoversion() != MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR))
|
||||
Log(lsINFO) << "Peer speaks version " <<
|
||||
(packet.protoversion() >> 16) << "." << (packet.protoversion() & 0xFF);
|
||||
mHello = packet;
|
||||
|
||||
if ( (packet.versionmajor() != SERVER_VERSION_MAJ) || (packet.versionminor() != SERVER_VERSION_MIN))
|
||||
{
|
||||
if (packet.has_fullversion())
|
||||
Log(lsINFO) << " Peer is running version " << packet.fullversion();
|
||||
else
|
||||
Log(lsINFO) << " Peer is running version " << packet.versionmajor() << "." << packet.versionminor();
|
||||
}
|
||||
|
||||
if (mClientConnect)
|
||||
{
|
||||
// If we connected due to scan, no longer need to scan.
|
||||
@@ -1119,12 +1112,8 @@ void Peer::sendHello()
|
||||
|
||||
newcoin::TMHello h;
|
||||
|
||||
h.set_versionmajor(SERVER_VERSION_MAJ);
|
||||
h.set_versionminor(SERVER_VERSION_MIN);
|
||||
h.set_protoversionmajor(PROTO_VERSION_MAJ);
|
||||
h.set_protoversionminor(PROTO_VERSION_MIN);
|
||||
h.set_minprotoversionminor(MIN_PROTO_MAJ);
|
||||
h.set_minprotoversionmajor(MIN_PROTO_MIN);
|
||||
h.set_protoversion(MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR));
|
||||
h.set_protoversionmin(MAKE_VERSION_INT(MIN_PROTO_MAJOR, MIN_PROTO_MINOR));
|
||||
h.set_fullversion(SERVER_VERSION);
|
||||
h.set_nettime(theApp->getOPs().getNetworkTimeNC());
|
||||
h.set_nodepublic(theApp->getWallet().getNodePublic().humanNodePublic());
|
||||
@@ -1171,13 +1160,11 @@ Json::Value Peer::getJson()
|
||||
|
||||
if (mHello.has_fullversion())
|
||||
ret["version"] = mHello.fullversion();
|
||||
else if (mHello.has_versionminor() && mHello.has_versionmajor())
|
||||
ret["version"] = boost::lexical_cast<std::string>(mHello.versionmajor()) + "." +
|
||||
boost::lexical_cast<std::string>(mHello.versionminor());
|
||||
|
||||
if (mHello.has_protoversionminor() && mHello.has_protoversionmajor())
|
||||
ret["protocol"] = boost::lexical_cast<std::string>(mHello.protoversionmajor()) + "." +
|
||||
boost::lexical_cast<std::string>(mHello.protoversionminor());
|
||||
if (mHello.has_protoversion() &&
|
||||
(mHello.protoversion() != MAKE_VERSION_INT(PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR)))
|
||||
ret["protocol"] = boost::lexical_cast<std::string>(GET_VERSION_MAJOR(mHello.protoversion())) + "." +
|
||||
boost::lexical_cast<std::string>(GET_VERSION_MINOR(mHello.protoversion()));
|
||||
/*
|
||||
if (!mIpPort.first.empty())
|
||||
{
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
|
||||
// Versions
|
||||
|
||||
#ifndef SERVER_VERSION_MAJ
|
||||
#ifndef SERVER_VERSION_MAJOR
|
||||
|
||||
#define SERVER_VERSION_MAJ 0
|
||||
#define SERVER_VERSION_MIN 2
|
||||
#define SERVER_VERSION_MAJOR 0
|
||||
#define SERVER_VERSION_MINOR 1
|
||||
#define SERVER_VERSION_SUB "-a"
|
||||
#define SERVER_NAME "NewCoin"
|
||||
|
||||
#define SV_STRINGIZE(x) SV_STRINGIZE2(x)
|
||||
#define SV_STRINGIZE2(x) #x
|
||||
#define SERVER_VERSION \
|
||||
(SERVER_NAME "-" SV_STRINGIZE(SERVER_VERSION_MAJ) "." SV_STRINGIZE(SERVER_VERSION_MIN) SERVER_VERSION_SUB)
|
||||
(SERVER_NAME "-" SV_STRINGIZE(SERVER_VERSION_MAJOR) "." SV_STRINGIZE(SERVER_VERSION_MINOR) SERVER_VERSION_SUB)
|
||||
|
||||
#define PROTO_VERSION_MAJ 0
|
||||
#define PROTO_VERSION_MIN 1
|
||||
#define PROTO_VERSION_MAJOR 0
|
||||
#define PROTO_VERSION_MINOR 1
|
||||
|
||||
#define MIN_PROTO_MAJ 0
|
||||
#define MIN_PROTO_MIN 1
|
||||
#define MIN_PROTO_MAJOR 0
|
||||
#define MIN_PROTO_MINOR 1
|
||||
|
||||
#define MAKE_VERSION_INT(maj,min) ((maj << 16) | min)
|
||||
#define GET_VERSION_MAJOR(ver) (ver >> 16)
|
||||
#define GET_VERSION_MINOR(ver) (ver & 0xff)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,20 +37,16 @@ enum MessageType {
|
||||
|
||||
|
||||
message TMHello {
|
||||
required uint32 versionMinor = 1;
|
||||
required uint32 versionMajor = 2;
|
||||
required uint32 protoVersionMinor = 3;
|
||||
required uint32 protoVersionMajor = 4;
|
||||
required uint32 minProtoVersionMinor = 5;
|
||||
required uint32 minProtoVersionMajor = 6;
|
||||
required bytes nodePublic = 7;
|
||||
required bytes nodeProof = 8;
|
||||
optional string fullVersion = 9;
|
||||
optional uint64 netTime = 10;
|
||||
optional uint32 ipv4Port = 11;
|
||||
optional uint32 ledgerIndex = 12;
|
||||
optional bytes closedLedger = 13; // our last closed ledger
|
||||
optional bytes previousLedger = 14; // the ledger before the last closed ledger
|
||||
required uint32 protoVersion = 1;
|
||||
required uint32 protoVersionMin = 2;
|
||||
required bytes nodePublic = 3;
|
||||
required bytes nodeProof = 4;
|
||||
optional string fullVersion = 5;
|
||||
optional uint64 netTime = 6;
|
||||
optional uint32 ipv4Port = 7;
|
||||
optional uint32 ledgerIndex = 8;
|
||||
optional bytes closedLedger = 9; // our last closed ledger
|
||||
optional bytes previousLedger = 10; // the ledger before the last closed ledger
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user