Make CBase58Data (and NewcoinAddress) hashable.

This commit is contained in:
Arthur Britto
2012-04-26 15:18:10 -07:00
parent 396eca1a3c
commit cb7fdf6ad8

View File

@@ -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