Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove boost::hash_value() overloads. #428

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Builds/VisualStudio2013/RippleD.vcxproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{B7F39ECD-473C-484D-BC34-31F8362506A5}</ProjectGuid>
<ProjectGuid>{26B7D9AC-1A80-8EF8-6703-D061F1BECB75}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>RippleD</RootNamespace>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
Expand Down Expand Up @@ -3383,9 +3383,6 @@
<ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
Expand Down Expand Up @@ -4106,4 +4103,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
3 changes: 0 additions & 3 deletions Builds/VisualStudio2013/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -4647,9 +4647,6 @@
<ClCompile Include="..\..\src\ripple\types\impl\UintTypes.cpp">
<Filter>ripple\types\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\base_uint.cpp">
<Filter>ripple\types\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\strHex.cpp">
<Filter>ripple\types\impl</Filter>
</ClCompile>
Expand Down
10 changes: 0 additions & 10 deletions src/beast/beast/container/hash_append.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

#endif
4 changes: 1 addition & 3 deletions src/beast/beast/http/URL.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ hash_append (Hasher& h, URL const& url)
hash_append (h, url.toString());
}

extern std::size_t hash_value (beast::URL const& url);

}

//------------------------------------------------------------------------------
Expand All @@ -143,7 +141,7 @@ template <>
struct hash <beast::URL>
{
std::size_t operator() (beast::URL const& v) const
{ return beast::hash_value (v); }
{ return v.toString().hash(); }
};

}
Expand Down
10 changes: 0 additions & 10 deletions src/beast/beast/http/impl/URL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,4 @@ std::ostream& operator<< (std::ostream &os, URL const& url)
return os;
}

//------------------------------------------------------------------------------

std::size_t hash_value (URL const& v)
{
return std::size_t (v.toString().hash());
}

}


// boost::hash support
26 changes: 15 additions & 11 deletions src/beast/beast/net/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <beast/net/IPAddressV6.h>
#include <beast/container/hash_append.h>

#include <boost/functional/hash.hpp>

#include <cstdint>
#include <ios>
#include <string>
Expand Down Expand Up @@ -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. */
inline std::string to_string (Address const& addr)
{
Expand Down Expand Up @@ -337,7 +329,19 @@ struct hash <beast::IP::Address>
std::size_t
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);
}
};
}
Expand Down
7 changes: 2 additions & 5 deletions src/beast/beast/net/IPAddressV4.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <beast/container/hash_append.h>

#include <cstdint>
#include <functional>
#include <ios>
#include <string>
#include <utility>
Expand Down Expand Up @@ -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. */
std::string to_string (AddressV4 const& addr);

Expand Down Expand Up @@ -197,7 +194,7 @@ template <>
struct hash <beast::IP::AddressV4>
{
std::size_t operator() (beast::IP::AddressV4 const& addr) const
{ return hash_value (addr); }
{ return addr.value; }
};
}

Expand Down
7 changes: 2 additions & 5 deletions src/beast/beast/net/IPAddressV6.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <cassert>
#include <cstdint>
#include <functional>
#include <ios>
#include <string>
#include <utility>
Expand Down Expand Up @@ -78,10 +79,6 @@ hash_append(Hasher&, AddressV6 const&)
assert(false);
}

/** boost::hash support. */
inline std::size_t hash_value (AddressV6 const&)
{ assert(false); return 0; }

/** Returns the address represented as a string. */
std::string to_string (AddressV6 const& addr);

Expand All @@ -104,7 +101,7 @@ template <>
struct hash <beast::IP::AddressV6>
{
std::size_t operator() (beast::IP::AddressV6 const& addr) const
{ return hash_value (addr); }
{ assert(false); return 0; }
};
}

Expand Down
15 changes: 11 additions & 4 deletions src/beast/beast/net/IPEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
inline std::string to_string (Endpoint const& endpoint)
{ return endpoint.to_string(); }
Expand All @@ -161,7 +158,17 @@ template <>
struct hash <beast::IP::Endpoint>
{
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); }
};
}

Expand Down
9 changes: 0 additions & 9 deletions src/beast/beast/net/impl/IPEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
// VFALCO TODO Support ipv6!
Expand Down
4 changes: 4 additions & 0 deletions src/ripple/algorithm/api/CycledSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define RIPPLE_TYPES_CYCLEDSET_H_INCLUDED

#include <boost/unordered_set.hpp>
#include <unordered_set>

namespace ripple {

Expand All @@ -37,6 +38,9 @@ template <class Key,
class CycledSet
{
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<
Key, Hash, KeyEqual, Allocator> ContainerType;
typedef typename ContainerType::iterator iterator;
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/module/app/consensus/LedgerConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ class LedgerConsensusImp
}

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

for (auto& it : mPeerPositions)
{
Expand Down Expand Up @@ -1899,7 +1899,7 @@ class LedgerConsensusImp

// Disputed transactions
ripple::unordered_map<uint256, DisputedTx::pointer> mDisputes;
boost::unordered_set<uint256> mCompares;
ripple::unordered_set<uint256> mCompares;

// Close time estimates
std::map<std::uint32_t, int> mCloseTimes;
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/module/app/ledger/OrderBookDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ void OrderBookDB::setup (Ledger::ref ledger)
}

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> >& sourceMap,
boost::unordered_set< RippleAsset >& XRPBooks,
ripple::unordered_set< RippleAsset >& XRPBooks,
int& books)
{
if ((entry->getType () == ltDIR_NODE) && (entry->isFieldPresent (sfExchangeRate)) &&
Expand Down Expand Up @@ -96,10 +96,10 @@ static void updateHelper (SLE::ref entry,

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> > sourceMap;
boost::unordered_set< RippleAsset > XRPBooks;
ripple::unordered_set< RippleAsset > XRPBooks;

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

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/module/app/ledger/OrderBookDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class OrderBookDB
AssetToOrderBook mDestMap;

// does an order book to XRP exist
boost::unordered_set <RippleAsset> mXRPBooks;
ripple::unordered_set <RippleAsset> mXRPBooks;

typedef RippleRecursiveMutex LockType;
typedef std::lock_guard <LockType> ScopedLockType;
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/module/app/misc/AmendmentTableImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace ripple {

typedef ripple::unordered_map<uint256, AmendmentState> amendmentMap_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 std::lock_guard <LockType> ScopedLockType;
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/module/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ class NetworkOPsImp
// InfoSub::Source
//
void subAccount (InfoSub::ref ispListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
std::uint32_t uLedgerIndex, bool rt);
void unsubAccount (std::uint64_t uListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
bool rt);

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

void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
std::uint32_t uLedgerIndex, bool rt)
{
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
Expand Down Expand Up @@ -2653,7 +2653,7 @@ void NetworkOPsImp::subAccount (InfoSub::ref isrListener,
}

void NetworkOPsImp::unsubAccount (std::uint64_t uSeq,
const boost::unordered_set<RippleAddress>& vnaAccountIDs,
const ripple::unordered_set<RippleAddress>& vnaAccountIDs,
bool rt)
{
SubInfoMapType& subMap = rt ? mSubRTAccount : mSubAccount;
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/module/app/peers/UniqueNodeList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ class UniqueNodeListImp
}
}

boost::unordered_set<std::string> usUNL;
ripple::unordered_set<std::string> usUNL;

if (!vsnNodes.empty ())
{
Expand Down Expand Up @@ -2025,7 +2025,7 @@ class UniqueNodeListImp

// XXX Make this faster, make this the contents vector unsigned char or raw public key.
// 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 mtpScoreStart; // Time currently started scoring.
Expand Down
5 changes: 0 additions & 5 deletions src/ripple/module/app/shamap/SHAMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ void SHAMapNodeID::setMHash () const
mHash = h;
}

std::size_t hash_value (const SHAMapNodeID& mn)
{
return mn.getMHash ();
}

SHAMap::pointer SHAMap::snapShot (bool isMutable)
{
SHAMap::pointer ret = std::make_shared<SHAMap> (mType,
Expand Down
2 changes: 0 additions & 2 deletions src/ripple/module/app/shamap/SHAMapNodeID.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ class SHAMapNodeID
void setMHash () const;
};

extern std::size_t hash_value (SHAMapNodeID const& mn);

inline std::ostream& operator<< (std::ostream& out, SHAMapNodeID const& node)
{
return out << node.getString ();
Expand Down
10 changes: 0 additions & 10 deletions src/ripple/module/data/crypto/Base58Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,4 @@ std::string CBase58Data::ToString () const
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
Loading