Changeset View
Changeset View
Standalone View
Standalone View
src/hash.h
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | CHash256() | ||||
.Write(p1begin == p1end ? pblank : (const uint8_t *)&p1begin[0], | .Write(p1begin == p1end ? pblank : (const uint8_t *)&p1begin[0], | ||||
(p1end - p1begin) * sizeof(p1begin[0])) | (p1end - p1begin) * sizeof(p1begin[0])) | ||||
.Write(p2begin == p2end ? pblank : (const uint8_t *)&p2begin[0], | .Write(p2begin == p2end ? pblank : (const uint8_t *)&p2begin[0], | ||||
(p2end - p2begin) * sizeof(p2begin[0])) | (p2end - p2begin) * sizeof(p2begin[0])) | ||||
.Finalize((uint8_t *)&result); | .Finalize((uint8_t *)&result); | ||||
return result; | return result; | ||||
} | } | ||||
/** Compute the 256-bit hash of the concatenation of three objects. */ | |||||
template <typename T1, typename T2, typename T3> | |||||
inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, | |||||
const T2 p2end, const T3 p3begin, const T3 p3end) { | |||||
static const uint8_t pblank[1] = {}; | |||||
uint256 result; | |||||
CHash256() | |||||
.Write(p1begin == p1end ? pblank : (const uint8_t *)&p1begin[0], | |||||
(p1end - p1begin) * sizeof(p1begin[0])) | |||||
.Write(p2begin == p2end ? pblank : (const uint8_t *)&p2begin[0], | |||||
(p2end - p2begin) * sizeof(p2begin[0])) | |||||
.Write(p3begin == p3end ? pblank : (const uint8_t *)&p3begin[0], | |||||
(p3end - p3begin) * sizeof(p3begin[0])) | |||||
.Finalize((uint8_t *)&result); | |||||
return result; | |||||
} | |||||
/** Compute the 160-bit hash an object. */ | /** Compute the 160-bit hash an object. */ | ||||
template <typename T1> inline uint160 Hash160(const T1 pbegin, const T1 pend) { | template <typename T1> inline uint160 Hash160(const T1 pbegin, const T1 pend) { | ||||
static uint8_t pblank[1] = {}; | static uint8_t pblank[1] = {}; | ||||
uint160 result; | uint160 result; | ||||
CHash160() | CHash160() | ||||
.Write(pbegin == pend ? pblank : (const uint8_t *)&pbegin[0], | .Write(pbegin == pend ? pblank : (const uint8_t *)&pbegin[0], | ||||
(pend - pbegin) * sizeof(pbegin[0])) | (pend - pbegin) * sizeof(pbegin[0])) | ||||
.Finalize((uint8_t *)&result); | .Finalize((uint8_t *)&result); | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |