mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Rewrite build version and protocol version interface
This commit is contained in:
@@ -19,6 +19,12 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\modules\ripple_app\basics\ripple_BuildInfo.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.cpp">
|
<ClCompile Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
@@ -1318,9 +1324,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\BeastConfig.h" />
|
<ClInclude Include="..\..\BeastConfig.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildVersion.h" />
|
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildInfo.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.h" />
|
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_Version.h" />
|
|
||||||
<ClInclude Include="..\..\modules\ripple_app\consensus\ripple_DisputedTx.h" />
|
<ClInclude Include="..\..\modules\ripple_app\consensus\ripple_DisputedTx.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\consensus\ripple_LedgerConsensus.h" />
|
<ClInclude Include="..\..\modules\ripple_app\consensus\ripple_LedgerConsensus.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\contracts\ripple_Contract.h" />
|
<ClInclude Include="..\..\modules\ripple_app\contracts\ripple_Contract.h" />
|
||||||
|
|||||||
@@ -870,6 +870,9 @@
|
|||||||
<ClCompile Include="..\..\Subtrees\beast\modules\beast_sqlite\beast_sqlite.c">
|
<ClCompile Include="..\..\Subtrees\beast\modules\beast_sqlite\beast_sqlite.c">
|
||||||
<Filter>[0] Subtrees\beast</Filter>
|
<Filter>[0] Subtrees\beast</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\modules\ripple_app\basics\ripple_BuildInfo.cpp">
|
||||||
|
<Filter>[1] Ripple\ripple_app\basics</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3.h">
|
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3.h">
|
||||||
@@ -1287,12 +1290,6 @@
|
|||||||
<ClInclude Include="..\..\modules\ripple_client\ripple_client.h">
|
<ClInclude Include="..\..\modules\ripple_client\ripple_client.h">
|
||||||
<Filter>[1] Ripple\ripple_client</Filter>
|
<Filter>[1] Ripple\ripple_client</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildVersion.h">
|
|
||||||
<Filter>[1] Ripple\ripple_app\basics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_Version.h">
|
|
||||||
<Filter>[1] Ripple\ripple_app\basics</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_LogFile.h">
|
<ClInclude Include="..\..\modules\ripple_basics\utility\ripple_LogFile.h">
|
||||||
<Filter>[1] Ripple\ripple_basics\utility</Filter>
|
<Filter>[1] Ripple\ripple_basics\utility</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -1659,6 +1656,9 @@
|
|||||||
<ClInclude Include="..\..\modules\ripple_core\validator\ripple_ValidatorImp.h">
|
<ClInclude Include="..\..\modules\ripple_core\validator\ripple_ValidatorImp.h">
|
||||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildInfo.h">
|
||||||
|
<Filter>[1] Ripple\ripple_app\basics</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="..\..\modules\ripple_data\protocol\ripple.proto">
|
<CustomBuild Include="..\..\modules\ripple_data\protocol\ripple.proto">
|
||||||
|
|||||||
2
TODO.txt
2
TODO.txt
@@ -122,8 +122,6 @@ David Features:
|
|||||||
use read/write locking semantics to update the values. Later, use Listeners
|
use read/write locking semantics to update the values. Later, use Listeners
|
||||||
to notify dependent code to resolve the dependency inversion.
|
to notify dependent code to resolve the dependency inversion.
|
||||||
|
|
||||||
- Merge ripple_Version.h and ripple_BuildVersion.h
|
|
||||||
|
|
||||||
- Rename LoadMonitor to LoadMeter, change LoadEvent to LoadMeter::ScopedSample
|
- Rename LoadMonitor to LoadMeter, change LoadEvent to LoadMeter::ScopedSample
|
||||||
|
|
||||||
- Rename LedgerMaster to Ledgers, create ILedgers interface.
|
- Rename LedgerMaster to Ledgers, create ILedgers interface.
|
||||||
|
|||||||
305
modules/ripple_app/basics/ripple_BuildInfo.cpp
Normal file
305
modules/ripple_app/basics/ripple_BuildInfo.cpp
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
String const& BuildInfo::getVersionString ()
|
||||||
|
{
|
||||||
|
static char const* const rawText =
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// The build version number (edit this for each release)
|
||||||
|
//
|
||||||
|
"0.010-rc1"
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
;
|
||||||
|
|
||||||
|
struct StaticInitializer
|
||||||
|
{
|
||||||
|
StaticInitializer ()
|
||||||
|
{
|
||||||
|
// Sanity checking on the raw text
|
||||||
|
|
||||||
|
Version v;
|
||||||
|
|
||||||
|
if (! v.parse (rawText) || v.print () != rawText)
|
||||||
|
Throw (std::invalid_argument ("illegal server version format string"));
|
||||||
|
|
||||||
|
versionString = rawText;
|
||||||
|
}
|
||||||
|
|
||||||
|
String versionString;
|
||||||
|
};
|
||||||
|
|
||||||
|
static StaticInitializer value;
|
||||||
|
|
||||||
|
return value.versionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The protocol version we speak and prefer.
|
||||||
|
//
|
||||||
|
BuildInfo::Protocol const& BuildInfo::getCurrentProtocol ()
|
||||||
|
{
|
||||||
|
static Protocol currentProtocol (1, 2);
|
||||||
|
|
||||||
|
return currentProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The oldest protocol version we will accept.
|
||||||
|
//
|
||||||
|
BuildInfo::Protocol const& BuildInfo::getMinimumProtocol ()
|
||||||
|
{
|
||||||
|
static Protocol minimumProtocol (1, 2);
|
||||||
|
|
||||||
|
return minimumProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Don't touch anything below this line
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
char const* BuildInfo::getFullVersionString ()
|
||||||
|
{
|
||||||
|
struct StaticInitializer
|
||||||
|
{
|
||||||
|
StaticInitializer ()
|
||||||
|
{
|
||||||
|
String s;
|
||||||
|
|
||||||
|
s << "Ripple-" << getVersionString ();
|
||||||
|
|
||||||
|
fullVersionString = s.toStdString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string fullVersionString;
|
||||||
|
};
|
||||||
|
|
||||||
|
static StaticInitializer value;
|
||||||
|
|
||||||
|
return value.fullVersionString.c_str ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BuildInfo::Version::Version ()
|
||||||
|
: vmajor (0)
|
||||||
|
, vminor (0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BuildInfo::Version::parse (String const& s)
|
||||||
|
{
|
||||||
|
// Many not have leading or trailing whitespace
|
||||||
|
if (s.trim () != s)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int const indexOfDot = s.indexOfChar ('.');
|
||||||
|
|
||||||
|
// Must have a dot
|
||||||
|
if (indexOfDot == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String const majorString = s.substring (0, indexOfDot);
|
||||||
|
|
||||||
|
// Must only contain digits
|
||||||
|
if (! majorString.containsOnly ("0123456789"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Must match after conversion back and forth
|
||||||
|
if (String (majorString.getIntValue ()) != majorString)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int const indexOfDash = s.indexOfChar ('-');
|
||||||
|
|
||||||
|
// A dash must come after the dot.
|
||||||
|
if (indexOfDash >= 0 && indexOfDash <= indexOfDot)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String const minorString = (indexOfDash == -1) ?
|
||||||
|
s.substring (indexOfDot + 1) : s.substring (indexOfDot + 1, indexOfDash);
|
||||||
|
|
||||||
|
// Must be length three
|
||||||
|
if (minorString.length () != 3)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Must only contain digits
|
||||||
|
if (! minorString.containsOnly ("0123456789"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String const suffixString = (indexOfDash == -1) ?
|
||||||
|
"" : s.substring (indexOfDash + 1);
|
||||||
|
|
||||||
|
if (suffixString.length () > 0)
|
||||||
|
{
|
||||||
|
// Must be 4 characters or less
|
||||||
|
if (suffixString.length () > 4)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Must start with a letter
|
||||||
|
if (! String::charToString (suffixString [0]).containsOnly ("abcdefghijklmnopqrstuvwxyz"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Must only contain letters and numbers
|
||||||
|
if (! String::charToString (suffixString [0]).containsOnly ("abcdefghijklmnopqrstuvwxyz01234567890"))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vmajor = majorString.getIntValue ();
|
||||||
|
vminor = minorString.getIntValue ();
|
||||||
|
suffix = suffixString;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BuildInfo::Version::print () const noexcept
|
||||||
|
{
|
||||||
|
String s;
|
||||||
|
|
||||||
|
s << String (vmajor) << "." << String (vminor).paddedLeft ('0', 3);
|
||||||
|
|
||||||
|
if (suffix.isNotEmpty ())
|
||||||
|
s << "-" << suffix;
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BuildInfo::Protocol::Protocol ()
|
||||||
|
: vmajor (0)
|
||||||
|
, vminor (0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildInfo::Protocol::Protocol (unsigned short major_, unsigned short minor_)
|
||||||
|
: vmajor (major_)
|
||||||
|
, vminor (minor_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildInfo::Protocol::Protocol (PackedFormat packedVersion)
|
||||||
|
{
|
||||||
|
vmajor = (packedVersion >> 16) & 0xffff;
|
||||||
|
vminor = (packedVersion & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildInfo::Protocol::PackedFormat BuildInfo::Protocol::toPacked () const noexcept
|
||||||
|
{
|
||||||
|
return ((vmajor << 16) & 0xffff0000) | (vminor & 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string BuildInfo::Protocol::toStdString () const noexcept
|
||||||
|
{
|
||||||
|
String s;
|
||||||
|
|
||||||
|
s << String (vmajor) << "." << "vminor";
|
||||||
|
|
||||||
|
return s.toStdString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BuildInfoTests : public UnitTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BuildInfoTests () : UnitTest ("BuildInfo", "ripple")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkVersion (String const& s)
|
||||||
|
{
|
||||||
|
BuildInfo::Version v;
|
||||||
|
|
||||||
|
expect (v.parse (s));
|
||||||
|
|
||||||
|
// Conversion back and forth should be identical
|
||||||
|
expect (v.print () == s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testVersion ()
|
||||||
|
{
|
||||||
|
beginTestCase ("version");
|
||||||
|
|
||||||
|
BuildInfo::Version v;
|
||||||
|
|
||||||
|
checkVersion ("0.000");
|
||||||
|
checkVersion ("1.002");
|
||||||
|
checkVersion ("10.002");
|
||||||
|
checkVersion ("99.999");
|
||||||
|
checkVersion ("99.999-r");
|
||||||
|
checkVersion ("99.999-r1");
|
||||||
|
checkVersion ("99.999-r123");
|
||||||
|
|
||||||
|
unexpected (v.parse (" 1.2")); // Many not have leading or trailing whitespace
|
||||||
|
unexpected (v.parse ("1.2 ")); // Many not have leading or trailing whitespace
|
||||||
|
unexpected (v.parse (" 1.2 ")); // Many not have leading or trailing whitespace
|
||||||
|
unexpected (v.parse ("2")); // Must have a dot
|
||||||
|
unexpected (v.parse ("23")); // Must have a dot
|
||||||
|
unexpected (v.parse ("4-rc1")); // Must have a dot
|
||||||
|
unexpected (v.parse ("01.000")); // No leading zeroes
|
||||||
|
unexpected (v.parse ("4-4.r")); // A dash must come after the dot.
|
||||||
|
unexpected (v.parse ("1.2345")); // Must be length three
|
||||||
|
unexpected (v.parse ("1a.2")); // Must only contain digits
|
||||||
|
unexpected (v.parse ("1.2b")); // Must only contain digits
|
||||||
|
unexpected (v.parse ("1.2-rxxx1")); // Must be 4 characters or less
|
||||||
|
unexpected (v.parse ("1.2-")); // Must start with a letter
|
||||||
|
unexpected (v.parse ("1.2-3")); // Must start with a letter
|
||||||
|
unexpected (v.parse ("1.2-r!")); // Must only contain letters and numbers
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkProtcol (unsigned short vmajor, unsigned short vminor)
|
||||||
|
{
|
||||||
|
typedef BuildInfo::Protocol P;
|
||||||
|
|
||||||
|
expect (P (P (vmajor, vminor).toPacked ()) == P (vmajor, vminor));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testProtocol ()
|
||||||
|
{
|
||||||
|
typedef BuildInfo::Protocol P;
|
||||||
|
|
||||||
|
beginTestCase ("protocol");
|
||||||
|
|
||||||
|
expect (P (0, 0).toPacked () == 0);
|
||||||
|
expect (P (0, 1).toPacked () == 1);
|
||||||
|
expect (P (0, 65535).toPacked () == 65535);
|
||||||
|
|
||||||
|
checkProtcol (0, 0);
|
||||||
|
checkProtcol (0, 1);
|
||||||
|
checkProtcol (0, 255);
|
||||||
|
checkProtcol (0, 65535);
|
||||||
|
checkProtcol (1, 0);
|
||||||
|
checkProtcol (1, 65535);
|
||||||
|
checkProtcol (65535, 65535);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testValues ()
|
||||||
|
{
|
||||||
|
beginTestCase ("comparison");
|
||||||
|
|
||||||
|
typedef BuildInfo::Protocol P;
|
||||||
|
|
||||||
|
expect (P(1,2) == P(1,2));
|
||||||
|
expect (P(3,4) >= P(3,4));
|
||||||
|
expect (P(5,6) <= P(5,6));
|
||||||
|
expect (P(7,8) > P(6,7));
|
||||||
|
expect (P(7,8) < P(8,9));
|
||||||
|
expect (P(65535,0) < P(65535,65535));
|
||||||
|
expect (P(65535,65535) >= P(65535,65535));
|
||||||
|
|
||||||
|
expect (BuildInfo::getCurrentProtocol () >= BuildInfo::getMinimumProtocol ());
|
||||||
|
}
|
||||||
|
|
||||||
|
void runTest ()
|
||||||
|
{
|
||||||
|
testVersion ();
|
||||||
|
testProtocol ();
|
||||||
|
testValues ();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static BuildInfoTests buildInfoTests;
|
||||||
145
modules/ripple_app/basics/ripple_BuildInfo.h
Normal file
145
modules/ripple_app/basics/ripple_BuildInfo.h
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#ifndef RIPPLE_BUILDINFO_H_INCLUDED
|
||||||
|
#define RIPPLE_BUILDINFO_H_INCLUDED
|
||||||
|
|
||||||
|
/** Versioning information for this build. */
|
||||||
|
struct BuildInfo
|
||||||
|
{
|
||||||
|
/** Server version.
|
||||||
|
|
||||||
|
The server version has three parts:
|
||||||
|
|
||||||
|
<major> A non negative integer.
|
||||||
|
<minor> An integer between 0 and 999 inclusive.
|
||||||
|
<suffix> An optional string. For example, "rc1"
|
||||||
|
|
||||||
|
The version string is formatted thusly:
|
||||||
|
|
||||||
|
<major> '.' <minor> '.' ['-' <suffix>]
|
||||||
|
|
||||||
|
The minor version number is always padded with leading zeroes
|
||||||
|
to bring the number of characters up to exactly three. For example,
|
||||||
|
the server version string "12.045-rc1" has major version 12, minor
|
||||||
|
version 45, and suffix "rc1". A suffix may only consist of lowercase
|
||||||
|
letters and digits, and must start with a letter. The suffix may
|
||||||
|
be up to 4 characters. The major version may not be prefixed with
|
||||||
|
extra leading zeroes.
|
||||||
|
|
||||||
|
The suffix for a new official release is usually omitted. If hotfixes
|
||||||
|
are added to official releases they get a single leter suffix.
|
||||||
|
|
||||||
|
Release candidates are marked with suffixes starting with "rc" and
|
||||||
|
followed by a number starting from 1 to indicate the first
|
||||||
|
release candidate, with subsequent release candidates incrementing
|
||||||
|
the number. A final release candidate which becomes an official
|
||||||
|
release loses the suffix. The next release candidate will have a
|
||||||
|
new major or minor version number, and start back at "rc1".
|
||||||
|
*/
|
||||||
|
static String const& getVersionString ();
|
||||||
|
|
||||||
|
/** Full server version string.
|
||||||
|
|
||||||
|
This includes the name of the server. It is used in the peer
|
||||||
|
protocol hello message and also the headers of some HTTP replies.
|
||||||
|
*/
|
||||||
|
static char const* getFullVersionString ();
|
||||||
|
|
||||||
|
/** The server version's components. */
|
||||||
|
struct Version
|
||||||
|
{
|
||||||
|
int vmajor; // 0+
|
||||||
|
int vminor; // 0-999
|
||||||
|
String suffix; // Can be empty
|
||||||
|
|
||||||
|
//----
|
||||||
|
|
||||||
|
Version ();
|
||||||
|
|
||||||
|
/** Convert a string to components.
|
||||||
|
@return `false` if the string is improperly formatted.
|
||||||
|
*/
|
||||||
|
bool parse (String const& s);
|
||||||
|
|
||||||
|
/** Convert the components to a string. */
|
||||||
|
String print () const noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** The wire protocol version.
|
||||||
|
|
||||||
|
The version consists of two unsigned 16 bit integers representing
|
||||||
|
major and minor version numbers. All values are permissible.
|
||||||
|
*/
|
||||||
|
struct Protocol
|
||||||
|
{
|
||||||
|
unsigned short vmajor;
|
||||||
|
unsigned short vminor;
|
||||||
|
|
||||||
|
//----
|
||||||
|
|
||||||
|
/** The serialized format of the protocol version. */
|
||||||
|
typedef uint32 PackedFormat;
|
||||||
|
|
||||||
|
Protocol ();
|
||||||
|
Protocol (unsigned short vmajor, unsigned short vminor);
|
||||||
|
explicit Protocol (PackedFormat packedVersion);
|
||||||
|
|
||||||
|
PackedFormat toPacked () const noexcept;
|
||||||
|
|
||||||
|
std::string toStdString () const noexcept;
|
||||||
|
|
||||||
|
bool operator== (Protocol const& other) const noexcept { return toPacked () == other.toPacked (); }
|
||||||
|
bool operator!= (Protocol const& other) const noexcept { return toPacked () != other.toPacked (); }
|
||||||
|
bool operator>= (Protocol const& other) const noexcept { return toPacked () >= other.toPacked (); }
|
||||||
|
bool operator<= (Protocol const& other) const noexcept { return toPacked () <= other.toPacked (); }
|
||||||
|
bool operator> (Protocol const& other) const noexcept { return toPacked () > other.toPacked (); }
|
||||||
|
bool operator< (Protocol const& other) const noexcept { return toPacked () < other.toPacked (); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The protocol version we speak and prefer. */
|
||||||
|
static Protocol const& getCurrentProtocol ();
|
||||||
|
|
||||||
|
/** The oldest protocol version we will accept. */
|
||||||
|
static Protocol const& getMinimumProtocol ();
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// DEPRECATED STUFF
|
||||||
|
//
|
||||||
|
|
||||||
|
/** Retrieve the build version number.
|
||||||
|
|
||||||
|
This is typically incremented when an official version is publshed
|
||||||
|
with a list of changes.
|
||||||
|
|
||||||
|
Format is:
|
||||||
|
|
||||||
|
<major>.<minor>.<bugfix>
|
||||||
|
*/
|
||||||
|
static char const* getBuildVersion ()
|
||||||
|
{
|
||||||
|
return "0.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Retrieve the client API version number.
|
||||||
|
|
||||||
|
The client API version is incremented whenever a new feature
|
||||||
|
or breaking change is made to the websocket / RPC interface.
|
||||||
|
|
||||||
|
Format is:
|
||||||
|
|
||||||
|
<version-number>
|
||||||
|
*/
|
||||||
|
static char const* getClientVersion ()
|
||||||
|
{
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef RIPPLE_BUILDVERSION_RIPPLEHEADER
|
|
||||||
#define RIPPLE_BUILDVERSION_RIPPLEHEADER
|
|
||||||
|
|
||||||
/** Versioning information for the build.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class BuildVersion
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Retrieve the build version number.
|
|
||||||
|
|
||||||
This is typically incremented when an official version is publshed
|
|
||||||
with a list of changes.
|
|
||||||
|
|
||||||
Format is:
|
|
||||||
|
|
||||||
<major>.<minor>.<bugfix>
|
|
||||||
*/
|
|
||||||
static char const* getBuildVersion ()
|
|
||||||
{
|
|
||||||
return "0.0.1";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Retrieve the client API version number.
|
|
||||||
|
|
||||||
The client API version is incremented whenever a new feature
|
|
||||||
or breaking change is made to the websocket / RPC interface.
|
|
||||||
|
|
||||||
Format is:
|
|
||||||
|
|
||||||
<version-number>
|
|
||||||
*/
|
|
||||||
static char const* getClientVersion ()
|
|
||||||
{
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef RIPPLE_VERSION_H
|
|
||||||
#define RIPPLE_VERSION_H
|
|
||||||
|
|
||||||
//
|
|
||||||
// Versions
|
|
||||||
//
|
|
||||||
|
|
||||||
// VFALCO TODO Roll this together into ripple_BuildVersion
|
|
||||||
#define SERVER_VERSION_MAJOR 0
|
|
||||||
#define SERVER_VERSION_MINOR 9
|
|
||||||
#define SERVER_VERSION_SUB "-e"
|
|
||||||
#define SERVER_NAME "Ripple"
|
|
||||||
|
|
||||||
#define SV_STRINGIZE(x) SV_STRINGIZE2(x)
|
|
||||||
#define SV_STRINGIZE2(x) #x
|
|
||||||
#define SERVER_VERSION \
|
|
||||||
(SERVER_NAME "-" SV_STRINGIZE(SERVER_VERSION_MAJOR) "." SV_STRINGIZE(SERVER_VERSION_MINOR) SERVER_VERSION_SUB)
|
|
||||||
|
|
||||||
// Version we prefer to speak:
|
|
||||||
#define PROTO_VERSION_MAJOR 1
|
|
||||||
#define PROTO_VERSION_MINOR 2
|
|
||||||
|
|
||||||
// Version we will speak to:
|
|
||||||
#define MIN_PROTO_MAJOR 1
|
|
||||||
#define MIN_PROTO_MINOR 2
|
|
||||||
|
|
||||||
#define MAKE_VERSION_INT(maj,min) ((maj << 16) | min)
|
|
||||||
#define GET_VERSION_MAJOR(ver) (ver >> 16)
|
|
||||||
#define GET_VERSION_MINOR(ver) (ver & 0xff)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// vim:ts=4
|
|
||||||
@@ -1391,8 +1391,8 @@ Json::Value NetworkOPs::getServerInfo (bool human, bool admin)
|
|||||||
{
|
{
|
||||||
Json::Value info = Json::objectValue;
|
Json::Value info = Json::objectValue;
|
||||||
|
|
||||||
info ["build_version"] = BuildVersion::getBuildVersion ();
|
info ["build_version"] = BuildInfo::getBuildVersion ();
|
||||||
info ["client_version"] = BuildVersion::getClientVersion ();
|
info ["client_version"] = BuildInfo::getClientVersion ();
|
||||||
|
|
||||||
if (getConfig ().TESTNET)
|
if (getConfig ().TESTNET)
|
||||||
info["testnet"] = getConfig ().TESTNET;
|
info["testnet"] = getConfig ().TESTNET;
|
||||||
|
|||||||
@@ -972,11 +972,11 @@ void PeerImp::recvHello (protocol::TMHello& packet)
|
|||||||
WriteLog (lsINFO, Peer) << "Recv(Hello): " << getIP () << " :Clock far off -" << ourTime - packet.nettime ();
|
WriteLog (lsINFO, Peer) << "Recv(Hello): " << getIP () << " :Clock far off -" << ourTime - packet.nettime ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (packet.protoversionmin () > MAKE_VERSION_INT (PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR))
|
else if (packet.protoversionmin () > BuildInfo::getCurrentProtocol().toPacked ())
|
||||||
{
|
{
|
||||||
WriteLog (lsINFO, Peer) << "Recv(Hello): Server requires protocol version " <<
|
WriteLog (lsINFO, Peer) <<
|
||||||
GET_VERSION_MAJOR (packet.protoversion ()) << "." << GET_VERSION_MINOR (packet.protoversion ())
|
"Recv(Hello): Server requires protocol version " << BuildInfo::Protocol (packet.protoversion()).toStdString () <<
|
||||||
<< " we run " << PROTO_VERSION_MAJOR << "." << PROTO_VERSION_MINOR;
|
", we run " << BuildInfo::getCurrentProtocol().toStdString ();
|
||||||
}
|
}
|
||||||
else if (!mNodePublic.setNodePublic (packet.nodepublic ()))
|
else if (!mNodePublic.setNodePublic (packet.nodepublic ()))
|
||||||
{
|
{
|
||||||
@@ -991,9 +991,8 @@ void PeerImp::recvHello (protocol::TMHello& packet)
|
|||||||
{
|
{
|
||||||
// Successful connection.
|
// Successful connection.
|
||||||
WriteLog (lsINFO, Peer) << "Recv(Hello): Connect: " << mNodePublic.humanNodePublic ();
|
WriteLog (lsINFO, Peer) << "Recv(Hello): Connect: " << mNodePublic.humanNodePublic ();
|
||||||
CondLog (packet.protoversion () != MAKE_VERSION_INT (PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR), lsINFO, Peer)
|
CondLog (BuildInfo::Protocol (packet.protoversion()) != BuildInfo::getCurrentProtocol(), lsINFO, Peer) <<
|
||||||
<< "Peer speaks version " <<
|
"Peer speaks version " << BuildInfo::Protocol (packet.protoversion()).toStdString ();
|
||||||
(packet.protoversion () >> 16) << "." << (packet.protoversion () & 0xFF);
|
|
||||||
mHello = packet;
|
mHello = packet;
|
||||||
|
|
||||||
if (getApp().getUNL ().nodeInCluster (mNodePublic, mNodeName))
|
if (getApp().getUNL ().nodeInCluster (mNodePublic, mNodeName))
|
||||||
@@ -2239,9 +2238,9 @@ void PeerImp::sendHello ()
|
|||||||
|
|
||||||
protocol::TMHello h;
|
protocol::TMHello h;
|
||||||
|
|
||||||
h.set_protoversion (MAKE_VERSION_INT (PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR));
|
h.set_protoversion (BuildInfo::getCurrentProtocol().toPacked ());
|
||||||
h.set_protoversionmin (MAKE_VERSION_INT (MIN_PROTO_MAJOR, MIN_PROTO_MINOR));
|
h.set_protoversionmin (BuildInfo::getMinimumProtocol().toPacked ());
|
||||||
h.set_fullversion (SERVER_VERSION);
|
h.set_fullversion (BuildInfo::getFullVersionString ());
|
||||||
h.set_nettime (getApp().getOPs ().getNetworkTimeNC ());
|
h.set_nettime (getApp().getOPs ().getNetworkTimeNC ());
|
||||||
h.set_nodepublic (getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ());
|
h.set_nodepublic (getApp().getLocalCredentials ().getNodePublic ().humanNodePublic ());
|
||||||
h.set_nodeproof (&vchSig[0], vchSig.size ());
|
h.set_nodeproof (&vchSig[0], vchSig.size ());
|
||||||
@@ -2410,9 +2409,10 @@ Json::Value PeerImp::getJson ()
|
|||||||
ret["version"] = mHello.fullversion ();
|
ret["version"] = mHello.fullversion ();
|
||||||
|
|
||||||
if (mHello.has_protoversion () &&
|
if (mHello.has_protoversion () &&
|
||||||
(mHello.protoversion () != MAKE_VERSION_INT (PROTO_VERSION_MAJOR, PROTO_VERSION_MINOR)))
|
(mHello.protoversion () != BuildInfo::getCurrentProtocol().toPacked ()))
|
||||||
ret["protocol"] = lexicalCastThrow <std::string> (GET_VERSION_MAJOR (mHello.protoversion ())) + "." +
|
{
|
||||||
lexicalCastThrow <std::string> (GET_VERSION_MINOR (mHello.protoversion ()));
|
ret["protocol"] = BuildInfo::Protocol (mHello.protoversion ()).toStdString ();
|
||||||
|
}
|
||||||
|
|
||||||
if (!!mClosedLedgerHash)
|
if (!!mClosedLedgerHash)
|
||||||
ret["ledger"] = mClosedLedgerHash.GetHex ();
|
ret["ledger"] = mClosedLedgerHash.GetHex ();
|
||||||
|
|||||||
@@ -195,8 +195,7 @@ namespace ripple
|
|||||||
#include "contracts/ripple_Interpreter.h"
|
#include "contracts/ripple_Interpreter.h"
|
||||||
#include "contracts/ripple_Operation.h"
|
#include "contracts/ripple_Operation.h"
|
||||||
|
|
||||||
#include "basics/ripple_Version.h" // VFALCO TODO Should this be private?
|
#include "basics/ripple_BuildInfo.h" // private
|
||||||
#include "basics/ripple_BuildVersion.h" // private
|
|
||||||
#include "basics/ripple_RPCServerHandler.h"
|
#include "basics/ripple_RPCServerHandler.h"
|
||||||
|
|
||||||
#include "rpc/RPCDoor.h" // needs RPCServer
|
#include "rpc/RPCDoor.h" // needs RPCServer
|
||||||
@@ -244,6 +243,7 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
|
|||||||
|
|
||||||
#if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 1
|
#if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 1
|
||||||
|
|
||||||
|
#include "basics/ripple_BuildInfo.cpp"
|
||||||
#include "basics/ripple_RPCServerHandler.cpp"
|
#include "basics/ripple_RPCServerHandler.cpp"
|
||||||
#include "node/ripple_NodeObject.cpp"
|
#include "node/ripple_NodeObject.cpp"
|
||||||
#include "node/ripple_NodeStore.cpp"
|
#include "node/ripple_NodeStore.cpp"
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ std::string HTTPReply (int nStatus, const std::string& strMsg)
|
|||||||
rfc1123Time ().c_str (),
|
rfc1123Time ().c_str (),
|
||||||
access.c_str (),
|
access.c_str (),
|
||||||
strMsg.size () + 2,
|
strMsg.size () + 2,
|
||||||
SERVER_VERSION,
|
//SERVER_VERSION,
|
||||||
|
BuildInfo::getFullVersionString (),
|
||||||
strMsg.c_str ());
|
strMsg.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user