CHashWriter that does SHA256 in-place during serialization #1567

pull sipa wants to merge 1 commits into bitcoin:master from sipa:chashwriter changing 1 files +42 −6
  1. sipa commented at 9:12 PM on July 7, 2012: member

    SerializeHash used to create a memory-backed CDataStream, serialize the object (almost always a CTransaction) to it, and then feed it to SHA256. As most of the time is actually spent in allocating/deallocating the buffer, it is better to do the SHA256 in-place. That is what CHashWriter does.

    On my system, in ultraprune running on a tmpfs-backed datadir, this alone reduces total CPU time spent during import of 185k blocks by 4-5%.

  2. CHashWriter that does SHA256 in-place during serialization 6ece1d747e
  3. laanwj commented at 9:14 AM on July 8, 2012: member

    Nice! ACK on the code.

    May need testcases, though there are currently no testcases for CDataStream with SER_GETHASH at all.

  4. TheBlueMatt commented at 10:43 PM on July 10, 2012: member

    ACK, though Im interested to see what kind of improvement you see by simply removing duplicated Hash calls.

  5. jgarzik commented at 2:27 AM on July 11, 2012: contributor

    ACK

  6. gavinandresen commented at 12:35 PM on July 13, 2012: contributor

    ACK

  7. gavinandresen merged this on Jul 13, 2012
  8. gavinandresen closed this on Jul 13, 2012

  9. lateminer referenced this in commit 2205e3d302 on May 6, 2020
  10. DrahtBot locked this on Sep 8, 2021
  11. DrahtBot added the label CI failed on Apr 11, 2023
  12. MarcoFalke removed the label CI failed on Apr 11, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 09:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me