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

Refactor OptAppAndData #281

Open
matthiasgeihs opened this issue Dec 7, 2021 · 0 comments
Open

Refactor OptAppAndData #281

matthiasgeihs opened this issue Dec 7, 2021 · 0 comments

Comments

@matthiasgeihs
Copy link
Contributor

matthiasgeihs commented Dec 7, 2021

In actual, nothing is optional. Both App and Data must be non-nil values. What happens internally is:

  1. If the app is noApp: for encoding, we encode false and just return. for decoding, we read the false value and set app, data to noApp and noData repectively.
  2. Else: for encoding, we encode true, followed by the app and data. for decoding: we read the true value and then decode the app and data.

With the above understanding, I think a single struct called AppAndData with Encode and Decode methods defined on it will be a better approach.

However, this was an existing construct, which I only moved it from one package to another.
Because, this PR in itself is somewhat large, if we need to modify this, I think we should do in a separate one.

Originally posted by @manoranjith in #272 (comment)

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

No branches or pull requests

1 participant