Branch: refs/heads/master
Home: https://github.com/conformal/btcwire
Commit: 843e71515a3bffbd10b46a79627aa44832c6ed72
https://github.com/conformal/btcwire/commit/843e71515a3bffbd10b46a79627aa44832c6ed72
Author: Dave Collins <[email protected]>
Date: 2014-06-29 (Sun, 29 Jun 2014)
Changed paths:
M blockheader.go
M internal_test.go
M msgblock.go
M msgblock_test.go
M msgtx.go
Log Message:
-----------
Expose new SerializeSize API for blocks.
This commit adds a new function named SerializeSize to the public API for
MsgBlock which can be used to determine how many bytes the serialized data would
take without having to actually serialize it. In addition, it makes the
exported BlockVersion an untyped constant as well as changes the block and
tx versions to a signed integer to more closely match the protocol.
Finally, this commit also adds tests for the new function.
The following benchmark shows the difference between using the new
function to get the serialize size for a typical block and serializing
into a temporary buffer and taking the length of it:
Bufffer: BenchmarkBlockSerializeSizeBuffer 200000 27050 ns/op
New: BenchmarkBlockSerializeSizeNew 100000000 34 ns/op
Closes #19.