Tidy up Serializer:

* Remove getSHA512Half size parameter
* Remove unused Serializer::getSHA256
* Remove Serializer::getRIPEMD160
This commit is contained in:
Vinnie Falco
2015-05-27 13:50:41 -07:00
parent e18c6f63cc
commit 06823349f9
5 changed files with 8 additions and 35 deletions

View File

@@ -166,10 +166,8 @@ public:
return addFieldID (static_cast<int> (type), name);
}
// normal hash functions
uint160 getRIPEMD160 (int size = -1) const;
uint256 getSHA256 (int size = -1) const;
uint256 getSHA512Half (int size = -1) const;
// DEPRECATED
uint256 getSHA512Half() const;
// prefix hash functions
static uint256 getPrefixHash (std::uint32_t prefix, const unsigned char* data, int len);

View File

@@ -35,6 +35,7 @@ namespace ripple {
template <class Tag>
uint256 to256 (base_uint<160, Tag> const& a)
{
// VFALCO This assumes uint256 is zero-initialized
uint256 m;
memcpy (m.begin (), a.begin (), a.size ());
return m;

View File

@@ -296,36 +296,9 @@ Blob Serializer::getRaw (int offset, int length) const
return o;
}
uint160 Serializer::getRIPEMD160 (int size) const
uint256 Serializer::getSHA512Half () const
{
uint160 ret;
if ((size < 0) || (size > mData.size ())) size = mData.size ();
RIPEMD160 (& (mData.front ()), size, (unsigned char*) &ret);
return ret;
}
uint256 Serializer::getSHA256 (int size) const
{
uint256 ret;
if ((size < 0) || (size > mData.size ())) size = mData.size ();
SHA256 (& (mData.front ()), size, (unsigned char*) &ret);
return ret;
}
uint256 Serializer::getSHA512Half (int size) const
{
assert (size != 0);
if (size == 0)
return uint256();
if (size < 0 || size > mData.size())
return ripple::getSHA512Half (mData);
return ripple::getSHA512Half (
mData.data(), size);
return ripple::getSHA512Half (mData);
}
uint256 Serializer::getPrefixHash (std::uint32_t prefix, const unsigned char* data, int len)

View File

@@ -89,7 +89,7 @@ public:
for (int d = 0; d < 3; ++d)
s.add32 (r.nextInt ());
return std::make_shared <Item> (
to256(s.getRIPEMD160()), s.peekData ());
s.getSHA512Half(), s.peekData ());
}
void

View File

@@ -43,7 +43,8 @@ public:
for (int d = 0; d < 3; ++d) s.add32 (rand ());
return std::make_shared<SHAMapItem> (to256 (s.getRIPEMD160 ()), s.peekData ());
return std::make_shared<SHAMapItem>(
s.getSHA512Half(), s.peekData ());
}
bool confuseMap (SHAMap& map, int count)