aboutsummaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-04-30 21:56:04 +0200
committerPieter Wuille <sipa@ulyssis.org>2013-05-30 05:18:42 +0200
commit5d891489ab7828ad8db15e85bb63e2f13f021a6a (patch)
tree24cd213e276977570de5b299872368bdf70ac929 /src/hash.h
parentec0004aca0a2bf11f99c9587ddb2bf8ea818d3bb (diff)
Make CPubKey statically allocated
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/hash.h b/src/hash.h
index eaa1780c04..536ab71165 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -105,15 +105,22 @@ uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL
return ss.GetHash();
}
-inline uint160 Hash160(const std::vector<unsigned char>& vch)
+template<typename T1>
+inline uint160 Hash160(const T1 pbegin, const T1 pend)
{
+ static unsigned char pblank[1];
uint256 hash1;
- SHA256(&vch[0], vch.size(), (unsigned char*)&hash1);
+ SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);
uint160 hash2;
RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
+inline uint160 Hash160(const std::vector<unsigned char>& vch)
+{
+ return Hash160(vch.begin(), vch.end());
+}
+
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash);
#endif