From fe1dc62cef88280d2490a619beded052f313c6fc Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 30 Oct 2016 18:02:16 -0400 Subject: Hash P2P messages as they are received instead of at process-time --- src/net.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index 48ba9588d..a2414acf4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -758,12 +758,21 @@ int CNetMessage::readData(const char *pch, unsigned int nBytes) vRecv.resize(std::min(hdr.nMessageSize, nDataPos + nCopy + 256 * 1024)); } + hasher.Write((const unsigned char*)pch, nCopy); memcpy(&vRecv[nDataPos], pch, nCopy); nDataPos += nCopy; return nCopy; } +const uint256& CNetMessage::GetMessageHash() const +{ + assert(complete()); + if (data_hash.IsNull()) + hasher.Finalize(data_hash.begin()); + return data_hash; +} + -- cgit v1.2.3