-
Notifications
You must be signed in to change notification settings - Fork 670
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
UnmarshalFrom support in codec.Codec #3335
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.
Approved with one optional nit
codec/codec.go
Outdated
@@ -23,6 +23,7 @@ var ( | |||
type Codec interface { | |||
MarshalInto(interface{}, *wrappers.Packer) error | |||
Unmarshal([]byte, interface{}) error |
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.
Would it make sense to remove Unmarshal
entirely and have the codec manager do the exhaustion check?
This interface feels weird. (Not really having to do with your PR... but the existing code feels weird)
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.
If we'd prefer to leave that as a potential followup - I think that's reasonable too.
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 that should be a follow up instead of being part of this PR
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: aaronbuchwald <[email protected]>
Why this should be merged
This should be merged because it makes sense for HyperSDK to use avalanchego's default codec, but the current implementation is not compatible.
How this works
This adds an
UnmarshalFrom
function in thecodec.Codec
interface, allowing unpacking directly fromwrappers.Packer
instead of[]byte
.How this was tested
In codectest.go
It was also indirectly tested in this HyperSDK PR.