Compare commits

..

13 Commits

Author SHA1 Message Date
Mark Travis
ddf68d464d Set version to 0.25.2 2014-07-07 12:41:46 -07:00
JoelKatz
b2f19e8dc6 Find 'sabfd' paths
This permits USD/GW1 to be bridged to USD/GW2 by BTC/GW3 or
USD/GW1 to be bridged to BTC/GW2 by CNY/GW3. See RIPD-335.
2014-07-07 12:41:46 -07:00
David Schwartz
5714b42975 Impose a local limit on path lengths 2014-07-07 11:42:24 -07:00
David Schwartz
c4e9c49c10 Set version to 0.25.2-rc2 2014-07-07 11:33:26 -07:00
Mark Travis
9210efb051 In JSON, output unprintable currency codes as hex 2014-07-07 11:33:26 -07:00
Tom Ritchford
b9f1b05625 Use swapWith to save CPU; edit comment. 2014-07-07 11:33:26 -07:00
sublimator
828c2e3c71 Restore checkpointed ledger under all paths in PathFind. 2014-07-07 11:33:12 -07:00
David Schwartz
d06092212f Tighten up some serialization checks 2014-06-30 16:53:38 -07:00
Mark Travis
e70d618aff Set version to 0.25.2-rc1 2014-06-01 22:51:13 +00:00
Mark Travis
3e4cf426bd Detect paths with illegal bridging offers 2014-06-01 22:45:55 +00:00
Vinnie Falco
b677cacb8c Set version to 0.25.1 2014-05-15 11:13:54 -07:00
Nik Bougalis
1d66169ef1 Fix rippled-example.cfg to list 'peers_max' 2014-05-15 11:11:16 -07:00
Vinnie Falco
74653e57e6 Use std::string in lexicalCast 2014-05-15 11:11:15 -07:00
20 changed files with 251 additions and 277 deletions

View File

@@ -490,6 +490,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\ByteOrder.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@@ -510,18 +514,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\UInt128.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\UInt160.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\UInt256.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\ripple_types.cpp" />
<ClCompile Include="..\..\src\ripple\validators\impl\Manager.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1834,7 +1830,7 @@
<ClInclude Include="..\..\src\ripple\common\RippleSSLContext.h" />
<ClInclude Include="..\..\src\ripple\common\seconds_clock.h" />
<ClInclude Include="..\..\src\ripple\common\TaggedCache.h" />
<ClInclude Include="..\..\src\ripple\common\UnorderedMap.h" />
<ClInclude Include="..\..\src\ripple\common\UnorderedContainers.h" />
<ClInclude Include="..\..\src\ripple\http\api\Handler.h" />
<ClInclude Include="..\..\src\ripple\http\api\Server.h" />
<ClInclude Include="..\..\src\ripple\http\api\Port.h" />
@@ -2042,9 +2038,7 @@
<ClInclude Include="..\..\src\ripple\types\api\RipplePublicKeyHash.h" />
<ClInclude Include="..\..\src\ripple\types\api\SimpleIdentifier.h" />
<ClInclude Include="..\..\src\ripple\types\api\strHex.h" />
<ClInclude Include="..\..\src\ripple\types\api\UInt128.h" />
<ClInclude Include="..\..\src\ripple\types\api\UInt160.h" />
<ClInclude Include="..\..\src\ripple\types\api\UInt256.h" />
<ClInclude Include="..\..\src\ripple\types\ripple_types.h" />
<ClInclude Include="..\..\src\ripple\validators\api\Source.h" />
<ClInclude Include="..\..\src\ripple\validators\api\Types.h" />
@@ -2154,7 +2148,6 @@
<ClInclude Include="..\..\src\ripple_app\transactors\CreateOffer.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\CreateOfferDirect.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\CreateOfferBridged.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\CreateOfferOriginal.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\Payment.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\SetRegularKey.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\Transactor.h" />

View File

