Skip to content

codec; Enable custom scale methods#597

Merged
edwardmack merged 8 commits intodevelopmentfrom
ed/525-custom-scale-methods
Feb 10, 2020
Merged

codec; Enable custom scale methods#597
edwardmack merged 8 commits intodevelopmentfrom
ed/525-custom-scale-methods

Conversation

@edwardmack
Copy link
Copy Markdown
Contributor

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 <ed@edwardmack.com>
Signed-off-by: edwardmack <ed@edwardmack.com>
Copy link
Copy Markdown
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!! :)

Comment thread go.mod
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
Copy Markdown
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
Copy Markdown
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 <ed@edwardmack.com>

* go fmt'ed

Signed-off-by: edwardmack <ed@edwardmack.com>

* fixed lint rants

Signed-off-by: edwardmack <ed@edwardmack.com>

Co-authored-by: noot <36753753+noot@users.noreply.github.com>
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