Branch: refs/heads/master
  Home:   https://github.com/btcsuite/btcd
  Commit: 6211eef7eef5b1cc7c48bacf0f439917d914e199
      
https://github.com/btcsuite/btcd/commit/6211eef7eef5b1cc7c48bacf0f439917d914e199
  Author: Dave Collins <[email protected]>
  Date:   2015-04-06 (Mon, 06 Apr 2015)

  Changed paths:
    M blockchain/merkle.go
    M wire/bench_test.go
    M wire/blockheader.go
    M wire/common.go
    M wire/msgtx.go

  Log Message:
  -----------
  wire: Add new DoubleSha256SH function.

This commit adds a new function which is similar to the DoubleSha256
function except it returns a ShaHash copy instead of a byte slice.  It
also adds a new benchmark for it.

This can be a slight optimization in certain cases where the caller
ultimately wants a ShaHash since it can avoid a heap allocation and
additional copy to convert the result to a ShaHash (the function simply
performs a type cast against the returned array which is not possible
against a []byte).

existing: DoubleSha256     500000   3081 ns/op   32 B/op   1 allocs/op
     new: DoubleSha256SH   500000   2939 ns/op    0 B/op   0 allocs/op

The hashing functions for blocks and transactions have also been updated
to make use of the new function since they directly return the ShaHash.
The transaction change in particular is quite useful since transactions
are frequently hashed and this change allows all of those hashes to avoid
an additional heap allocation.


Reply via email to