mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-24 22:45:41 +01:00
Merge #19326: Simplify hash.h interface using Spans
77c507358bMake Hash[160] consume range-like objects (Pieter Wuille)02c4cc5c5dMake CHash256/CHash160 output to Span (Pieter Wuille)0ef97b1b10Make MurmurHash3 consume Spans (Pieter Wuille)e549bf8a9aMake CHash256 and CHash160 consume Spans (Pieter Wuille)2a2182c387Make script/standard's BaseHash Span-convertible (Pieter Wuille)e63dcc3a67Add MakeUCharSpan, to help constructing Span<[const] unsigned char> (Pieter Wuille)567825049fMake uint256 Span-convertible by adding ::data() (Pieter Wuille)131a2f0337scripted-diff: rename base_blob::data to m_data (Pieter Wuille) Pull request description: This makes use of the implicit constructions and conversions to Span introduced in #18468 to simplify the hash.h interface: * All functions that take a pointer and a length are changed to take a Span instead. * The Hash() and Hash160() functions are changed to take in "range" objects instead of begin/end iterators. ACKs for top commit: laanwj: re-ACK77c507358bjonatack: Code review re-ACK77c5073per `git range-diff14ceddd49fc016 77c5073` Tree-SHA512: 9ec929891b1ddcf30eb14b946ee1bf142eca1442b9de0067ad6a3c181e0c7ea0c99c0e291e7f6e7a18bd7bdf78fe94ee3d5de66e167401674caf91e026269771
This commit is contained in:
@@ -685,7 +685,7 @@ int V1TransportDeserializer::readData(const char *pch, unsigned int nBytes)
|
||||
vRecv.resize(std::min(hdr.nMessageSize, nDataPos + nCopy + 256 * 1024));
|
||||
}
|
||||
|
||||
hasher.Write((const unsigned char*)pch, nCopy);
|
||||
hasher.Write({(const unsigned char*)pch, nCopy});
|
||||
memcpy(&vRecv[nDataPos], pch, nCopy);
|
||||
nDataPos += nCopy;
|
||||
|
||||
@@ -696,7 +696,7 @@ const uint256& V1TransportDeserializer::GetMessageHash() const
|
||||
{
|
||||
assert(Complete());
|
||||
if (data_hash.IsNull())
|
||||
hasher.Finalize(data_hash.begin());
|
||||
hasher.Finalize(data_hash);
|
||||
return data_hash;
|
||||
}
|
||||
|
||||
@@ -736,7 +736,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const CMessageHeader::MessageSta
|
||||
|
||||
void V1TransportSerializer::prepareForTransport(CSerializedNetMsg& msg, std::vector<unsigned char>& header) {
|
||||
// create dbl-sha256 checksum
|
||||
uint256 hash = Hash(msg.data.begin(), msg.data.end());
|
||||
uint256 hash = Hash(msg.data);
|
||||
|
||||
// create header
|
||||
CMessageHeader hdr(Params().MessageStart(), msg.m_type.c_str(), msg.data.size());
|
||||
|
||||
Reference in New Issue
Block a user