Skip to content

Commit fac8220

Browse files
HowardHinnantnbougalis
authored andcommitted
Remove boost::hash_value() overloads.
This addresses https://ripplelabs.atlassian.net/browse/RIPD-102
1 parent 61f114e commit fac8220

35 files changed

+104
-182
lines changed

Builds/VisualStudio2013/RippleD.vcxproj

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Label="Globals">
4-
<ProjectGuid>{B7F39ECD-473C-484D-BC34-31F8362506A5}</ProjectGuid>
4+
<ProjectGuid>{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}</ProjectGuid>
55
<Keyword>Win32Proj</Keyword>
66
<RootNamespace>RippleD</RootNamespace>
77
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
@@ -3383,9 +3383,6 @@
33833383
<ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp">
33843384
<ExcludedFromBuild>True</ExcludedFromBuild>
33853385
</ClCompile>
3386-
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
3387-
<ExcludedFromBuild>True</ExcludedFromBuild>
3388-
</ClCompile>
33893386
<ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp">
33903387
<ExcludedFromBuild>True</ExcludedFromBuild>
33913388
</ClCompile>
@@ -4106,4 +4103,4 @@
41064103
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
41074104
<ImportGroup Label="ExtensionTargets">
41084105
</ImportGroup>
4109-
</Project>
4106+
</Project>

Builds/VisualStudio2013/RippleD.vcxproj.filters

-3
Original file line numberDiff line numberDiff line change
@@ -4647,9 +4647,6 @@
46474647
<ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp">
46484648
<Filter>ripple\types\impl</Filter>
46494649
</ClCompile>
4650-
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
4651-
<Filter>ripple\types\impl</Filter>
4652-
</ClCompile>
46534650
<ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp">
46544651
<Filter>ripple\types\impl</Filter>
46554652
</ClCompile>

src/beast/beast/container/hash_append.h

-10
Original file line numberDiff line numberDiff line change
@@ -702,16 +702,6 @@ struct uhash
702702
}
703703
};
704704

705-
struct call_hash_value
706-
{
707-
template <class T>
708-
std::size_t
709-
operator()(T const& t) const noexcept
710-
{
711-
return hash_value(t);
712-
}
713-
};
714-
715705
} // beast
716706

717707
#endif

src/beast/beast/http/URL.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ hash_append (Hasher& h, URL const& url)
131131
hash_append (h, url.toString());
132132
}
133133

134-
extern std::size_t hash_value (beast::URL const& url);
135-
136134
}
137135

138136
//------------------------------------------------------------------------------
@@ -143,7 +141,7 @@ template <>
143141
struct hash <beast::URL>
144142
{
145143
std::size_t operator() (beast::URL const& v) const
146-
{ return beast::hash_value (v); }
144+
{ return v.toString().hash(); }
147145
};
148146

149147
}

src/beast/beast/http/impl/URL.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,4 @@ std::ostream& operator<< (std::ostream &os, URL const& url)
164164
return os;
165165
}
166166

167-
//------------------------------------------------------------------------------
168-
169-
std::size_t hash_value (URL const& v)
170-
{
171-
return std::size_t (v.toString().hash());
172167
}
173-
174-
}
175-
176-
177-
// boost::hash support

src/beast/beast/net/IPAddress.h

+15-11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <beast/net/IPAddressV6.h>
2525
#include <beast/container/hash_append.h>
2626

27+
#include <boost/functional/hash.hpp>
28+
2729
#include <cstdint>
2830
#include <ios>
2931
#include <string>
@@ -277,16 +279,6 @@ is_public (Address const& addr)
277279

278280
//------------------------------------------------------------------------------
279281

280-
/** boost::hash support. */
281-
inline
282-
std::size_t
283-
hash_value (Address const& addr)
284-
{
285-
return (addr.is_v4 ())
286-
? hash_value (addr.to_v4())
287-
: hash_value (addr.to_v6());
288-
}
289-
290282
/** Returns the address represented as a string. */
291283
inline std::string to_string (Address const& addr)
292284
{
@@ -337,7 +329,19 @@ struct hash <beast::IP::Address>
337329
std::size_t
338330
operator() (beast::IP::Address const& addr) const
339331
{
340-
return hash_value (addr);
332+
return beast::uhash<>{} (addr);
333+
}
334+
};
335+
}
336+
337+
namespace boost {
338+
template <>
339+
struct hash <beast::IP::Address>
340+
{
341+
std::size_t
342+
operator() (beast::IP::Address const& addr) const
343+
{
344+
return beast::uhash<>{} (addr);
341345
}
342346
};
343347
}

src/beast/beast/net/IPAddressV4.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <beast/container/hash_append.h>
2424

2525
#include <cstdint>
26+
#include <functional>
2627
#include <ios>
2728
#include <string>
2829
#include <utility>
@@ -164,10 +165,6 @@ bool is_public (AddressV4 const& addr);
164165

165166
//------------------------------------------------------------------------------
166167

