NebulousLabs / Sia

Blockchain-based marketplace for file storage. Project has moved to GitLab: https://gitlab.com/NebulousLabs/Sia
https://sia.tech
MIT License
2.71k stars 440 forks source link

Moving encoding helpers into encoding package #3124

Closed lukechampine closed 6 years ago

lukechampine commented 6 years ago

These helpers are really nice for writing clean and efficient MarshalSia/UnmarshalSia methods, so there's no reason to hide them in the types package. Moving them into encoding also allows the Marshal and Unmarshal 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.

DavidVorick commented 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?

lukechampine commented 6 years ago

I settled on WritePrefixedBytes so it would have symmetry with ReadPrefixedBytes (ReadWithPrefix sounds weird).

IBD completed in 2 hours with no issues.