aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-10-30 18:02:16 -0400
committerMatt Corallo <git@bluematt.me>2016-10-30 18:04:57 -0400
commitfe1dc62cef88280d2490a619beded052f313c6fc (patch)
tree508e9da109124c6bfc539451add560c2ef14ebb4 /src/net.cpp
parentd2143dc937e3fc93fd35def25a9c0461f26ccd4f (diff)
downloadbitcoin-fe1dc62cef88280d2490a619beded052f313c6fc.tar.xz
Hash P2P messages as they are received instead of at process-time
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 48ba9588d9..a2414acf46 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;
+}
+