167-
/** boost::hash support. */
168-
inline std::size_t hash_value (AddressV4 const& addr)
169-
{ return addr.value; }
170-
171168
/** Returns the address represented as a string. */
172169
std::string to_string (AddressV4 const& addr);
173170

@@ -197,7 +194,7 @@ template <>
197194
struct hash <beast::IP::AddressV4>
198195
{
199196
std::size_t operator() (beast::IP::AddressV4 const& addr) const
200-
{ return hash_value (addr); }
197+
{ return addr.value; }
201198
};
202199
}
203200

src/beast/beast/net/IPAddressV6.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <cassert>
2424
#include <cstdint>
25+
#include <functional>
2526
#include <ios>
2627
#include <string>
2728
#include <utility>
@@ -78,10 +79,6 @@ hash_append(Hasher&, AddressV6 const&)
7879
assert(false);
7980
}
8081

81-
/** boost::hash support. */
82-
inline std::size_t hash_value (AddressV6 const&)
83-
{ assert(false); return 0; }
84-
8582
/** Returns the address represented as a string. */
8683
std::string to_string (AddressV6 const& addr);
8784

@@ -104,7 +101,7 @@ template <>
104101
struct hash <beast::IP::AddressV6>
105102
{
106103
std::size_t operator() (beast::IP::AddressV6 const& addr) const
107-
{ return hash_value (addr); }
104+
{ assert(false); return 0; }
108105
};
109106
}
110107

src/beast/beast/net/IPEndpoint.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ inline bool is_public (Endpoint const& endpoint)
132132

133133
//------------------------------------------------------------------------------
134134

135-
/** boost::hash support. */
136-
std::size_t hash_value (Endpoint const& endpoint);
137-
138135
/** Returns the endpoint represented as a string. */
139136
inline std::string to_string (Endpoint const& endpoint)
140137
{ return endpoint.to_string(); }
@@ -161,7 +158,17 @@ template <>
161158
struct hash <beast::IP::Endpoint>
162159
{
163160
std::size_t operator() (beast::IP::Endpoint const& endpoint) const
164-
{ return hash_value (endpoint); }
161+
{ return beast::uhash<>{} (endpoint); }
162+
};
163+
}
164+
165+
namespace boost {
166+
/** boost::hash support. */
167+
template <>
168+
struct hash <beast::IP::Endpoint>
169+
{
170+
std::size_t operator() (beast::IP::Endpoint const& endpoint) const
171+
{ return beast::uhash<>{} (endpoint); }
165172
};
166173
}
167174

src/beast/beast/net/impl/IPEndpoint.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ bool operator< (Endpoint const& lhs, Endpoint const& rhs)
137137

138138
//------------------------------------------------------------------------------
139139

140-
std::size_t hash_value (Endpoint const& endpoint)
141-
{
142-
std::size_t seed (hash_value (endpoint.address ()));
143-
// boost::hash_combine()
144-
seed ^= (std::hash <Port> () (endpoint.port ()))
145-
+ 0x9e3779b9 + (seed << 6) + (seed >> 2);
146-
return seed;
147-
}
148-
149140
std::istream& operator>> (std::istream& is, Endpoint& endpoint)
150141
{
151142
// VFALCO TODO Support ipv6!

src/ripple/algorithm/api/CycledSet.h

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define RIPPLE_TYPES_CYCLEDSET_H_INCLUDED
2222

2323
#include <boost/unordered_set.hpp>
24+
#include <unordered_set>
2425

2526
namespace ripple {
2627

@@ -37,6 +38,9 @@ template <class Key,
3738
class CycledSet
3839
{
3940
private:
41+
// HH This unordered_set can't be changed from boost until gcc allows for
42+
// stateful hash functions (or until rippled eliminates stateful hash
43+
// functions).
4044
typedef boost::unordered_set<
4145
Key, Hash, KeyEqual, Allocator> ContainerType;
4246
typedef typename ContainerType::iterator iterator;

src/ripple/module/app/consensus/LedgerConsensus.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ class LedgerConsensusImp
14961496
}
14971497

14981498
// if any peers have taken a contrary position, process disputes
1499-
boost::unordered_set<uint256> found;
1499+
ripple::unordered_set<uint256> found;
15001500

15011501
for (auto& it : mPeerPositions)
15021502
{
@@ -1899,7 +1899,7 @@ class LedgerConsensusImp
18991899

19001900
// Disputed transactions
19011901
ripple::unordered_map<uint256, DisputedTx::pointer> mDisputes;
1902-
boost::unordered_set<uint256> mCompares;
1902+
ripple::unordered_set<uint256> mCompares;
19031903

19041904
// Close time estimates
19051905
std::map<std::uint32_t, int> mCloseTimes;

src/ripple/module/app/ledger/OrderBookDB.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ void OrderBookDB::setup (Ledger::ref ledger)
6060
}
6161

6262
static void updateHelper (SLE::ref entry,
63-
boost::unordered_set< uint256 >& seen,
63+
ripple::unordered_set< uint256 >& seen,
6464
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >& destMap,
6565
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> >& sourceMap,
66-
boost::unordered_set< RippleAsset >& XRPBooks,
66+
ripple::unordered_set< RippleAsset >& XRPBooks,
6767
int& books)
6868
{
6969
if ((entry->getType () == ltDIR_NODE) && (entry->isFieldPresent (sfExchangeRate)) &&
@@ -96,10 +96,10 @@ static void updateHelper (SLE::ref entry,
9696

9797
void OrderBookDB::update (Ledger::pointer ledger)
9898
{
99-
boost::unordered_set< uint256 > seen;
99+
ripple::unordered_set< uint256 > seen;
100100
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> > destMap;
101101
ripple::unordered_map< RippleAsset, std::vector<OrderBook::pointer> > sourceMap;
102-
boost::unordered_set< RippleAsset > XRPBooks;
102+
ripple::unordered_set< RippleAsset > XRPBooks;
103103

104104
WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>";
105105

src/ripple/module/app/ledger/OrderBookDB.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class OrderBookDB
8989
AssetToOrderBook mDestMap;
9090

9191
// does an order book to XRP exist
92-
boost::unordered_set <RippleAsset> mXRPBooks;
92+
ripple::unordered_set <RippleAsset> mXRPBooks;
9393

9494
typedef RippleRecursiveMutex LockType;
9595
typedef std::lock_guard <LockType> ScopedLockType;

src/ripple/module/app/misc/AmendmentTableImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace ripple {
3131

3232
typedef ripple::unordered_map<uint256, AmendmentState> amendmentMap_t;
3333
typedef std::pair<const uint256, AmendmentState> amendmentIt_t;
34-
typedef boost::unordered_set<uint256> amendmentList_t;
34+
typedef ripple::unordered_set<uint256> amendmentList_t;
3535

3636
typedef RippleMutex LockType;
3737
typedef std::lock_guard <LockType> ScopedLockType;

src/ripple/module/app/misc/NetworkOPs.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ class NetworkOPsImp
386386
// InfoSub::Source
387387
//
388388
void subAccount (InfoSub::ref ispListener,
389-
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
389+
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
390390
std::uint32_t uLedgerIndex, bool rt);
391391
void unsubAccount (std::uint64_t uListener,
392-
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
392+
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
393393
bool rt);
394394

395395
bool subLedger (InfoSub::ref ispListener, Json::Value& jvResult);
@@ -2617,7 +2617,7 @@ void NetworkOPsImp::pubAccountTransaction (Ledger::ref lpCurrent, const Accepted
26172617
//
26182618

26192619
void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
2620-
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
2620+
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
26212621
std::uint32_t uLedgerIndex, bool rt)
26222622
{
26232623
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
@@ -2653,7 +2653,7 @@ void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
26532653
}
26542654

26552655
void NetworkOPsImp::unsubAccount (std::uint64_t uSeq,
2656-
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
2656+
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
26572657
bool rt)
26582658
{
26592659
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;

src/ripple/module/app/peers/UniqueNodeList.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ class UniqueNodeListImp
10251025
}
10261026
}
10271027

1028-
boost::unordered_set<std::string> usUNL;
1028+
ripple::unordered_set<std::string> usUNL;
10291029

10301030
if (!vsnNodes.empty ())
10311031
{
@@ -2025,7 +2025,7 @@ class UniqueNodeListImp
20252025

20262026
// XXX Make this faster, make this the contents vector unsigned char or raw public key.
20272027
// XXX Contents needs to based on score.
2028-
boost::unordered_set<std::string> mUNL;
2028+
ripple::unordered_set<std::string> mUNL;
20292029

20302030
boost::posix_time::ptime mtpScoreNext; // When to start scoring.
20312031
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.

src/ripple/module/app/shamap/SHAMap.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ void SHAMapNodeID::setMHash () const
114114
mHash = h;
115115
}
116116

117-
std::size_t hash_value (const SHAMapNodeID& mn)
118-
{
119-
return mn.getMHash ();
120-
}
121-
122117
SHAMap::pointer SHAMap::snapShot (bool isMutable)
123118
{
124119
SHAMap::pointer ret = std::make_shared<SHAMap> (mType,

src/ripple/module/app/shamap/SHAMapNodeID.h

-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ class SHAMapNodeID
130130
void setMHash () const;
131131
};
132132

133-
extern std::size_t hash_value (SHAMapNodeID const& mn);
134-
135133
inline std::ostream& operator<< (std::ostream& out, SHAMapNodeID const& node)
136134
{
137135
return out << node.getString ();

src/ripple/module/data/crypto/Base58Data.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,4 @@ std::string CBase58Data::ToString () const
7777
return Base58::encodeWithCheck (vch);
7878
}
7979

80-
std::size_t hash_value (const CBase58Data& b58)
81-
{
82-
std::size_t seed = HashMaps::getInstance ().getNonce <size_t> ()
83-
+ (b58.nVersion * HashMaps::goldenRatio);
84-
85-
boost::hash_combine (seed, b58.vchData);
86-
87-
return seed;
88-
}
89-
9080
} // ripple

0 commit comments

Comments
 (0)