diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj
index f3cf873f5e..920216882d 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj
+++ b/Builds/VisualStudio2012/RippleD.vcxproj
@@ -130,7 +130,7 @@
true
true
-
+
true
true
true
@@ -1614,17 +1614,19 @@
-
-
+
+
-
+
+
+
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters
index ca047f8d84..ef790e4ab7 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters
@@ -1056,7 +1056,7 @@
[2] Old Ripple\ripple_app\peers
-
+
[1] Ripple\types\impl
@@ -2085,15 +2085,6 @@
[1] Ripple\types\api
-
- [1] Ripple\types\api
-
-
- [1] Ripple\types\api
-
-
- [1] Ripple\types\api
-
[1] Ripple\types\api
@@ -2106,6 +2097,21 @@
[1] Ripple\types\api
+
+ [1] Ripple\types\api
+
+
+ [1] Ripple\types\api
+
+
+ [1] Ripple\types\api
+
+
+ [1] Ripple\types\api
+
+
+ [1] Ripple\types\api
+
diff --git a/doc/todo/VFALCO_TODO.txt b/doc/todo/VFALCO_TODO.txt
index 461d1da01a..c2fdb8c3e0 100644
--- a/doc/todo/VFALCO_TODO.txt
+++ b/doc/todo/VFALCO_TODO.txt
@@ -3,11 +3,14 @@ RIPPLE TODO
--------------------------------------------------------------------------------
Vinnie's List: Changes day to day, descending priority
-- Finish RPCAsyncServer, RPCService and RPCService::Manager
-- Fix and tidy up broken beast classes
- Parse Validator line using cribbed code
- Parse ContentBodyBuffer from HTTPResponse
-- Look into using CMake
+- HTTPMessage improvements
+- HTTPClient improvements based on HTTPServer
+- Ditch old HTTPClient so I can take the name
+- Finish RPCAsyncServer, RPCService and RPCService::Manager
+- Fix and tidy up broken beast classes
+- Fix RPCDoor to respect config setting for [rpc_secure]
- Validators should delay the application of newly downloaded lists from
sources, to mitigate the effects of attacks. Unless there's no validators
in the list.
@@ -15,9 +18,7 @@ Vinnie's List: Changes day to day, descending priority
manually revisit sources, etc...
- Clean up calculation of COnfig file location.
- Remove TESTNET and all related code and settings.
-- Fix RPCDoor to respect config setting for [rpc_secure]
- Remove addRpcSub, findRpcSub, and notify the appropriate partner(s)
-- Make RPCHandler/Server asynchronous
David Features:
- override config items from command line
@@ -25,6 +26,8 @@ David Features:
--------------------------------------------------------------------------------
+- Look into using CMake
+
- IPv6 support in IPEndpoint
- Configuration list for Jenkins
diff --git a/src/ripple/types/api/RippleCryptoIdentifier.h b/src/ripple/types/api/CryptoIdentifier.h
similarity index 90%
rename from src/ripple/types/api/RippleCryptoIdentifier.h
rename to src/ripple/types/api/CryptoIdentifier.h
index add834a67e..f5f9cb89bf 100644
--- a/src/ripple/types/api/RippleCryptoIdentifier.h
+++ b/src/ripple/types/api/CryptoIdentifier.h
@@ -4,8 +4,8 @@
*/
//==============================================================================
-#ifndef RIPPLE_TYPES_RIPPLECRYPTOIDENTIFIER_H_INCLUDED
-#define RIPPLE_TYPES_RIPPLECRYPTOIDENTIFIER_H_INCLUDED
+#ifndef RIPPLE_TYPES_CRYPTOIDENTIFIER_H_INCLUDED
+#define RIPPLE_TYPES_CRYPTOIDENTIFIER_H_INCLUDED
#include "beast/beast/FixedArray.h"
#include "beast/beast/intrusive/IntrusiveArray.h"
@@ -13,11 +13,11 @@
#include "Base58.h"
-#include "CryptoIdentifierStorage.h"
+#include "IdentifierStorage.h"
namespace ripple {
-/** Shared CryptoIdentifierType traits for Ripple crypto identifiers.
+/** Shared IdentifierType traits for Ripple crypto identifiers.
@tparam Size The number of bytes in the identifier, exclusive of version,
checksum, or padding.
@@ -30,7 +30,7 @@ namespace ripple {
the data including the Token.
*/
template
-class RippleCryptoIdentifier
+class CryptoIdentifier
{
public:
typedef std::size_t size_type;
@@ -44,7 +44,7 @@ public:
static bool const checked = Checked;
// This is what the wrapper creates, it includes the padding.
- typedef CryptoIdentifierStorage <
+ typedef IdentifierStorage <
pre_size, size, post_size> value_type;
typedef typename value_type::hasher hasher;
@@ -69,7 +69,7 @@ public:
}
}
- /** Base class for CryptoIdentifierType. */
+ /** Base class for IdentifierType. */
class base
{
public:
diff --git a/src/ripple/types/api/CryptoIdentifierStorage.h b/src/ripple/types/api/IdentifierStorage.h
similarity index 74%
rename from src/ripple/types/api/CryptoIdentifierStorage.h
rename to src/ripple/types/api/IdentifierStorage.h
index efad14dc6f..106a9d3a5e 100644
--- a/src/ripple/types/api/CryptoIdentifierStorage.h
+++ b/src/ripple/types/api/IdentifierStorage.h
@@ -4,16 +4,16 @@
*/
//==============================================================================
-#ifndef RIPPLE_TYPES_CRYPTOIDENTIFIERSTORAGE_H_INCLUDED
-#define RIPPLE_TYPES_CRYPTOIDENTIFIERSTORAGE_H_INCLUDED
+#ifndef RIPPLE_TYPES_IDENTIFIERSTORAGE_H_INCLUDED
+#define RIPPLE_TYPES_IDENTIFIERSTORAGE_H_INCLUDED
#include "beast/beast/FixedArray.h"
namespace ripple {
-/** A padded FixedArray used with CryptoIdentifierType traits. */
+/** A padded FixedArray used with IdentifierType traits. */
template
-class CryptoIdentifierStorage
+class IdentifierStorage
{
public:
typedef std::size_t size_type;
@@ -43,7 +43,7 @@ public:
{
}
- std::size_t operator() (CryptoIdentifierStorage const& storage) const
+ std::size_t operator() (IdentifierStorage const& storage) const
{
std::size_t hash;
Murmur::Hash (storage.cbegin (), storage.size, m_seed, &hash);
@@ -58,8 +58,8 @@ public:
class equal
{
public:
- bool operator() (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs) const
+ bool operator() (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs) const
{
return lhs == rhs;
}
@@ -115,7 +115,20 @@ public:
void rangecheck (size_type i)
{
if (i >= size)
- throw std::out_of_range ("CryptoIdentifierStorage<>: index out of range");
+ throw std::out_of_range ("IdentifierStorage<>: index out of range");
+ }
+
+ bool isZero() const
+ {
+ for (const_iterator iter(begin()); iter != end(); ++iter)
+ if ((*iter)!=0)
+ return false;
+ return true;
+ }
+
+ bool isNotZero() const
+ {
+ return !isZero();
}
private:
@@ -125,43 +138,43 @@ private:
//------------------------------------------------------------------------------
template
-bool operator== (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs)
+bool operator== (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs)
{
return std::equal (lhs.begin(), lhs.end(), rhs.begin());
}
template
-bool operator!= (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs)
+bool operator!= (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs)
{
return !(lhs==rhs);
}
template
-bool operator< (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs)
+bool operator< (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs)
{
return std::lexicographical_compare (lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
template
-bool operator> (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs)
+bool operator> (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs)
{
return rhs
-bool operator<= (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs)
+bool operator<= (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs)
{
return !(rhs
-bool operator>= (CryptoIdentifierStorage const& lhs,
- CryptoIdentifierStorage const& rhs)
+bool operator>= (IdentifierStorage const& lhs,
+ IdentifierStorage const& rhs)
{
return !(lhs
#include
@@ -19,7 +19,7 @@ namespace ripple {
/** Template for generalizing the cryptographic primitives used. */
template
-class CryptoIdentifierType : public Traits::base
+class IdentifierType : public Traits::base
{
public:
static std::size_t const size = Traits::size;
@@ -36,7 +36,7 @@ public:
template
hasher (Arg arg) : m_hasher (arg)
{ }
- std::size_t operator() (CryptoIdentifierType const& id) const
+ std::size_t operator() (IdentifierType const& id) const
{ return m_hasher(id.value()); }
private:
typename Traits::hasher m_hasher;
@@ -51,39 +51,39 @@ public:
template
equal (Arg arg) : m_equal (arg)
{ }
- bool operator() (CryptoIdentifierType const& lhs,
- CryptoIdentifierType const& rhs) const
+ bool operator() (IdentifierType const& lhs,
+ IdentifierType const& rhs) const
{ return m_equal (lhs.value(), rhs.value()); }
private:
typename Traits::equal m_equal;
};
/** Create an uninitialized value. */
- CryptoIdentifierType ()
+ IdentifierType ()
{
}
/** Create a copy from another value . */
- CryptoIdentifierType (value_type const& value)
+ IdentifierType (value_type const& value)
: m_value (value)
{
}
/** Create a copy of the value from range of bytes. */
- CryptoIdentifierType (uint8 const* begin, uint8 const* end)
+ IdentifierType (uint8 const* begin, uint8 const* end)
{
Traits::construct (begin, end, m_value);
}
/** Conversion construction from any specialized type. */
template
- explicit CryptoIdentifierType (Other const& other)
+ explicit IdentifierType (Other const& other)
{
this->operator= (other);
}
/** Assign a copy from another value. */
- CryptoIdentifierType& operator= (value_type const& value)
+ IdentifierType& operator= (value_type const& value)
{
m_value = value;
return *this;
@@ -91,7 +91,7 @@ public:
/** Copy conversion from any specialized type. */
template
- CryptoIdentifierType& operator= (Other const& other)
+ IdentifierType& operator= (Other const& other)
{
typename Traits::template assign () (
m_value, other);
@@ -104,6 +104,25 @@ public:
return m_value;
}
+ /** Smart dereference.
+ This provides access to the underlying container for compatibility.
+ For example, to call member functions that are otherwise not
+ available.
+ */
+ value_type const* operator->() const
+ {
+ return &value();
+ }
+
+ /** Implicit conversion to value_type.
+ This lets the IdentifierType appear as an rvalue in an assignment
+ where the lvalue is of type value_type.
+ */
+ operator value_type const& () const
+ {
+ return value();
+ }
+
/** Iterator access. */
/** @{ */
const_iterator begin() const { return value().begin(); }
@@ -128,9 +147,41 @@ private:
//------------------------------------------------------------------------------
+template
+bool operator== (IdentifierType const& lhs,
+ IdentifierType const& rhs)
+{ return lhs.value() == rhs.value(); }
+
+template
+bool operator!= (IdentifierType const& lhs,
+ IdentifierType const& rhs)
+{ return lhs.value() != rhs.value(); }
+
+template
+bool operator< (IdentifierType const& lhs,
+ IdentifierType const& rhs)
+{ return lhs.value() < rhs.value(); }
+
+template
+bool operator> (IdentifierType const& lhs,
+ IdentifierType const& rhs)
+{ return lhs.value() > rhs.value(); }
+
+template
+bool operator<= (IdentifierType const& lhs,
+ IdentifierType const& rhs)
+{ return lhs.value() <= rhs.value(); }
+
+template
+bool operator>= (IdentifierType const& lhs,
+ IdentifierType const& rhs)
+{ return lhs.value() >= rhs.value(); }
+
+//------------------------------------------------------------------------------
+
template
std::ostream& operator<< (std::ostream& os,
- CryptoIdentifierType const& id)
+ IdentifierType const& id)
{
os << id.to_string();
return os;
@@ -138,7 +189,7 @@ std::ostream& operator<< (std::ostream& os,
template
std::istream& operator>> (std::istream& is,
- CryptoIdentifierType const& id)
+ IdentifierType const& id)
{
return is;
}
@@ -151,10 +202,10 @@ namespace std {
/** Specialization for hash. */
template
-struct hash >
+struct hash >
{
public:
- typedef ripple::CryptoIdentifierType argument_type;
+ typedef ripple::IdentifierType argument_type;
typedef std::size_t result_type;
hash ()
@@ -182,11 +233,11 @@ private:
/** Specialization for equal_to. */
template
-struct equal_to >
+struct equal_to >
{
public:
typedef bool result_type;
- typedef ripple::CryptoIdentifierType argument_type;
+ typedef ripple::IdentifierType argument_type;
typedef argument_type first_argument_type;
typedef argument_type second_argument_type;
diff --git a/src/ripple/types/api/RippleAccountID.h b/src/ripple/types/api/RippleAccountID.h
index 223d9f38e1..02f3f42079 100644
--- a/src/ripple/types/api/RippleAccountID.h
+++ b/src/ripple/types/api/RippleAccountID.h
@@ -7,12 +7,12 @@
#ifndef RIPPLE_TYPES_RIPPLEACCOUNTID_H_INCLUDED
#define RIPPLE_TYPES_RIPPLEACCOUNTID_H_INCLUDED
-#include "RippleCryptoIdentifier.h"
+#include "CryptoIdentifier.h"
namespace ripple {
class RippleAccountIDTraits
- : public RippleCryptoIdentifier <20, 0, true>
+ : public CryptoIdentifier <20, 0, true>
{
public:
template
@@ -42,7 +42,7 @@ public:
}
};
-typedef CryptoIdentifierType RippleAccountID;
+typedef IdentifierType RippleAccountID;
}
diff --git a/src/ripple/types/api/RippleAccountPrivateKey.h b/src/ripple/types/api/RippleAccountPrivateKey.h
index bff407ebda..a88abf5bd5 100644
--- a/src/ripple/types/api/RippleAccountPrivateKey.h
+++ b/src/ripple/types/api/RippleAccountPrivateKey.h
@@ -7,12 +7,12 @@
#ifndef RIPPLE_TYPES_RIPPLEACCOUNTPRIVATEKEY_H_INCLUDED
#define RIPPLE_TYPES_RIPPLEACCOUNTPRIVATEKEY_H_INCLUDED
-#include "RippleCryptoIdentifier.h"
+#include "CryptoIdentifier.h"
namespace ripple {
class RippleAccountPrivateKeyTraits
- : public RippleCryptoIdentifier <32, 34, true>
+ : public CryptoIdentifier <32, 34, true>
{
public:
template
@@ -25,7 +25,7 @@ public:
};
};
-typedef CryptoIdentifierType RippleAccountPrivateKey;
+typedef IdentifierType RippleAccountPrivateKey;
}
diff --git a/src/ripple/types/api/RippleAccountPublicKey.h b/src/ripple/types/api/RippleAccountPublicKey.h
index 5b6942ae69..7fe735daf1 100644
--- a/src/ripple/types/api/RippleAccountPublicKey.h
+++ b/src/ripple/types/api/RippleAccountPublicKey.h
@@ -7,12 +7,12 @@
#ifndef RIPPLE_TYPES_RIPPLEACCOUNTPUBLICKEY_H_INCLUDED
#define RIPPLE_TYPES_RIPPLEACCOUNTPUBLICKEY_H_INCLUDED
-#include "RippleCryptoIdentifier.h"
+#include "CryptoIdentifier.h"
namespace ripple {
class RippleAccountPublicKeyTraits
- : public RippleCryptoIdentifier <33, 35, true>
+ : public CryptoIdentifier <33, 35, true>
{
public:
template
@@ -25,7 +25,7 @@ public:
};
};
-typedef CryptoIdentifierType RippleAccountPublicKey;
+typedef IdentifierType RippleAccountPublicKey;
}
diff --git a/src/ripple/types/api/RippleLedgerHash.h b/src/ripple/types/api/RippleLedgerHash.h
new file mode 100644
index 0000000000..d808bad4ec
--- /dev/null
+++ b/src/ripple/types/api/RippleLedgerHash.h
@@ -0,0 +1,39 @@
+//------------------------------------------------------------------------------
+/*
+ Copyright (c) 2011-2013, OpenCoin, Inc.
+*/
+//==============================================================================
+
+#ifndef RIPPLE_TYPES_RIPPLELEDGERHASH_H_INCLUDED
+#define RIPPLE_TYPES_RIPPLELEDGERHASH_H_INCLUDED
+
+namespace ripple {
+
+/*
+ Hashes are used to uniquely identify objects like
+ transactions, peers, validators, and accounts.
+
+ For historical reasons, some hashes are 256 bits and some are 160.
+
+ David:
+ "The theory is that you may need to communicate public keys
+ to others, so having them be shorter is a good idea. plus,
+ you can't arbitrarily tweak them because you wouldn't know
+ the corresponding private key anyway. So the security
+ requirements aren't as great."
+*/
+/** The SHA256 bit hash of a signed ledger. */
+class RippleLedgerHashTraits : public SimpleIdentifier <32>
+{
+public:
+};
+
+/** A ledger hash. */
+typedef IdentifierType RippleLedgerHash;
+
+// Legacy
+typedef uint256 LedgerHash;
+
+}
+
+#endif
diff --git a/src/ripple/types/api/RipplePrivateKey.h b/src/ripple/types/api/RipplePrivateKey.h
index 3626bb315e..f3b830fbd3 100644
--- a/src/ripple/types/api/RipplePrivateKey.h
+++ b/src/ripple/types/api/RipplePrivateKey.h
@@ -7,12 +7,12 @@
#ifndef RIPPLE_TYPES_RIPPLEPRIVATEKEY_H_INCLUDED
#define RIPPLE_TYPES_RIPPLEPRIVATEKEY_H_INCLUDED
-#include "RippleCryptoIdentifier.h"
+#include "CryptoIdentifier.h"
namespace ripple {
class RipplePrivateKeyTraits
- : public RippleCryptoIdentifier <32, 32, true>
+ : public CryptoIdentifier <32, 32, true>
{
public:
template
@@ -25,7 +25,7 @@ public:
};
};
-typedef CryptoIdentifierType RipplePrivateKey;
+typedef IdentifierType RipplePrivateKey;
}
diff --git a/src/ripple/types/api/RipplePublicKey.h b/src/ripple/types/api/RipplePublicKey.h
index ba1031b76c..f7664515fd 100644
--- a/src/ripple/types/api/RipplePublicKey.h
+++ b/src/ripple/types/api/RipplePublicKey.h
@@ -7,12 +7,10 @@
#ifndef RIPPLE_TYPES_RIPPLEPUBLICKEY_H_INCLUDED
#define RIPPLE_TYPES_RIPPLEPUBLICKEY_H_INCLUDED
-#include "RippleCryptoIdentifier.h"
-
namespace ripple {
class RipplePublicKeyTraits
- : public RippleCryptoIdentifier <33, 28, true>
+ : public CryptoIdentifier <33, 28, true>
{
public:
template
@@ -25,7 +23,7 @@ public:
};
};
-typedef CryptoIdentifierType RipplePublicKey;
+typedef IdentifierType RipplePublicKey;
}
diff --git a/src/ripple/types/api/RipplePublicKeyHash.h b/src/ripple/types/api/RipplePublicKeyHash.h
index 7a4bd35408..52f33e64d5 100644
--- a/src/ripple/types/api/RipplePublicKeyHash.h
+++ b/src/ripple/types/api/RipplePublicKeyHash.h
@@ -9,8 +9,22 @@
namespace ripple {
-/** A container holding the hash of a public key in binary format. */
-typedef UnsignedInteger <20> RipplePublicKeyHash;
+/** Traits for the public key hash. */
+class RipplePublicKeyHashTraits : public SimpleIdentifier <20>
+{
+public:
+ template
+ struct assign
+ {
+ void operator() (value_type& value, Other const& other)
+ {
+ value = other;
+ }
+ };
+};
+
+/** A container holding the 160-bit hash of the 257-bit public key. */
+typedef IdentifierType RipplePublicKeyHash;
}
diff --git a/src/ripple/types/api/SimpleIdentifier.h b/src/ripple/types/api/SimpleIdentifier.h
new file mode 100644
index 0000000000..5c572967a6
--- /dev/null
+++ b/src/ripple/types/api/SimpleIdentifier.h
@@ -0,0 +1,58 @@
+//------------------------------------------------------------------------------
+/*
+ Copyright (c) 2011-2013, OpenCoin, Inc.
+*/
+//==============================================================================
+
+#ifndef RIPPLE_TYPES_SIMPLEIDENTIFIER_H_INCLUDED
+#define RIPPLE_TYPES_SIMPLEIDENTIFIER_H_INCLUDED
+
+namespace ripple {
+
+/** Provides common traits for non-signing identifiers like ledger hashes.
+ The storage is a suitably sized instance of base_uint.
+*/
+template
+class SimpleIdentifier
+{
+public:
+ static std::size_t const size = Bytes;
+
+ typedef std::size_t size_type;
+ typedef base_uint value_type;
+ typedef typename value_type::hasher hasher;
+ typedef typename value_type::equal equal;
+
+ /** Initialize from an input sequence. */
+ static void construct (
+ uint8 const* begin, uint8 const* end,
+ value_type& value)
+ {
+ std::copy (begin, end, value.begin());
+ }
+
+ /** Base class for IdentifierType. */
+ struct base { };
+
+ /** Convert to std::string. */
+ static std::string to_string (value_type const& value)
+ {
+ return strHex (value.cbegin(), size);
+ }
+
+ /** Assignment specializations.
+ When Other is the same as value_type, this is a copy assignment.
+ */
+ template
+ struct assign
+ {
+ void operator() (value_type& value, Other const& other)
+ {
+ value = other;
+ }
+ };
+};
+
+}
+
+#endif
diff --git a/src/ripple/types/api/base_uint.h b/src/ripple/types/api/base_uint.h
index 8386451674..fb7e8be023 100644
--- a/src/ripple/types/api/base_uint.h
+++ b/src/ripple/types/api/base_uint.h
@@ -38,9 +38,83 @@ protected:
unsigned int pn[WIDTH];
public:
- base_uint ()
+ /** Construct uninitialized.
+ Requirements:
+ std::is_trivially_constructible::value == true
+ */
+ base_uint () { }
+
+ //--------------------------------------------------------------------------
+ //
+ // STL Container Interface
+ //
+
+ static std::size_t const bytes = (BITS/8);
+
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef unsigned char value_type;
+ typedef value_type* pointer;
+ typedef value_type& reference;
+ typedef value_type const* const_pointer;
+ typedef value_type const& const_reference;
+ typedef pointer iterator;
+ typedef const_pointer const_iterator;
+ typedef std::reverse_iterator
+ reverse_iterator;
+ typedef std::reverse_iterator
+ const_reverse_iterator;
+
+ pointer data() { return reinterpret_cast(pn); }
+ const_pointer data() const { return reinterpret_cast(pn); }
+
+ iterator begin() { return data(); }
+ iterator end() { return data()+bytes; }
+ const_iterator begin() const { return data(); }
+ const_iterator end() const { return data()+bytes; }
+ const_iterator cbegin() const { return data(); }
+ const_iterator cend() const { return data()+bytes; }
+
+ reverse_iterator rbegin() { return end(); }
+ reverse_iterator rend() { return begin(); }
+ const_reverse_iterator rbegin() const { return end(); }
+ const_reverse_iterator rend() const { return begin(); }
+ const_reverse_iterator crbegin() const { return cend(); }
+ const_reverse_iterator crend() const { return cbegin(); }
+
+ /** Value hashing function.
+ The seed prevents crafted inputs from causing degenarate parent containers.
+ */
+ class hasher
{
- }
+ public:
+ explicit hasher (HashValue seedToUse = Random::getSystemRandom ().nextInt ())
+ : m_seed (seedToUse)
+ {
+ }
+
+ std::size_t operator() (base_uint const& value) const
+ {
+ std::size_t hash;
+ Murmur::Hash (value.cbegin (), (BITS / 8), m_seed, &hash);
+ return hash;
+ }
+
+ private:
+ std::size_t m_seed;
+ };
+
+ /** Container equality testing function. */
+ class equal
+ {
+ public:
+ bool operator() (base_uint const& lhs, base_uint const& rhs) const
+ {
+ return lhs == rhs;
+ }
+ };
+
+ //--------------------------------------------------------------------------
protected:
// This is to disambiguate from other 1 parameter ctors
@@ -58,7 +132,6 @@ protected:
memcpy (&pn [0], data, BITS / 8);
}
public:
-
bool isZero () const
{
for (int i = 0; i < WIDTH; i++)
@@ -364,36 +437,6 @@ public:
return GetHex ();
}
- unsigned char* begin ()
- {
- return reinterpret_cast (pn);
- }
-
- unsigned char* end ()
- {
- return reinterpret_cast (pn + WIDTH);
- }
-
- unsigned char const* cbegin () const noexcept
- {
- return reinterpret_cast (pn);
- }
-
- unsigned char const* cend () const noexcept
- {
- return reinterpret_cast (pn + WIDTH);
- }
-
- const unsigned char* begin () const noexcept
- {
- return cbegin ();
- }
-
- const unsigned char* end () const noexcept
- {
- return cend ();
- }
-
unsigned int size () const
{
return sizeof (pn);
@@ -439,4 +482,70 @@ std::ostream& operator<< (std::ostream& out, const base_uint& u)
}
+//------------------------------------------------------------------------------
+
+namespace std {
+
+/** Specialization for hash. */
+template
+struct hash >
+{
+public:
+ typedef ripple::base_uint argument_type;
+ typedef std::size_t result_type;
+
+ hash ()
+ {
+ static typename argument_type::hasher s_hash;
+ m_hash = s_hash;
+ }
+
+ template
+ explicit hash (Arg arg) : m_hash (arg)
+ {
+ }
+
+ result_type operator() (argument_type const& key) const
+ {
+ return m_hash (key);
+ }
+
+private:
+ typename argument_type::hasher m_hash;
+};
+
+//------------------------------------------------------------------------------
+
+/** Specialization for equal_to. */
+template
+struct equal_to >
+{
+public:
+ typedef bool result_type;
+ typedef ripple::base_uint argument_type;
+ typedef argument_type first_argument_type;
+ typedef argument_type second_argument_type;
+
+ equal_to ()
+ {
+ }
+
+ template
+ explicit equal_to (Arg arg)
+ : m_equal (arg)
+ {
+ }
+
+ result_type operator() (argument_type const& lhs,
+ argument_type const& rhs) const
+ {
+ return m_equal (lhs, rhs);
+ }
+
+private:
+ typename argument_type::equal m_equal;
+};
+
+}
+
#endif
diff --git a/src/ripple/types/impl/RippleCryptoIdentifierTests.cpp b/src/ripple/types/impl/RippleIdentifierTests.cpp
similarity index 100%
rename from src/ripple/types/impl/RippleCryptoIdentifierTests.cpp
rename to src/ripple/types/impl/RippleIdentifierTests.cpp
diff --git a/src/ripple/types/ripple_types.cpp b/src/ripple/types/ripple_types.cpp
index aa1d21989e..4b14147847 100644
--- a/src/ripple/types/ripple_types.cpp
+++ b/src/ripple/types/ripple_types.cpp
@@ -24,4 +24,4 @@
#include "impl/UInt128.cpp"
#include "impl/UInt160.cpp"
#include "impl/UInt256.cpp"
-#include "impl/RippleCryptoIdentifierTests.cpp"
+#include "impl/RippleIdentifierTests.cpp"
diff --git a/src/ripple/types/ripple_types.h b/src/ripple/types/ripple_types.h
index a66974ad80..12a5aa8761 100644
--- a/src/ripple/types/ripple_types.h
+++ b/src/ripple/types/ripple_types.h
@@ -37,15 +37,17 @@ using namespace beast;
# include "api/UInt256.h"
# include "api/RandomNumbers.h"
#include "api/HashMaps.h"
-#include "api/CryptoIdentifierType.h"
-# include "api/CryptoIdentifierStorage.h"
+# include "api/IdentifierType.h"
+# include "api/IdentifierStorage.h"
+# include "api/CryptoIdentifier.h"
#include "api/RippleAccountID.h"
#include "api/RippleAccountPublicKey.h"
#include "api/RippleAccountPrivateKey.h"
#include "api/RipplePublicKey.h"
#include "api/RipplePrivateKey.h"
-
+# include "api/SimpleIdentifier.h"
+#include "api/RippleLedgerHash.h"
#include "api/RipplePublicKeyHash.h"
#endif
diff --git a/src/ripple/validators/api/Manager.h b/src/ripple/validators/api/Manager.h
index 0a256b5484..14e855fda7 100644
--- a/src/ripple/validators/api/Manager.h
+++ b/src/ripple/validators/api/Manager.h
@@ -70,7 +70,7 @@ public:
// Trusted Validators
- //virtual bool isPublicKeyTrusted (PublicKey const& publicKey) = 0;
+ //virtual bool isPublicKeyTrusted (RipplePublicKey const& publicKey) = 0;
//--------------------------------------------------------------------------
diff --git a/src/ripple/validators/api/Source.h b/src/ripple/validators/api/Source.h
index a906ac7977..25b2c443fc 100644
--- a/src/ripple/validators/api/Source.h
+++ b/src/ripple/validators/api/Source.h
@@ -18,7 +18,7 @@ public:
struct Info
{
/** The unique key for this validator. */
- PublicKey publicKey;
+ RipplePublicKey publicKey;
/** Optional human readable comment describing the validator. */
String label;
diff --git a/src/ripple/validators/api/Types.h b/src/ripple/validators/api/Types.h
index deb4674e4f..b8b4afc101 100644
--- a/src/ripple/validators/api/Types.h
+++ b/src/ripple/validators/api/Types.h
@@ -10,13 +10,11 @@
namespace ripple {
namespace Validators {
-typedef RipplePublicKey PublicKey;
-typedef RipplePublicKeyHash PublicKeyHash;
-
struct ReceivedValidation
{
- uint256 ledgerHash;
- PublicKeyHash signerPublicKeyHash;
+ RippleLedgerHash ledgerHash;
+ RipplePublicKey publicKey;
+ RipplePublicKeyHash publicKeyHash;
};
/** Callback used to optionally cancel long running fetch operations. */
diff --git a/src/ripple/validators/impl/ChosenList.h b/src/ripple/validators/impl/ChosenList.h
index ae1a22a51b..bef2481899 100644
--- a/src/ripple/validators/impl/ChosenList.h
+++ b/src/ripple/validators/impl/ChosenList.h
@@ -22,7 +22,7 @@ public:
}
};
- typedef boost::unordered_map MapType;
+ typedef boost::unordered_map MapType;
ChosenList (std::size_t expectedSize = 0)
{
@@ -40,17 +40,17 @@ public:
return m_map.size ();
}
- void insert (PublicKey const& key, Info const& info) noexcept
+ void insert (RipplePublicKey const& key, Info const& info) noexcept
{
m_map [key] = info;
}
- bool containsPublicKey (PublicKey const& publicKey) const noexcept
+ bool containsPublicKey (RipplePublicKey const& publicKey) const noexcept
{
return m_map.find (publicKey) != m_map.cend ();
}
- bool containsPublicKeyHash (PublicKeyHash const& publicKeyHash) const noexcept
+ bool containsPublicKeyHash (RipplePublicKeyHash const& publicKeyHash) const noexcept
{
return false;
}
diff --git a/src/ripple/validators/impl/Logic.h b/src/ripple/validators/impl/Logic.h
index c1beef9dd0..d9b2cf4383 100644
--- a/src/ripple/validators/impl/Logic.h
+++ b/src/ripple/validators/impl/Logic.h
@@ -46,7 +46,7 @@ public:
};
typedef boost::unordered_map <
- PublicKey, ValidatorInfo, PublicKey::hasher> MapType;
+ RipplePublicKey, ValidatorInfo, RipplePublicKey::hasher> MapType;
struct State
{
@@ -388,7 +388,7 @@ public:
// Returns `true` if the public key hash is contained in the Chosen List.
//
- bool isTrustedPublicKeyHash (PublicKeyHash const& publicKeyHash)
+ bool isTrustedPublicKeyHash (RipplePublicKeyHash const& publicKeyHash)
{
return m_chosenList->containsPublicKeyHash (publicKeyHash);
}
diff --git a/src/ripple/validators/impl/Tests.cpp b/src/ripple/validators/impl/Tests.cpp
index 0a2aeb62f5..c1f9018f6c 100644
--- a/src/ripple/validators/impl/Tests.cpp
+++ b/src/ripple/validators/impl/Tests.cpp
@@ -119,7 +119,7 @@ public:
for (uint32 i = m_start ; i < m_end; ++i)
{
Info info;
- info.publicKey = Validators::PublicKey::createFromInteger (i);
+ info.publicKey = RipplePublicKey::createFromInteger (i);
info.label = String::fromNumber (i);
result.list.add (info);
}
diff --git a/src/ripple/validators/impl/Utilities.cpp b/src/ripple/validators/impl/Utilities.cpp
index 24e8aba108..43dcdcaef6 100644
--- a/src/ripple/validators/impl/Utilities.cpp
+++ b/src/ripple/validators/impl/Utilities.cpp
@@ -236,17 +236,17 @@ Time Utilities::stringToTime (String s)
return Time (0);
}
-std::string Utilities::publicKeyToString (PublicKey const& publicKey)
+std::string Utilities::publicKeyToString (RipplePublicKey const& publicKey)
{
- std::string s (PublicKey::size, ' ');
+ std::string s (RipplePublicKey::size, ' ');
std::copy (publicKey.cbegin(), publicKey.cend(), s.begin());
return s;
}
-PublicKey Utilities::stringToPublicKey (std::string const& s)
+RipplePublicKey Utilities::stringToPublicKey (std::string const& s)
{
- bassert (s.size() == PublicKey::size);
- return PublicKey ();
+ bassert (s.size() == RipplePublicKey::size);
+ return RipplePublicKey ();
}
//------------------------------------------------------------------------------
diff --git a/src/ripple/validators/impl/Utilities.h b/src/ripple/validators/impl/Utilities.h
index ab8ccd00f8..6a049bbf57 100644
--- a/src/ripple/validators/impl/Utilities.h
+++ b/src/ripple/validators/impl/Utilities.h
@@ -54,9 +54,9 @@ public:
static String timeToString (Time const& t);
static Time stringToTime (String s);
- // conversion between PublicKey and String
- static std::string publicKeyToString (PublicKey const& publicKey);
- static PublicKey stringToPublicKey (std::string const& s);
+ // conversion between RipplePublicKey and String
+ static std::string publicKeyToString (RipplePublicKey const& publicKey);
+ static RipplePublicKey stringToPublicKey (std::string const& s);
struct Helpers;
diff --git a/src/ripple_app/ledger/InboundLedgers.cpp b/src/ripple_app/ledger/InboundLedgers.cpp
index ad0b4d65cc..4b2da760dd 100644
--- a/src/ripple_app/ledger/InboundLedgers.cpp
+++ b/src/ripple_app/ledger/InboundLedgers.cpp
@@ -76,7 +76,7 @@ InboundLedger::pointer InboundLedgers::find (uint256 const& hash)
return ret;
}
-bool InboundLedgers::hasLedger (uint256 const& hash)
+bool InboundLedgers::hasLedger (LedgerHash const& hash)
{
assert (hash.isNonZero ());
@@ -84,7 +84,7 @@ bool InboundLedgers::hasLedger (uint256 const& hash)
return mLedgers.find (hash) != mLedgers.end ();
}
-void InboundLedgers::dropLedger (uint256 const& hash)
+void InboundLedgers::dropLedger (LedgerHash const& hash)
{
assert (hash.isNonZero ());
@@ -93,7 +93,7 @@ void InboundLedgers::dropLedger (uint256 const& hash)
}
-bool InboundLedgers::awaitLedgerData (uint256 const& ledgerHash)
+bool InboundLedgers::awaitLedgerData (LedgerHash const& ledgerHash)
{
InboundLedger::pointer ledger = find (ledgerHash);
@@ -114,7 +114,7 @@ inboundLedgerTrigger:
*/
// means "We got some data from an inbound ledger"
-void InboundLedgers::gotLedgerData (Job&, uint256 hash,
+void InboundLedgers::gotLedgerData (Job&, LedgerHash hash,
boost::shared_ptr packet_ptr, boost::weak_ptr wPeer)
{
protocol::TMLedgerData& packet = *packet_ptr;
diff --git a/src/ripple_app/peers/Peer.cpp b/src/ripple_app/peers/Peer.cpp
index 3dcd4a40d4..3c45583f24 100644
--- a/src/ripple_app/peers/Peer.cpp
+++ b/src/ripple_app/peers/Peer.cpp
@@ -1450,8 +1450,8 @@ static void checkValidation (Job&, SerializedValidation::pointer val, bool isTru
SerializedValidation const& sv (*val);
Validators::ReceivedValidation rv;
rv.ledgerHash = sv.getLedgerHash ();
- uint160 const publicKeyHash (sv.getSignerPublic ().getNodeID ());
- rv.signerPublicKeyHash = RipplePublicKeyHash (publicKeyHash.begin ());
+ rv.publicKey = sv.getSignerPublic();
+ rv.publicKeyHash = sv.getSignerPublic();
getApp ().getValidators ().receiveValidation (rv);
#endif
}
diff --git a/src/ripple_data/protocol/Protocol.h b/src/ripple_data/protocol/Protocol.h
index 41fd4bd8ce..8400aea42a 100644
--- a/src/ripple_data/protocol/Protocol.h
+++ b/src/ripple_data/protocol/Protocol.h
@@ -28,24 +28,6 @@ struct Protocol
static int const txMaxSizeBytes = 1024 * 1024; // 1048576
};
-/*
- Hashes are used to uniquely identify objects like
- transactions, peers, validators, and accounts.
-
- For historical reasons, some hashes are 256 bits and some are 160.
-
- David:
- "The theory is that you may need to communicate public keys
- to others, so having them be shorter is a good idea. plus,
- you can't arbitrarily tweak them because you wouldn't know
- the corresponding private key anyway. So the security
- requirements aren't as great."
-*/
-
-/** A ledger hash.
-*/
-typedef uint256 LedgerHash;
-
/** A ledger index.
*/
// VFALCO TODO pick one. I like Index since its not an abbreviation
diff --git a/src/ripple_data/protocol/RippleAddress.cpp b/src/ripple_data/protocol/RippleAddress.cpp
index 5761171829..a0a5f9e0c6 100644
--- a/src/ripple_data/protocol/RippleAddress.cpp
+++ b/src/ripple_data/protocol/RippleAddress.cpp
@@ -951,7 +951,7 @@ static RippleAddressTests rippleAddressTests;
//------------------------------------------------------------------------------
-class RippleCryptoIdentifierTests : public UnitTest
+class RippleIdentifierTests : public UnitTest
{
public:
void runTest ()
@@ -1013,9 +1013,9 @@ public:
privateKey.to_string());
}
- RippleCryptoIdentifierTests () : UnitTest ("RippleCryptoIdentifier", "ripple")
+ RippleIdentifierTests () : UnitTest ("RippleIdentifier", "ripple")
{
}
};
-static RippleCryptoIdentifierTests rippleCryptoIdentifierTests;
+static RippleIdentifierTests rippleIdentifierTests;
diff --git a/src/ripple_data/protocol/RippleAddress.h b/src/ripple_data/protocol/RippleAddress.h
index 687fed7c34..917020eebf 100644
--- a/src/ripple_data/protocol/RippleAddress.h
+++ b/src/ripple_data/protocol/RippleAddress.h
@@ -206,6 +206,7 @@ public:
//------------------------------------------------------------------------------
+/** RipplePublicKey */
template <>
struct RipplePublicKeyTraits::assign
{
@@ -216,6 +217,18 @@ struct RipplePublicKeyTraits::assign
}
};
+/** RipplePublicKeyHash */
+template <>
+struct RipplePublicKeyHashTraits::assign
+{
+ void operator() (value_type& value, RippleAddress const& v) const
+ {
+ uint160 const ui (v.getNodeID ());
+ construct (ui.begin(), ui.end(), value);
+ }
+};
+
+/** RipplePrivateKey */
template <>
struct RipplePrivateKeyTraits::assign
{
@@ -226,6 +239,7 @@ struct RipplePrivateKeyTraits::assign
}
};
+/** RippleAccountID */
template <>
struct RippleAccountIDTraits::assign
{
@@ -236,6 +250,7 @@ struct RippleAccountIDTraits::assign
}
};
+/** RippleAccountPublicKey */
template <>
struct RippleAccountPublicKeyTraits::assign
{
@@ -246,6 +261,7 @@ struct RippleAccountPublicKeyTraits::assign
}
};
+/** RippleAccountPrivateKey */
template <>
struct RippleAccountPrivateKeyTraits::assign
{