aboutsummaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-06-18 16:32:32 -0700
committerPieter Wuille <pieter@wuille.net>2020-07-30 13:57:53 -0700
commite549bf8a9afae42fcda805e216a1cde62df195a6 (patch)
tree2d00e10ead84a3162f7ddc74300dcfbd340853a4 /src/hash.h
parent2a2182c387f607cd8284f33890bd285a81077b7f (diff)
Make CHash256 and CHash160 consume Spans
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/hash.h b/src/hash.h
index c295568a3e..3289bdee2f 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -31,8 +31,8 @@ public:
sha.Reset().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash);
}
- CHash256& Write(const unsigned char *data, size_t len) {
- sha.Write(data, len);
+ CHash256& Write(Span<const unsigned char> input) {
+ sha.Write(input.data(), input.size());
return *this;
}
@@ -55,8 +55,8 @@ public:
CRIPEMD160().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash);
}
- CHash160& Write(const unsigned char *data, size_t len) {
- sha.Write(data, len);
+ CHash160& Write(Span<const unsigned char> input) {
+ sha.Write(input.data(), input.size());
return *this;
}
@@ -72,7 +72,7 @@ inline uint256 Hash(const T1 pbegin, const T1 pend)
{
static const unsigned char pblank[1] = {};
uint256 result;
- CHash256().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0]))
+ CHash256().Write({pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0])})
.Finalize((unsigned char*)&result);
return result;
}
@@ -83,8 +83,8 @@ inline uint256 Hash(const T1 p1begin, const T1 p1end,
const T2 p2begin, const T2 p2end) {
static const unsigned char pblank[1] = {};
uint256 result;
- CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]))
- .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]))
+ CHash256().Write({p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])})
+ .Write({p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])})
.Finalize((unsigned char*)&result);
return result;
}
@@ -95,7 +95,7 @@ inline uint160 Hash160(const T1 pbegin, const T1 pend)
{
static unsigned char pblank[1] = {};
uint160 result;
- CHash160().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0]))
+ CHash160().Write({pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0])})
.Finalize((unsigned char*)&result);
return result;
}
@@ -129,7 +129,7 @@ public:
int GetVersion() const { return nVersion; }
void write(const char *pch, size_t size) {
- ctx.Write((const unsigned char*)pch, size);
+ ctx.Write({(const unsigned char*)pch, size});
}
// invalidates the object