Remove boost::hash_value() overloads.

This addresses https://ripplelabs.atlassian.net/browse/RIPD-102
This commit is contained in:
Howard Hinnant
2014-07-02 12:37:13 -04:00
committed by Nik Bougalis
parent 61f114e655
commit fac82204b6
35 changed files with 104 additions and 182 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{B7F39ECD-473C-484D-BC34-31F8362506A5}</ProjectGuid> <ProjectGuid>{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>RippleD</RootNamespace> <RootNamespace>RippleD</RootNamespace>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename> <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
@@ -3383,9 +3383,6 @@
<ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp"> <ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp"> <ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild> <ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile> </ClCompile>
@@ -4106,4 +4103,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@@ -4647,9 +4647,6 @@
<ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp"> <ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp">
<Filter>ripple\types\impl</Filter> <Filter>ripple\types\impl</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
<Filter>ripple\types\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp"> <ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp">
<Filter>ripple\types\impl</Filter> <Filter>ripple\types\impl</Filter>
</ClCompile> </ClCompile>

View File

@@ -702,16 +702,6 @@ struct uhash
} }
}; };
struct call_hash_value
{
template <class T>
std::size_t
operator()(T const& t) const noexcept
{
return hash_value(t);
}
};
} // beast } // beast
#endif #endif

View File

@@ -131,8 +131,6 @@ hash_append (Hasher& h, URL const& url)
hash_append (h, url.toString()); hash_append (h, url.toString());
} }
extern std::size_t hash_value (beast::URL const& url);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -143,7 +141,7 @@ template <>
struct hash <beast::URL> struct hash <beast::URL>
{ {
std::size_t operator() (beast::URL const& v) const std::size_t operator() (beast::URL const& v) const
{ return beast::hash_value (v); } { return v.toString().hash(); }
}; };
} }

View File

@@ -164,14 +164,4 @@ std::ostream& operator<< (std::ostream &os, URL const& url)
return os; return os;
} }
//------------------------------------------------------------------------------
std::size_t hash_value (URL const& v)
{
return std::size_t (v.toString().hash());
} }
}
// boost::hash support

View File

@@ -24,6 +24,8 @@
#include <beast/net/IPAddressV6.h> #include <beast/net/IPAddressV6.h>
#include <beast/container/hash_append.h> #include <beast/container/hash_append.h>
#include <boost/functional/hash.hpp>
#include <cstdint> #include <cstdint>
#include <ios> #include <ios>
#include <string> #include <string>
@@ -277,16 +279,6 @@ is_public (Address const& addr)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** boost::hash support. */
inline
std::size_t
hash_value (Address const& addr)
{
return (addr.is_v4 ())
? hash_value (addr.to_v4())
: hash_value (addr.to_v6());
}
/** Returns the address represented as a string. */ /** Returns the address represented as a string. */
inline std::string to_string (Address const& addr) inline std::string to_string (Address const& addr)
{ {
@@ -337,7 +329,19 @@ struct hash <beast::IP::Address>
std::size_t std::size_t
operator() (beast::IP::Address const& addr) const operator() (beast::IP::Address const& addr) const
{ {
return hash_value (addr); return beast::uhash<>{} (addr);
}
};
}
namespace boost {
template <>
struct hash <beast::IP::Address>
{
std::size_t
operator() (beast::IP::Address const& addr) const
{
return beast::uhash<>{} (addr);
} }
}; };
} }

View File