@@ -1008,12 +1008,6 @@
<ClCompile Include="..\..\src\ripple\sslutil\impl\CBigNum.cpp">
<Filter>[1] Ripple\sslutil\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\UInt256.cpp">
<Filter>[1] Ripple\types\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\UInt128.cpp">
<Filter>[1] Ripple\types\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\ByteOrder.cpp">
<Filter>[1] Ripple\types\impl</Filter>
</ClCompile>
@@ -1743,6 +1737,9 @@
<ClCompile Include="..\..\src\ripple\common\tests\cross_offer.test.cpp">
<Filter>[1] Ripple\common\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
<Filter>[1] Ripple\types\impl</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\ripple_basics\containers\RangeSet.h">
@@ -2570,15 +2567,9 @@
<ClInclude Include="..\..\src\ripple\sslutil\api\bignum_error.h">
<Filter>[1] Ripple\sslutil\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\types\api\UInt256.h">
<Filter>[1] Ripple\types\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\types\api\base_uint.h">
<Filter>[1] Ripple\types\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\types\api\UInt128.h">
<Filter>[1] Ripple\types\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\types\api\UInt160.h">
<Filter>[1] Ripple\types\api</Filter>
</ClInclude>
@@ -3254,9 +3245,6 @@
<ClInclude Include="..\..\src\ripple_app\transactors\CreateOfferBridged.h">
<Filter>[2] Old Ripple\ripple_app\transactors</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\transactors\CreateOfferOriginal.h">
<Filter>[2] Old Ripple\ripple_app\transactors</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\transactors\Payment.h">
<Filter>[2] Old Ripple\ripple_app\transactors</Filter>
</ClInclude>
@@ -3339,9 +3327,6 @@
<ClInclude Include="..\..\src\ripple_overlay\api\Overlay.h">
<Filter>[2] Old Ripple\ripple_overlay\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\common\UnorderedMap.h">
<Filter>[1] Ripple\common</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_rpc\impl\LookupLedger.h">
<Filter>[2] Old Ripple\ripple_rpc\impl</Filter>
</ClInclude>
@@ -3378,6 +3363,9 @@
<ClInclude Include="..\..\src\ripple\common\jsonrpc_fields.h">
<Filter>[1] Ripple\common</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\common\UnorderedContainers.h">
<Filter>[1] Ripple\common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\doc\CheatSheet.md">

View File

@@ -1,5 +1,5 @@
Name: rippled
Version: 0.24.0
Version: 0.25.2
Release: 1%{?dist}
Summary: Ripple peer-to-peer network daemon

View File

@@ -136,10 +136,10 @@
#
#
#
# [max_peers]
# [peers_max]
#
# The largest number of desired peer connections (incoming or outgoing).
# Cluster and fixed peers do not count towards this total. There are
# The largest number of desired peer connections (incoming or outgoing).
# Cluster and fixed peers do not count towards this total. There are
# implementation-defined lower limits imposed on this value for security
# purposes.
#

View File

@@ -21,43 +21,6 @@
namespace beast {
unsigned char const LexicalCastUtilities::s_digitTable [256] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xFF - 0x07
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x08 - 0x0F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x10 - 0x17
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x18 - 0x1F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x20 - 0x27
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x28 - 0x2F
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 0x30 - 0x37
0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x38 - 0x3F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x40 - 0x47
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x48 - 0x4F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x50 - 0x57
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x58 - 0x5F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x60 - 0x67
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x68 - 0x6F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x70 - 0x77
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x78 - 0x7F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x80 - 0x87
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x88 - 0x8F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x90 - 0x97
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0x98 - 0x9F
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xA0 - 0xA7
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xA8 - 0xAF
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xB0 - 0xB7
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xB8 - 0xBF
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xC0 - 0xC7
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xC8 - 0xCF
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xD0 - 0xD7
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xD8 - 0xDF
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xE0 - 0xE7
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xE8 - 0xEF
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xF0 - 0xF7
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 0xF8 - 0xFF
};
//------------------------------------------------------------------------------
class LexicalCast_test : public unit_test::suite
{
public:
@@ -70,7 +33,7 @@ public:
template <class IntType>
void testInteger (IntType in)
{
String s;
std::string s;
IntType out (in+1);
expect (lexicalCastChecked (s, in));
@@ -105,6 +68,20 @@ public:
}
}
void testPathologies()
{
testcase("pathologies");
try
{
lexicalCastThrow<int>("\xef\xbc\x91\xef\xbc\x90"); // utf-8 encoded
fail("Should throw");
}
catch(BadLexicalCast const&)
{
pass();
}
}
void run()
{
std::int64_t const seedValue = 50;
@@ -119,6 +96,8 @@ public:
testIntegers <std::uint32_t> (r);
testIntegers <std::int64_t> (r);
testIntegers <std::uint64_t> (r);
testPathologies();
}
};

