Merge bitcoin/bitcoin#25331: Add HashWriter without ser-type and ser-version and use it where possible

faf9accd66 Use HashWriter where possible (MacroFake)
faa5425629 Add HashWriter without ser-type and ser-version (MacroFake)

Pull request description:

  This was done in the context of https://github.com/bitcoin/bitcoin/pull/25284 , but I think it also makes sense standalone.

  The basic idea is that serialization type should not be initialized when it is not needed. Same for the serialization version.

  So do this here for `HashWriter`. `CHashWriter` remains in places where it is not yet possible.

ACKs for top commit:
  sipa:
    utACK faf9accd66
  Empact:
    utACK faf9accd66

Tree-SHA512: 544cc712436e49f6e608120bcd3ddc5ea72dd236554ce30fb6cfff34a92d7e67b6e6527336ad0f5b6365e2b2884f4c6508aef775953ccd9312f17752729703f2
This commit is contained in:
fanquake
2022-07-22 08:36:00 +01:00
14 changed files with 65 additions and 53 deletions

View File

@@ -74,7 +74,7 @@ bool MessageSign(
uint256 MessageHash(const std::string& message)
{
CHashWriter hasher(SER_GETHASH, 0);
HashWriter hasher{};
hasher << MESSAGE_MAGIC << message;
return hasher.GetHash();