@@ -23,6 +23,7 @@
#include <beast/container/hash_append.h> #include <beast/container/hash_append.h>
#include <cstdint> #include <cstdint>
#include <functional>
#include <ios> #include <ios>
#include <string> #include <string>
#include <utility> #include <utility>
@@ -164,10 +165,6 @@ bool is_public (AddressV4 const& addr);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** boost::hash support. */
inline std::size_t hash_value (AddressV4 const& addr)
{ return addr.value; }
/** Returns the address represented as a string. */ /** Returns the address represented as a string. */
std::string to_string (AddressV4 const& addr); std::string to_string (AddressV4 const& addr);
@@ -197,7 +194,7 @@ template <>
struct hash <beast::IP::AddressV4> struct hash <beast::IP::AddressV4>
{ {
std::size_t operator() (beast::IP::AddressV4 const& addr) const std::size_t operator() (beast::IP::AddressV4 const& addr) const
{ return hash_value (addr); } { return addr.value; }
}; };
} }

View File

@@ -22,6 +22,7 @@
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#include <functional>
#include <ios> #include <ios>
#include <string> #include <string>
#include <utility> #include <utility>
@@ -78,10 +79,6 @@ hash_append(Hasher&, AddressV6 const&)
assert(false); assert(false);
} }
/** boost::hash support. */
inline std::size_t hash_value (AddressV6 const&)
{ assert(false); return 0; }
/** Returns the address represented as a string. */ /** Returns the address represented as a string. */
std::string to_string (AddressV6 const& addr); std::string to_string (AddressV6 const& addr);
@@ -104,7 +101,7 @@ template <>
struct hash <beast::IP::AddressV6> struct hash <beast::IP::AddressV6>
{ {
std::size_t operator() (beast::IP::AddressV6 const& addr) const std::size_t operator() (beast::IP::AddressV6 const& addr) const
{ return hash_value (addr); } { assert(false); return 0; }
}; };
} }

View File

@@ -132,9 +132,6 @@ inline bool is_public (Endpoint const& endpoint)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** boost::hash support. */
std::size_t hash_value (Endpoint const& endpoint);
/** Returns the endpoint represented as a string. */ /** Returns the endpoint represented as a string. */
inline std::string to_string (Endpoint const& endpoint) inline std::string to_string (Endpoint const& endpoint)
{ return endpoint.to_string(); } { return endpoint.to_string(); }
@@ -161,7 +158,17 @@ template <>
struct hash <beast::IP::Endpoint> struct hash <beast::IP::Endpoint>
{ {
std::size_t operator() (beast::IP::Endpoint const& endpoint) const std::size_t operator() (beast::IP::Endpoint const& endpoint) const
{ return hash_value (endpoint); } { return beast::uhash<>{} (endpoint); }
};
}
namespace boost {
/** boost::hash support. */
template <>
struct hash <beast::IP::Endpoint>
{
std::size_t operator() (beast::IP::Endpoint const& endpoint) const
{ return beast::uhash<>{} (endpoint); }
}; };
} }

View File