View File

@@ -20,221 +20,144 @@
#ifndef BEAST_LEXICALCAST_H_INCLUDED
#define BEAST_LEXICALCAST_H_INCLUDED
namespace beast
#include <string>
#include "../../../beast/cxx14/type_traits.h" // <type_traits>
#include <cerrno>
#include <cstdlib>
#include <limits>
#include <utility>
namespace beast {
namespace detail {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4800)
#pragma warning(disable: 4804)
#endif
template <class IntType>
bool
parseSigned (IntType& result, char const* begin, char const* end)
{
static_assert(std::is_signed<IntType>::value, "");
char* ptr;
auto errno_save = errno;
errno = 0;
long long r = std::strtoll(begin, &ptr, 10);
std::swap(errno, errno_save);
errno_save = ptr != end;
if (errno_save == 0)
{
if (std::numeric_limits<IntType>::min() <= r &&
r <= std::numeric_limits<IntType>::max())
result = static_cast<IntType>(r);
else
errno_save = 1;
}
return errno_save == 0;
}
// Base class with utility functions
struct LexicalCastUtilities
template <class UIntType>
bool
parseUnsigned (UIntType& result, char const* begin, char const* end)
{
static unsigned char const s_digitTable [256];
// strict string to integer parser
template <class IntType, class InputIterator>
static inline bool parseSigned (IntType& result, InputIterator begin, InputIterator end)
static_assert(std::is_unsigned<UIntType>::value, "");
char* ptr;
auto errno_save = errno;
errno = 0;
unsigned long long r = std::strtoull(begin, &ptr, 10);
std::swap(errno, errno_save);
errno_save = ptr != end;
if (errno_save == 0)
{
if (0 == std::distance (begin, end))
return false;
std::uint64_t accum = 0;
InputIterator it = begin;
// process sign
bool negative = false;
if ('+' == *it)
{
++it;
}
else if ('-' == *it)
{
++it;
negative = true;
}
if (end == it)
return false;
// calc max of abs value
std::uint64_t max;
if (negative)
max = static_cast <std::uint64_t> (
-(static_cast <std::int64_t> (std::numeric_limits <IntType>::min ())));
if (r <= std::numeric_limits<UIntType>::max())
result = static_cast<UIntType>(r);
else
max = std::numeric_limits <IntType>::max ();
// process digits
while (end != it)
{
std::uint64_t const digit = static_cast <IntType> (
s_digitTable [static_cast <unsigned int> (*it++)]);
if (0xFF == digit)
return false;
std::uint64_t const overflow = (max - digit) / 10;
if (accum > overflow)
return false;
accum = (10 * accum) + digit;
}
if (negative)
{
result = -static_cast <IntType> (accum);
}
else
{
result = static_cast <IntType> (accum);
}
return true;
errno_save = 1;
}
template <class IntType, class InputIterator>
static inline bool parseUnsigned (IntType& result, InputIterator begin, InputIterator end)
{
if (0 == std::distance (begin, end))
return false;
std::uint64_t accum = 0;
InputIterator it = begin;
std::uint64_t const max = std::numeric_limits <IntType>::max ();
// process digits
while (end != it)
{
std::uint64_t const digit = static_cast <IntType> (
s_digitTable [static_cast <unsigned int> (*it++)]);
if (0xFF == digit)
return false;
std::uint64_t const overflow = (max - digit) / 10;
if (accum > overflow)
return false;
accum = (10 * accum) + digit;
}
result = static_cast <IntType> (accum);
return true;
}
};
return errno_save == 0;
}
//------------------------------------------------------------------------------
/** This is thrown when a conversion is not possible.
Only used in the throw variants of lexicalCast.
*/
struct BadLexicalCast : public std::bad_cast
{
};
// These specializatons get called by the non-member functions to do the work
template <class Out, class In>
struct LexicalCast;
// conversion to String
template <class In>
struct LexicalCast <String, In>
{
bool operator() (String& out, int in) const { out = String (in); return true; }
bool operator() (String& out, unsigned int in) const { out = String (in); return true; }
bool operator() (String& out, short in) const { out = String (in); return true; }
bool operator() (String& out, unsigned short in) const { out = String (in); return true; }
bool operator() (String& out, std::int64_t in) const { out = String (in); return true; }
bool operator() (String& out, std::uint64_t in) const { out = String (in); return true; }
bool operator() (String& out, float in) const { out = String (in); return true; }
bool operator() (String& out, double in) const { out = String (in); return true; }
};
// Parse String to number
template <class Out>
struct LexicalCast <Out, String>
{
bool operator() (int& out, String const& in) const { std::string const& s (in.toStdString ()); return LexicalCastUtilities::parseSigned (out, s.begin (), s.end ()); }
bool operator() (short& out, String const& in) const { std::string const& s (in.toStdString ()); return LexicalCastUtilities::parseSigned (out, s.begin (), s.end ()); }
bool operator() (std::int64_t& out, String const& in) const { std::string const& s (in.toStdString ()); return LexicalCastUtilities::parseSigned (out, s.begin (), s.end ()); }
bool operator() (unsigned int& out, String const& in) const { std::string const& s (in.toStdString ()); return LexicalCastUtilities::parseUnsigned (out, s.begin (), s.end ()); }
bool operator() (unsigned short& out, String const& in) const { std::string const& s (in.toStdString ()); return LexicalCastUtilities::parseUnsigned (out, s.begin (), s.end ()); }
bool operator() (std::uint64_t& out, String const& in) const { std::string const& s (in.toStdString ()); return LexicalCastUtilities::parseUnsigned (out, s.begin (), s.end ()); }
bool operator() (float& out, String const& in) const { bassertfalse; return false; /* UNIMPLEMENTED! */ }
bool operator() (double& out, String const& in) const { bassertfalse; return false; /* UNIMPLEMENTED! */ }
bool operator () (bool& out, String const& in) const
{
// boost::lexical_cast is very strict, it
// throws on anything but "1" or "0"
//
if (in == "1")
{
out = true;
return true;
}
else if (in == "0")
{
out = false;
return true;
}
return false;
}
};
//------------------------------------------------------------------------------
// Conversion to std::string
// conversion to std::string
template <class In>
struct LexicalCast <std::string, In>
{
bool operator() (std::string& out, In in) const
{
String s;
if (LexicalCast <String, In> () (s, in))
{
out = s.toStdString ();
return true;
}
return false;
}
bool operator() (std::string& out, short in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, int in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, long in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, long long in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, unsigned short in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, unsigned int in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, unsigned long in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, unsigned long long in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, float in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, double in) { out = std::to_string(in); return true; }
bool operator() (std::string& out, long double in) { out = std::to_string(in); return true; }
};
// Conversion from std::string
// Parse std::string to number
template <class Out>
struct LexicalCast <Out, std::string>
{
bool operator() (Out& out, std::string const& in) const
{
Out result;
if (LexicalCast <Out, String> () (result, String (in.c_str ())))
{
out = result;
return true;
}
return false;
}
bool operator() (short& out, std::string const& in) const { return parseSigned (out, in.data(), in.data()+in.size()); }
bool operator() (int& out, std::string const& in) const { return parseSigned (out, in.data(), in.data()+in.size()); }
bool operator() (long& out, std::string const& in) const { return parseSigned (out, in.data(), in.data()+in.size()); }
bool operator() (long long& out, std::string const& in) const { return parseSigned (out, in.data(), in.data()+in.size()); }
bool operator() (unsigned short& out, std::string const& in) const { return parseUnsigned (out, in.data(), in.data()+in.size()); }
bool operator() (unsigned int& out, std::string const& in) const { return parseUnsigned (out, in.data(), in.data()+in.size()); }
bool operator() (unsigned long& out, std::string const& in) const { return parseUnsigned (out, in.data(), in.data()+in.size()); }
bool operator() (unsigned long long& out, std::string const& in) const { return parseUnsigned (out, in.data(), in.data()+in.size()); }
bool operator() (float& out, std::string const& in) const { bassertfalse; return false; /* UNIMPLEMENTED! */ }
bool operator() (double& out, std::string const& in) const { bassertfalse; return false; /* UNIMPLEMENTED! */ }
bool operator() (long double& out, std::string const& in) const { bassertfalse; return false; /* UNIMPLEMENTED! */ }
#if 0
bool operator() (bool& out, std::string const& in) const;
#else
bool operator() (bool& out, std::string const& in) const { return parseUnsigned (out, in.data(), in.data()+in.size()); }
#endif
};
#if 0
template <class Out>
bool
LexicalCast <Out, std::string>::operator() (bool& out, std::string const& in) const
{
// boost::lexical_cast is very strict, it
// throws on anything but "1" or "0"
//
if (in == "1")
{
out = true;
return true;
}
else if (in == "0")
{
out = false;
return true;
}
return false;
}
#endif
//------------------------------------------------------------------------------
// Conversion from null terminated char const*
template <class Out>
struct LexicalCast <Out, char const*>
{
bool operator() (Out& out, char const* in) const
{
Out result;
if (LexicalCast <Out, String> () (result, String (in)))
{
out = result;
return true;
}
return false;
return LexicalCast <Out, std::string>()(out, in);
}
};
@@ -257,15 +180,28 @@ struct LexicalCast <Out, char*>
}
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} // detail
//------------------------------------------------------------------------------
/** Thrown when a conversion is not possible with LexicalCast.
Only used in the throw variants of lexicalCast.
*/
struct BadLexicalCast : public std::bad_cast
{
};
/** Intelligently convert from one type to another.
@return `false` if there was a parsing or range error
*/
template <class Out, class In>
bool lexicalCastChecked (Out& out, In in)
{
return LexicalCast <Out, In> () (out, in);
return detail::LexicalCast <Out, In> () (out, in);
}
/** Convert from one type to another, throw on error
@@ -283,8 +219,6 @@ Out lexicalCastThrow (In in)
return out;
throw BadLexicalCast ();
return Out ();
}
/** Convert from one type to another.

View File

@@ -356,13 +356,19 @@ TER PathState::pushNode (
if (!!pnCur.uCurrencyID != !!pnCur.uIssuerID)
{
WriteLog (lsDEBUG, RippleCalc) << "pushNode: currency is inconsistent with issuer.";
WriteLog (lsDEBUG, RippleCalc) <<
"pushNode: currency is inconsistent with issuer.";
terResult = temBAD_PATH;
}
else if (!!pnPrv.uAccountID)
else if (pnPrv.uCurrencyID == pnCur.uCurrencyID &&
pnPrv.uIssuerID == pnCur.uIssuerID)
{
WriteLog (lsDEBUG, RippleCalc) <<
"pushNode: bad path: offer to same currency and issuer";
terResult = temBAD_PATH;
}
else
{
// Previous is an account.
WriteLog (lsTRACE, RippleCalc) << "pushNode: imply for offer.";
// Insert intermediary issuer account if needed.

View File

@@ -914,6 +914,7 @@ void Pathfinder::initPathTable()
list.push_back(CostedPath_t(6, makePath("safad")));
list.push_back(CostedPath_t(6, makePath("saxfd"))); // source -> gateway -> book to XRP -> book -> destination
list.push_back(CostedPath_t(6, makePath("saxfad")));
list.push_back(CostedPath_t(6, makePath("sabfd"))); // source -> gateway -> book -> book -> destination
list.push_back(CostedPath_t(7, makePath("saaad")));
}
@@ -927,6 +928,7 @@ void Pathfinder::initPathTable()
list.push_back(CostedPath_t(5, makePath("saxfd")));
list.push_back(CostedPath_t(5, makePath("sxfad")));
list.push_back(CostedPath_t(6, makePath("saxfad")));
list.push_back(CostedPath_t(6, makePath("sabfd")));
list.push_back(CostedPath_t(7, makePath("saafd")));
list.push_back(CostedPath_t(8, makePath("saafad")));
list.push_back(CostedPath_t(9, makePath("safaad")));

View File

@@ -2617,7 +2617,7 @@ TER RippleCalc::rippleCalc (
while (temUNCERTAIN == terResult)
{
int iBest = -1;
const LedgerEntrySet lesCheckpoint = activeLedger;
LedgerEntrySet lesCheckpoint = activeLedger;
int iDry = 0;
// True, if ever computed multi-quality.
@@ -2819,6 +2819,10 @@ TER RippleCalc::rippleCalc (
}
else
{
// We must restore the activeLedger from lesCheckpoint in the case
// when iBest is -1 and just before the result is set to tesSUCCESS.
activeLedger.swapWith (lesCheckpoint);
terResult = tesSUCCESS;
}
}

View File

@@ -212,9 +212,14 @@ TER PaymentTransactor::doApply ()
try
{
bool const openLedger = is_bit_set (mParams, tapOPEN_LEDGER);
bool const tooManyPaths = spsPaths.size () > MaxPathSize;
terResult = openLedger && tooManyPaths
bool pathTooBig = spsPaths.size () > MaxPathSize;
for (auto const& path : spsPaths)
if (path.size () > MaxPathLength)
pathTooBig = true;
terResult = openLedger && pathTooBig
? telBAD_PATH_COUNT // Too many paths for proposed ledger.
: RippleCalc::rippleCalc (
mEngine->view (),

View File

@@ -37,6 +37,9 @@ class PaymentTransactor
/* The largest number of paths we allow */
static std::size_t const MaxPathSize = 6;
/* The longest path we allow */
static std::size_t const MaxPathLength = 8;
public:
PaymentTransactor (
SerializedTransaction const& txn,

View File

@@ -29,7 +29,7 @@ TransactionMetaSet::TransactionMetaSet (uint256 const& txid, std::uint32_t ledge
Serializer s (vec);
SerializerIterator sit (s);
std::unique_ptr<SerializedType> pobj = STObject::deserialize (sit, sfAffectedNodes);
std::unique_ptr<SerializedType> pobj = STObject::deserialize (sit, sfMetadata);
STObject* obj = static_cast<STObject*> (pobj.get ());
if (!obj)

View File

@@ -31,7 +31,7 @@ char const* BuildInfo::getRawVersionString ()
//
// The build version number (edit this for each release)
//
"0.25.0"
"0.25.2"
//
// Must follow the format described here:
//

View File

@@ -32,9 +32,10 @@ SField::StaticLockType& SField::getMutex ()
}
SField sfInvalid (-1), sfGeneric (0);
SField sfLedgerEntry (STI_LEDGERENTRY, 1, "LedgerEntry");
SField sfTransaction (STI_TRANSACTION, 1, "Transaction");
SField sfValidation (STI_VALIDATION, 1, "Validation");
SField sfLedgerEntry (STI_LEDGERENTRY, 257, "LedgerEntry");
SField sfTransaction (STI_TRANSACTION, 257, "Transaction");
SField sfValidation (STI_VALIDATION, 257, "Validation");
SField sfMetadata (STI_METADATA, 257, "Metadata");
SField sfHash (STI_HASH256, 257, "hash");
SField sfIndex (STI_HASH256, 258, "index");

View File

@@ -39,9 +39,11 @@ enum SerializedTypeID
#undef FIELD
// high level types
// cannot be serialized inside other types
STI_TRANSACTION = 10001,
STI_LEDGERENTRY = 10002,
STI_VALIDATION = 10003,
STI_METADATA = 10004,
};
/** Identifies fields.
@@ -239,7 +241,9 @@ protected:
SField (SerializedTypeID id, int val);
};
extern SField sfInvalid, sfGeneric, sfLedgerEntry, sfTransaction, sfValidation;
extern SField
sfInvalid, sfGeneric,
sfLedgerEntry, sfTransaction, sfValidation, sfMetadata;
#define FIELD(name, type, index) extern SField sf##name;
#define TYPE(name, type, index)

View File

@@ -223,6 +223,14 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency)
{
static uint160 const sIsoBits ("FFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFF");
// Characters we are willing to include the ASCII representation
// of a three-letter currency code
static std::string legalASCIICurrencyCharacters =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"<>(){}[]|?!@#$%^&*";
if (uCurrency.isZero ())
{
return SYSTEM_CURRENCY_CODE;
@@ -244,7 +252,8 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency)
// Specifying the system currency code using ISO-style representation
// is not allowed.
if (iso != SYSTEM_CURRENCY_CODE)
if ((iso != SYSTEM_CURRENCY_CODE) &&
(iso.find_first_not_of (legalASCIICurrencyCharacters) == std::string::npos))
return iso;
}

View File

@@ -705,7 +705,7 @@ bool STParsedJSON::parse (std::string const& json_name,
"[" << i << "]." << objectName;
bool const success (parse (ss.str (), objectFields,
nameField, depth + 1, sub_object_));
if (! success)
if (! success || (sub_object_->getFName().fieldType != STI_OBJECT))
return false;
}
tail->push_back (*sub_object_);

View File

@@ -277,6 +277,12 @@ bool STObject::set (SerializerIterator& sit, int depth)
reachedEndOfObject = (type == STI_OBJECT) && (field == 1);
if ((type == STI_ARRAY) && (field == 1))
{
WriteLog (lsWARNING, STObject) << "Encountered object with end of array marker";
throw std::runtime_error ("Illegal terminator in object");
}
if (!reachedEndOfObject)
{
// Figure out the field
@@ -361,6 +367,12 @@ void STObject::add (Serializer& s, bool withSigningFields) const
// insert them in sorted order
const SerializedType* field = it.second;
// When we serialize an object inside another object,
// the type associated by rule with this field name
// must be OBJECT, or the object cannot be deserialized
assert ((field->getSType() != STI_OBJECT) ||
(field->getFName().fieldType == STI_OBJECT));
field->addFieldID (s);
field->add (s);
@@ -1233,6 +1245,12 @@ STArray* STArray::construct (SerializerIterator& sit, SField::ref field)
if ((type == STI_ARRAY) && (field == 1))
break;
if ((type == STI_OBJECT) && (field == 1))
{
WriteLog (lsWARNING, STObject) << "Encountered array with end of object marker";
throw std::runtime_error ("Illegal terminator in array");
}
SField::ref fn = SField::getField (type, field);
if (fn.isInvalid ())
@@ -1241,6 +1259,12 @@ STArray* STArray::construct (SerializerIterator& sit, SField::ref field)
throw std::runtime_error ("Unknown field");
}
if (fn.fieldType != STI_OBJECT)
{
WriteLog (lsTRACE, STObject) << "Array contains non-object";
throw std::runtime_error ("Non-object in array");
}
value.push_back (new STObject (fn));
value.rbegin ()->set (sit, 1);
}

View File

@@ -353,6 +353,8 @@ STVector256* STVector256::construct (SerializerIterator& u, SField::ref name)
void STVector256::add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_VECTOR256);
s.addVL (mValue.empty () ? nullptr : mValue[0].begin (), mValue.size () * (256 / 8));
}
@@ -592,6 +594,8 @@ std::string STPathSet::getText () const
void STPathSet::add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_PATHSET);
bool bFirst = true;
BOOST_FOREACH (const STPath & spPath, value)

View File

@@ -146,13 +146,14 @@ public:
virtual void add (Serializer& s) const
{
;
assert (false);
}
virtual bool isEquivalent (const SerializedType& t) const;
void addFieldID (Serializer& s) const
{
assert (fName->isBinary ());
s.addFieldID (fName->fieldType, fName->fieldValue);
}
@@ -247,6 +248,8 @@ public:
Json::Value getJson (int) const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_UINT8);
s.add8 (value);
}
@@ -306,6 +309,8 @@ public:
Json::Value getJson (int) const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_UINT16);
s.add16 (value);
}
@@ -365,6 +370,8 @@ public:
Json::Value getJson (int) const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_UINT32);
s.add32 (value);
}
@@ -423,6 +430,8 @@ public:
Json::Value getJson (int) const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_UINT64);
s.add64 (value);
}
@@ -881,6 +890,8 @@ public:
virtual std::string getText () const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_HASH128);
s.add128 (value);
}
@@ -954,6 +965,8 @@ public:
virtual std::string getText () const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_HASH160);
s.add160 (value);
}
@@ -1027,6 +1040,8 @@ public:
std::string getText () const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert (fName->fieldType == STI_HASH256);
s.add256 (value);
}
@@ -1094,6 +1109,9 @@ public:
virtual std::string getText () const;
void add (Serializer& s) const
{
assert (fName->isBinary ());
assert ((fName->fieldType == STI_VL) ||
(fName->fieldType == STI_ACCOUNT));
s.addVL (value);
}