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

format code/code refactor #18

Open
ayrat555 opened this issue Apr 17, 2018 · 2 comments
Open

format code/code refactor #18

ayrat555 opened this issue Apr 17, 2018 · 2 comments

Comments

@ayrat555
Copy link
Member

format code with elixir code formatter and refactor if necessary

For example,

    # The following checks Holistic Validity, as defined in Eq.(29)
    errors = []
      ++ if child_block.header.state_root == block.header.state_root, do: [], else: [:state_root_mismatch]
      ++ if child_block.header.ommers_hash == block.header.ommers_hash, do: [], else: [:ommers_hash_mismatch]
      ++ if child_block.header.transactions_root == block.header.transactions_root, do: [], else: [:transactions_root_mismatch]
      ++ if child_block.header.receipts_root == block.header.receipts_root, do: [], else: [:receipts_root_mismatch]

turns into

    # The following checks Holistic Validity, as defined in Eq.(29)
    errors =
      [] ++
        if child_block.header.state_root == block.header.state_root,
          do: [],
          else:
            [:state_root_mismatch] ++
              if(
                child_block.header.ommers_hash == block.header.ommers_hash,
                do: [],
                else:
                  [:ommers_hash_mismatch] ++
                    if(
                      child_block.header.transactions_root == block.header.transactions_root,
                      do: [],
                      else:
                        [:transactions_root_mismatch] ++
                          if(
                            child_block.header.receipts_root == block.header.receipts_root,
                            do: [],
                            else: [:receipts_root_mismatch]
                          )
                    )
              )
@hayesgm
Copy link
Contributor

hayesgm commented Apr 17, 2018

Yup, there should be a number of ways to refactor that code that would end up a lot cleaner. Possibly a number of function called piped to each other, for instance. Or even, just binding each of the ++ clauses to variables and ending with the concatentation of them.

@atoulme
Copy link
Member

atoulme commented Aug 14, 2018

I don't see this particular code path and its formatting.

I am reenabling formatting checks as part of the build and adding a formatting configuration file, as well as its effects in #22. Please let me know if this helps.

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

3 participants