@@ -137,15 +137,6 @@ bool operator< (Endpoint const& lhs, Endpoint const& rhs)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::size_t hash_value (Endpoint const& endpoint)
{
std::size_t seed (hash_value (endpoint.address ()));
// boost::hash_combine()
seed ^= (std::hash <Port> () (endpoint.port ()))
+ 0x9e3779b9 + (seed << 6) + (seed >> 2);
return seed;
}
std::istream& operator>> (std::istream& is, Endpoint& endpoint) std::istream& operator>> (std::istream& is, Endpoint& endpoint)
{ {
// VFALCO TODO Support ipv6! // VFALCO TODO Support ipv6!

View File

@@ -21,6 +21,7 @@
#define RIPPLE_TYPES_CYCLEDSET_H_INCLUDED #define RIPPLE_TYPES_CYCLEDSET_H_INCLUDED
#include <boost/unordered_set.hpp> #include <boost/unordered_set.hpp>
#include <unordered_set>
namespace ripple { namespace ripple {
@@ -37,6 +38,9 @@ template <class Key,
class CycledSet class CycledSet
{ {
private: private:
// HH This unordered_set can't be changed from boost until gcc allows for
// stateful hash functions (or until rippled eliminates stateful hash
// functions).
typedef boost::unordered_set< typedef boost::unordered_set<
Key, Hash, KeyEqual, Allocator> ContainerType; Key, Hash, KeyEqual, Allocator> ContainerType;
typedef typename ContainerType::iterator iterator; typedef typename ContainerType::iterator iterator;

View File

@@ -1496,7 +1496,7 @@ private:
} }
// if any peers have taken a contrary position, process disputes // if any peers have taken a contrary position, process disputes
boost::unordered_set<uint256> found; ripple::unordered_set<uint256> found;
for (auto& it : mPeerPositions) for (auto& it : mPeerPositions)
{ {
@@ -1899,7 +1899,7 @@ private:
// Disputed transactions // Disputed transactions
ripple::unordered_map<uint256, DisputedTx::pointer> mDisputes; ripple::unordered_map<uint256, DisputedTx::pointer> mDisputes;
boost::unordered_set<uint256> mCompares; ripple::unordered_set<uint256> mCompares;
// Close time estimates // Close time estimates
std::map<std::uint32_t, int> mCloseTimes; std::map<std::uint32_t, int> mCloseTimes;

View File

@@ -60,10 +60,10 @@ void OrderBookDB::setup (Ledger::ref ledger)
} }
static void updateHelper (SLE::ref entry, static void updateHelper (SLE::ref entry,
boost::unordered_set< uint256 >& seen, ripple::unordered_set< uint256 >& seen,
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >& destMap, ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >& destMap,
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >& sourceMap, ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >& sourceMap,
boost::unordered_set< RippleAsset >& XRPBooks, ripple::unordered_set< RippleAsset >& XRPBooks,
int& books) int& books)
{ {
if ((entry->getType () == ltDIR_NODE) && (entry->isFieldPresent (sfExchangeRate)) && if ((entry->getType () == ltDIR_NODE) && (entry->isFieldPresent (sfExchangeRate)) &&
@@ -96,10 +96,10 @@ static void updateHelper (SLE::ref entry,
void OrderBookDB::update (Ledger::pointer ledger) void OrderBookDB::update (Ledger::pointer ledger)
{ {
boost::unordered_set< uint256 > seen; ripple::unordered_set< uint256 > seen;
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> > destMap; ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> > destMap;
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> > sourceMap; ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> > sourceMap;
boost::unordered_set< RippleAsset > XRPBooks; ripple::unordered_set< RippleAsset > XRPBooks;
WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>"; WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>";

View File

@@ -89,7 +89,7 @@ private:
AssetToOrderBook mDestMap; AssetToOrderBook mDestMap;
// does an order book to XRP exist // does an order book to XRP exist
boost::unordered_set <RippleAsset> mXRPBooks; ripple::unordered_set <RippleAsset> mXRPBooks;
typedef RippleRecursiveMutex LockType; typedef RippleRecursiveMutex LockType;
typedef std::lock_guard <LockType> ScopedLockType; typedef std::lock_guard <LockType> ScopedLockType;

View File

@@ -31,7 +31,7 @@ protected:
typedef ripple::unordered_map<uint256, AmendmentState> amendmentMap_t; typedef ripple::unordered_map<uint256, AmendmentState> amendmentMap_t;
typedef std::pair<const uint256, AmendmentState> amendmentIt_t; typedef std::pair<const uint256, AmendmentState> amendmentIt_t;
typedef boost::unordered_set<uint256> amendmentList_t; typedef ripple::unordered_set<uint256> amendmentList_t;
typedef RippleMutex LockType; typedef RippleMutex LockType;
typedef std::lock_guard <LockType> ScopedLockType; typedef std::lock_guard <LockType> ScopedLockType;

View File

@@ -386,10 +386,10 @@ public:
// InfoSub::Source // InfoSub::Source
// //
void subAccount (InfoSub::ref ispListener, void subAccount (InfoSub::ref ispListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs, const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
std::uint32_t uLedgerIndex, bool rt); std::uint32_t uLedgerIndex, bool rt);
void unsubAccount (std::uint64_t uListener, void unsubAccount (std::uint64_t uListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs, const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
bool rt); bool rt);
bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult); bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult);
@@ -2617,7 +2617,7 @@ void NetworkOPsImp::pubAccountTransaction (Ledger::ref lpCurrent, const Accepted
// //
void NetworkOPsImp::subAccount (InfoSub::ref isrListener, void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs, const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
std::uint32_t uLedgerIndex, bool rt) std::uint32_t uLedgerIndex, bool rt)
{ {
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount; SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
@@ -2653,7 +2653,7 @@ void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
} }
void NetworkOPsImp::unsubAccount (std::uint64_t uSeq, void NetworkOPsImp::unsubAccount (std::uint64_t uSeq,
const boost::unordered_set<RippleAddress>& vnaAccountIDs, const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
bool rt) bool rt)
{ {
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount; SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;

View File

@@ -1025,7 +1025,7 @@ private:
} }
} }
boost::unordered_set<std::string> usUNL; ripple::unordered_set<std::string> usUNL;
if (!vsnNodes.empty ()) if (!vsnNodes.empty ())
{ {
@@ -2025,7 +2025,7 @@ private:
// XXX Make this faster, make this the contents vector unsigned char or raw public key. // XXX Make this faster, make this the contents vector unsigned char or raw public key.
// XXX Contents needs to based on score. // XXX Contents needs to based on score.
boost::unordered_set<std::string> mUNL; ripple::unordered_set<std::string> mUNL;
boost::posix_time::ptime mtpScoreNext; // When to start scoring. boost::posix_time::ptime mtpScoreNext; // When to start scoring.
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring. boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.

View File

@@ -114,11 +114,6 @@ void SHAMapNodeID::setMHash () const
mHash = h; mHash = h;
} }
std::size_t hash_value (const SHAMapNodeID& mn)
{
return mn.getMHash ();
}
SHAMap::pointer SHAMap::snapShot (bool isMutable) SHAMap::pointer SHAMap::snapShot (bool isMutable)
{ {
SHAMap::pointer ret = std::make_shared<SHAMap> (mType, SHAMap::pointer ret = std::make_shared<SHAMap> (mType,

View File

@@ -130,8 +130,6 @@ private:
void setMHash () const; void setMHash () const;
}; };
extern std::size_t hash_value (SHAMapNodeID const& mn);
inline std::ostream& operator<< (std::ostream& out, SHAMapNodeID const& node) inline std::ostream& operator<< (std::ostream& out, SHAMapNodeID const& node)
{ {
return out << node.getString (); return out << node.getString ();

View File

@@ -77,14 +77,4 @@ std::string CBase58Data::ToString () const
return Base58::encodeWithCheck (vch); return Base58::encodeWithCheck (vch);
} }
std::size_t hash_value (const CBase58Data& b58)
{
std::size_t seed = HashMaps::getInstance ().getNonce <size_t> ()
+ (b58.nVersion * HashMaps::goldenRatio);
boost::hash_combine (seed, b58.vchData);
return seed;
}
} // ripple } // ripple

View File

@@ -96,8 +96,6 @@ public:
{ {
beast::hash_append(hasher, value.vchData); beast::hash_append(hasher, value.vchData);
} }
friend std::size_t hash_value (const CBase58Data& b58);
}; };
inline bool inline bool
@@ -136,8 +134,6 @@ operator>= (CBase58Data const& lhs, CBase58Data const& rhs)
return lhs.compare (rhs) >= 0; return lhs.compare (rhs) >= 0;
} }
extern std::size_t hash_value (const CBase58Data& b58);
} // ripple } // ripple
#endif #endif

View File

@@ -55,11 +55,11 @@ public:
public: public:
// VFALCO TODO Rename the 'rt' parameters to something meaningful. // VFALCO TODO Rename the 'rt' parameters to something meaningful.
virtual void subAccount (ref ispListener, virtual void subAccount (ref ispListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs, const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
std::uint32_t uLedgerIndex, bool rt) = 0; std::uint32_t uLedgerIndex, bool rt) = 0;
virtual void unsubAccount (std::uint64_t uListener, virtual void unsubAccount (std::uint64_t uListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs, const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
bool rt) = 0; bool rt) = 0;
// VFALCO TODO Document the bool return value // VFALCO TODO Document the bool return value
@@ -130,11 +130,11 @@ protected:
private: private:
Consumer m_consumer; Consumer m_consumer;
Source& m_source; Source& m_source;
boost::unordered_set <RippleAddress> mSubAccountInfo; ripple::unordered_set <RippleAddress> mSubAccountInfo;
boost::unordered_set <RippleAddress> mSubAccountTransaction; ripple::unordered_set <RippleAddress> mSubAccountTransaction;
std::shared_ptr <PathRequest> mPathRequest; std::shared_ptr <PathRequest> mPathRequest;
std::uint64_t mSeq; std::uint64_t mSeq;
}; };
} // ripple } // ripple

