mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Make CBase58Data (and NewcoinAddress) hashable.
This commit is contained in:
16
src/base58.h
16
src/base58.h
@@ -18,6 +18,8 @@
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include "bignum.h"
|
||||
#include "BitcoinUtil.h"
|
||||
@@ -241,7 +243,21 @@ public:
|
||||
bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; }
|
||||
bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; }
|
||||
bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; }
|
||||
|
||||
friend std::size_t hash_value(CBase58Data const& b58);
|
||||
};
|
||||
|
||||
inline std::size_t hash_value(CBase58Data const& b58)
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
|
||||
boost::hash_combine(seed, b58.nVersion);
|
||||
BOOST_FOREACH(const unsigned char& x, b58.vchData)
|
||||
{
|
||||
boost::hash_combine(seed, x);
|
||||
}
|
||||
|
||||
return seed;
|
||||
}
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
Reference in New Issue
Block a user