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

Reduce function input to address' hash only where possible #2325

Merged
merged 2 commits into from
Jul 10, 2019

Conversation

pasqu4le
Copy link
Contributor

@pasqu4le pasqu4le commented Jul 9, 2019

Motivation

A lot of function take an Explorer.Chain.Address as an parameter, but only use its hash.
This makes tracing the necessary scope of functions harder and is one of the cause for unnecessary queries/code execution.

Changelog

This PR refactors these functions to take only an address' hash.
A small amount of them have been considered exceptions and left as is (e.g. in case where the function is simple and already has multiple declarations to take an address or just its hash).

Checklist for your PR

  • I added an entry to CHANGELOG.md with this PR
  • If I added new functionality, I added tests covering it.
  • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • I checked whether I should update the docs and did so if necessary

@pasqu4le pasqu4le self-assigned this Jul 9, 2019
Problem: a lot of function take an Explorer.Chain.Address as an parameter, but only use its hash.
This makes tracing the necessary scope of functions harder and is one of the cause for unnecessary queries/code execution.

Solution: refactor this functions to take only an address' hash.
@pasqu4le pasqu4le force-pushed the pp-limit-input-to-address-hash branch from 1769578 to 4e2ba9a Compare July 9, 2019 14:53
@pasqu4le pasqu4le added ready for review This PR is ready for reviews. and removed in progress labels Jul 9, 2019
@coveralls
Copy link

coveralls commented Jul 9, 2019

Pull Request Test Coverage Report for Build 91f28a3f-9187-42b8-8648-f928d98bb553

  • 13 of 20 (65.0%) changed or added relevant lines in 9 files are covered.
  • 4 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.04%) to 80.945%

Changes Missing Coverage Covered Lines Changed/Added Lines %
apps/explorer/lib/explorer/chain/address_token_transfer_csv_exporter.ex 2 3 66.67%
apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex 0 2 0.0%
apps/block_scout_web/lib/block_scout_web/controllers/address_validation_controller.ex 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
apps/explorer/lib/explorer/chain.ex 1 80.97%
apps/block_scout_web/lib/block_scout_web/controllers/address_validation_controller.ex 1 0.0%
apps/explorer/lib/explorer/market/market_history_cache.ex 2 88.89%
Totals Coverage Status
Change from base Build 4caf5a1a-fc4d-44f0-9cae-ca0117135d6a: -0.04%
Covered Lines: 5191
Relevant Lines: 6413

💛 - Coveralls

@vbaranov vbaranov merged commit 68a1409 into master Jul 10, 2019
@vbaranov vbaranov deleted the pp-limit-input-to-address-hash branch July 10, 2019 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review This PR is ready for reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants