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

Add multiple EncodeTo improvements #72

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Nov 12, 2021

Enum econding:

  • Check that enum values are legal before encoding them
  • Use e as the receiver name of EncodeTo (it was using s) which is inconsistent with the rest of the code.

Union encoding:

Layout improvements:

-       err = s.SeqNum.EncodeTo(e)
-       if err != nil {
+       if err = s.SeqNum.EncodeTo(e); err != nil {
                return err
        }
  • Fix incorrectly nested error checks
        if s.InflationDest != nil {
-               err = (*s.InflationDest).EncodeTo(e)
-       }
-       if err != nil {
-               return err
+               if err = (*s.InflationDest).EncodeTo(e); err != nil {
+                       return err
+               }
        }

Closes #70

@2opremio
Copy link
Contributor Author

You can see the generated code at stellar/go#4068

@2opremio 2opremio merged commit 0e66fb9 into master Nov 15, 2021
@2opremio 2opremio deleted the encodeto-improvements branch November 15, 2021 14:43
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.

EncodeTo() should error when encountering invalid union discriminant values
3 participants