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

codec; Enable custom scale methods #597

Merged
merged 8 commits into from
Feb 10, 2020

Conversation

edwardmack
Copy link
Member

This PR introduces functionality for handling custom Encode/Decode function for types when these functions have been defined.

Changes

  • EncodeCustom function added which checks if interface has Encode function defined, if so it uses that for encoding, if not it uses the standard scale encoding.
  • DecodeCustom function added which checks if interface has Decode function defined, if so it uses that for decoding, if not it uses the standard scale decoding.
  • Added test cases for testing this.

Tests:

 go test ./codec/... 

Issues:

closes #525

DecodeCustom handles calling Decode function for types that have Decode
defined, otherwise uses regular Scale Decoding functions

Signed-off-by: edwardmack <[email protected]>
Signed-off-by: edwardmack <[email protected]>
Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!! :)

@@ -11,8 +11,8 @@ require (
github.com/disiqueira/gotree v1.0.0
github.com/ethereum/go-ethereum v1.9.6
github.com/filecoin-project/go-leb128 v0.0.0-20190212224330-8d79a5489543
github.com/golang/protobuf v1.3.2 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have raised https://github.com/ChainSafe/gossamer/wiki/GoMOD#pr-597 to track the gomod changes for this PR. Lets try to keep it updated for the next changes.

Copy link
Contributor

@thomasmodeneis thomasmodeneis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I have added a comment on the go.mod changes to track the changes, other than that it looks good.

@edwardmack edwardmack merged commit 6167ab6 into development Feb 10, 2020
@noot noot deleted the ed/525-custom-scale-methods branch February 10, 2020 16:53
ryanchristo pushed a commit that referenced this pull request Jun 24, 2020
* checks if type has Encode function

* Added DecodeCustom to handle calling Decode func

DecodeCustom handles calling Decode function for types that have Decode
defined, otherwise uses regular Scale Decoding functions

Signed-off-by: edwardmack <[email protected]>

* go fmt'ed

Signed-off-by: edwardmack <[email protected]>

* fixed lint rants

Signed-off-by: edwardmack <[email protected]>

Co-authored-by: noot <[email protected]>
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.

Enable Custom Scale Methods
4 participants