Skip to content
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

Merged
merged 11 commits into from
Sep 4, 2024
Merged

Conversation

containerman17
Copy link
Contributor

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 the codec.Codec interface, allowing unpacking directly from wrappers.Packer instead of []byte.

How this was tested

In codectest.go

It was also indirectly tested in this HyperSDK PR.

Copy link
Collaborator

@aaronbuchwald aaronbuchwald left a 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
Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Collaborator

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

@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 4, 2024
Merged via the queue into master with commit 84a2c77 Sep 4, 2024
21 checks passed
@StephenButtolph StephenButtolph deleted the codec-unmarshal-from branch September 4, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants