-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add zcash_serialized_size()
to ZcashSerialize
trait
#2824
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's two ways we can be more efficient here:
- stop allocating RAM and writing data to it - just sum the serialized sizes instead
- calculate the serialized size once, then add it to
UnminedTx
as a new field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few performance tweaks we could do.
Co-authored-by: teor <teor@riseup.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Motivation
I am not totally sure this is the way to do it but just a quick attempt to resolve #2778
I am open to just close the PR if this is not a good idea or make changes if needed.
Consensus Rules
https://zips.z.cash/zip-0401#specification
Solution
Use the already in place
zcash_serialize_to_vec()
helper function to simplify the task of getting a serialized size of any object, in this case we are using it to get the size of a transaction.Review
I think anyone can review.