View File

@@ -142,7 +142,7 @@ Json::Value doSubscribe (RPC::Context& context)
} }
else else
{ {
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_[strAccountsProposed]); ripple::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_[strAccountsProposed]);
if (usnaAccoundIds.empty ()) if (usnaAccoundIds.empty ())
{ {
@@ -163,7 +163,7 @@ Json::Value doSubscribe (RPC::Context& context)
} }
else else
{ {
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_["accounts"]); ripple::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_["accounts"]);
if (usnaAccoundIds.empty ()) if (usnaAccoundIds.empty ())
{ {

View File

@@ -88,7 +88,7 @@ Json::Value doUnsubscribe (RPC::Context& context)
if (context.params_.isMember ("accounts_proposed") || context.params_.isMember ("rt_accounts")) if (context.params_.isMember ("accounts_proposed") || context.params_.isMember ("rt_accounts"))
{ {
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds ( ripple::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (
context.params_.isMember ("accounts_proposed") context.params_.isMember ("accounts_proposed")
? context.params_["accounts_proposed"] ? context.params_["accounts_proposed"]
: context.params_["rt_accounts"]); // DEPRECATED : context.params_["rt_accounts"]); // DEPRECATED
@@ -105,7 +105,7 @@ Json::Value doUnsubscribe (RPC::Context& context)
if (context.params_.isMember ("accounts")) if (context.params_.isMember ("accounts"))
{ {
boost::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_["accounts"]); ripple::unordered_set<RippleAddress> usnaAccoundIds = RPC::parseAccountIds (context.params_["accounts"]);
if (usnaAccoundIds.empty ()) if (usnaAccoundIds.empty ())
{ {

View File

@@ -22,9 +22,9 @@
namespace ripple { namespace ripple {
namespace RPC { namespace RPC {
boost::unordered_set<RippleAddress> parseAccountIds (const Json::Value& jvArray) ripple::unordered_set<RippleAddress> parseAccountIds (const Json::Value& jvArray)
{ {
boost::unordered_set<RippleAddress> usnaResult; ripple::unordered_set<RippleAddress> usnaResult;
for (Json::Value::const_iterator it = jvArray.begin (); it != jvArray.end (); it++) for (Json::Value::const_iterator it = jvArray.begin (); it != jvArray.end (); it++)
{ {

View File

@@ -23,7 +23,7 @@
namespace ripple { namespace ripple {
namespace RPC { namespace RPC {
boost::unordered_set <RippleAddress> parseAccountIds (const Json::Value& jvArray); ripple::unordered_set <RippleAddress> parseAccountIds (const Json::Value& jvArray);
} // RPC } // RPC
} // ripple } // ripple

View File

@@ -479,9 +479,9 @@ OverlayImpl::onPeerActivated (Peer::ptr const& peer)
{ {
auto const result (m_publicKeyMap.emplace ( auto const result (m_publicKeyMap.emplace (
boost::unordered::piecewise_construct, std::piecewise_construct,
boost::make_tuple (peer->getNodePublic()), std::make_tuple (peer->getNodePublic()),
boost::make_tuple (peer))); std::make_tuple (peer)));
assert(result.second); assert(result.second);
} }

View File

@@ -30,7 +30,6 @@
#include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/context.hpp> #include <boost/asio/ssl/context.hpp>
#include <boost/unordered_map.hpp>
#include <beast/cxx14/memory.h> // <memory> #include <beast/cxx14/memory.h> // <memory>
#include <cassert> #include <cassert>
@@ -53,7 +52,7 @@ private:
typedef std::unordered_map <PeerFinder::Slot::ptr, typedef std::unordered_map <PeerFinder::Slot::ptr,
std::weak_ptr <PeerImp>> PeersBySlot; std::weak_ptr <PeerImp>> PeersBySlot;
typedef boost::unordered_map < typedef ripple::unordered_map <
RippleAddress, Peer::ptr> PeerByPublicKey; RippleAddress, Peer::ptr> PeerByPublicKey;
typedef std::unordered_map < typedef std::unordered_map <

View File

@@ -20,6 +20,13 @@
#ifndef RIPPLE_TESTOVERLAY_CONNECTIONTYPE_H_INCLUDED #ifndef RIPPLE_TESTOVERLAY_CONNECTIONTYPE_H_INCLUDED
#define RIPPLE_TESTOVERLAY_CONNECTIONTYPE_H_INCLUDED #define RIPPLE_TESTOVERLAY_CONNECTIONTYPE_H_INCLUDED
// HH Todo: Stop the practice of opening a namespace and #include
} // namespace ripple
#include <ripple/common/UnorderedContainers.h>
namespace ripple {
namespace TestOverlay namespace TestOverlay
{ {
@@ -34,7 +41,7 @@ public:
typedef typename State::UniqueID UniqueID; typedef typename State::UniqueID UniqueID;
typedef std::vector <Message> Messages; typedef std::vector <Message> Messages;
typedef boost::unordered_set <UniqueID> MessageTable; typedef ripple::unordered_set <UniqueID> MessageTable;
/** Create the 'no connection' object. */ /** Create the 'no connection' object. */
ConnectionType () ConnectionType ()

View File

@@ -42,7 +42,7 @@ public:
typedef ConnectionType <Config> Connection; typedef ConnectionType <Config> Connection;
typedef std::vector <Connection> Connections; typedef std::vector <Connection> Connections;
typedef boost::unordered_set <UniqueID> MessageTable; typedef ripple::unordered_set <UniqueID> MessageTable;
explicit PeerType (Network& network) explicit PeerType (Network& network)
: m_network (network) : m_network (network)

View File

@@ -28,6 +28,7 @@
#include <ripple/types/api/base_uint.h> #include <ripple/types/api/base_uint.h>
#include <ripple/types/api/strHex.h> #include <ripple/types/api/strHex.h>
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <functional>
namespace ripple { namespace ripple {

View File

@@ -32,6 +32,8 @@
#include <beast/container/hardened_hash.h> #include <beast/container/hardened_hash.h>
#include <beast/utility/Zero.h> #include <beast/utility/Zero.h>
#include <boost/functional/hash.hpp>
#include <functional> #include <functional>
using beast::zero; using beast::zero;
@@ -402,13 +404,6 @@ typedef base_uint<128> uint128;
typedef base_uint<160> uint160; typedef base_uint<160> uint160;
typedef base_uint<256> uint256; typedef base_uint<256> uint256;
//------------------------------------------------------------------------------
extern std::size_t hash_value (uint128 const&);
extern std::size_t hash_value (uint160 const&);
extern std::size_t hash_value (uint256 const&);
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag> template <std::size_t Bits, class Tag>
inline int compare ( inline int compare (
base_uint<Bits, Tag> const& a, base_uint<Bits, Tag> const& b) base_uint<Bits, Tag> const& a, base_uint<Bits, Tag> const& b)
@@ -526,4 +521,21 @@ inline std::ostream& operator<< (
} // rippled } // rippled
namespace boost
{
template <std::size_t Bits, class Tag>
struct hash<ripple::base_uint<Bits, Tag>>
{
using argument_type = ripple::base_uint<Bits, Tag>;
std::size_t
operator()(argument_type const& u) const
{
return beast::hardened_hash<argument_type>{}(u);
}
};
} // boost
#endif #endif

View File

@@ -222,11 +222,11 @@ public:
testAssetSet <std::unordered_set <RippleAssetRef>> (); testAssetSet <std::unordered_set <RippleAssetRef>> ();
#endif #endif
testcase ("boost::unordered_set <RippleAsset>"); testcase ("ripple::unordered_set <RippleAsset>");
testAssetSet <boost::unordered_set <RippleAsset>> (); testAssetSet <ripple::unordered_set <RippleAsset>> ();
testcase ("boost::unordered_set <RippleAssetRef>"); testcase ("ripple::unordered_set <RippleAssetRef>");
testAssetSet <boost::unordered_set <RippleAssetRef>> (); testAssetSet <ripple::unordered_set <RippleAssetRef>> ();
} }
void testAssetMaps () void testAssetMaps ()
@@ -425,11 +425,11 @@ public:
testBookSet <std::unordered_set <RippleBookRef>> (); testBookSet <std::unordered_set <RippleBookRef>> ();
#endif #endif
testcase ("boost::unordered_set <RippleBook>"); testcase ("ripple::unordered_set <RippleBook>");
testBookSet <boost::unordered_set <RippleBook>> (); testBookSet <ripple::unordered_set <RippleBook>> ();
testcase ("boost::unordered_set <RippleBookRef>"); testcase ("ripple::unordered_set <RippleBookRef>");
testBookSet <boost::unordered_set <RippleBookRef>> (); testBookSet <ripple::unordered_set <RippleBookRef>> ();
} }
void testBookMaps () void testBookMaps ()

View File

@@ -1,47 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
namespace ripple {
// NIKB TODO having a dependency on HashMaps sucks. Try to remove it and combine
// these functions into a single template.
std::size_t hash_value (uint128 const& u)
{
std::size_t seed = HashMaps::getInstance ().getNonce <std::size_t> ();
return beast::hardened_hash<uint128>{seed}(u);
}
std::size_t hash_value (uint160 const& u)
{
std::size_t seed = HashMaps::getInstance ().getNonce <std::size_t> ();
return beast::hardened_hash<uint160>{seed}(u);
}
std::size_t hash_value (uint256 const& u)
{
std::size_t seed = HashMaps::getInstance ().getNonce <size_t> ();
return beast::hardened_hash<uint256>{seed}(u);
}
}

View File

@@ -43,7 +43,6 @@
#include <ripple/types/impl/ByteOrder.cpp> #include <ripple/types/impl/ByteOrder.cpp>
#include <ripple/types/impl/RandomNumbers.cpp> #include <ripple/types/impl/RandomNumbers.cpp>
#include <ripple/types/impl/strHex.cpp> #include <ripple/types/impl/strHex.cpp>
#include <ripple/types/impl/base_uint.cpp>
#include <ripple/types/impl/UintTypes.cpp> #include <ripple/types/impl/UintTypes.cpp>
#include <ripple/types/impl/RippleIdentifierTests.cpp> #include <ripple/types/impl/RippleIdentifierTests.cpp>
#include <ripple/types/impl/RippleAssets.cpp> #include <ripple/types/impl/RippleAssets.cpp>