aboutsummaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-01-02 11:31:25 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-01-02 11:40:31 +0100
commitfa24493d6394b3a477535f480664c9596f18e3c5 (patch)
tree56fb2f98aba2055c959c57ffb8022dbcd21f8d27 /src/hash.h
parentfa65bbf217b725ada35107b4ad646d250228355c (diff)
downloadbitcoin-fa24493d6394b3a477535f480664c9596f18e3c5.tar.xz
Use spans of std::byte in serialize
This switches .read() and .write() to take spans of bytes.
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/hash.h b/src/hash.h
index 1456a899d8..9f582842c1 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -111,8 +111,9 @@ public:
int GetType() const { return nType; }
int GetVersion() const { return nVersion; }
- void write(const char *pch, size_t size) {
- ctx.Write((const unsigned char*)pch, size);
+ void write(Span<const std::byte> src)
+ {
+ ctx.Write(UCharCast(src.data()), src.size());
}
/** Compute the double-SHA256 hash of all data written to this object.
@@ -162,18 +163,18 @@ private:
public:
explicit CHashVerifier(Source* source_) : CHashWriter(source_->GetType(), source_->GetVersion()), source(source_) {}
- void read(char* pch, size_t nSize)
+ void read(Span<std::byte> dst)
{
- source->read(pch, nSize);
- this->write(pch, nSize);
+ source->read(dst);
+ this->write(dst);
}
void ignore(size_t nSize)
{
- char data[1024];
+ std::byte data[1024];
while (nSize > 0) {
size_t now = std::min<size_t>(nSize, 1024);
- read(data, now);
+ read({data, now});
nSize -= now;
}
}