mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge #9045: Hash P2P messages as they are received instead of at process-time
fe1dc62 Hash P2P messages as they are received instead of at process-time (Matt Corallo)
This commit is contained in:
@@ -742,12 +742,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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user