Closed lukechampine closed 6 years ago
I'm surprised these weren't already in the encoding package.
@lukechampine can you run an IBD on this branch once you are happy with it to make sure it can sync the current chain?
I settled on WritePrefixedBytes
so it would have symmetry with ReadPrefixedBytes
(ReadWithPrefix
sounds weird).
IBD completed in 2 hours with no issues.
These helpers are really nice for writing clean and efficient
MarshalSia
/UnmarshalSia
methods, so there's no reason to hide them in thetypes
package. Moving them intoencoding
also allows theMarshal
andUnmarshal
functions to make use of them.This is a low-priority PR. It brings a nice performance benefit (approx. half as many allocations when encoding/decoding types without custom marshaler methods), and will be useful any time we want to write
MarshalSia
/UnmarshalSia
methods down the line, but it certainly isn't blocking anything.