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

cache status get #1535

Merged
merged 11 commits into from
May 28, 2020
Merged

cache status get #1535

merged 11 commits into from
May 28, 2020

Conversation

InoMurko
Copy link
Contributor

@InoMurko InoMurko commented May 26, 2020

Protecting status.get from collapsing

Overview

Putting an ETS table in front of our internals.

Changes

Our underlying mechanisms can change state only on Ethereum block issuance interval (changes are in ethLogs). So pulling it more then once (for one client) per 15 seconds doesn't make any difference. But it buts lots of pressure on watchers internals.

  • Update the ETS STATUS cache on ethereum height change

Testing

mix test

@coveralls
Copy link

coveralls commented May 26, 2020

Coverage Status

Coverage increased (+0.1%) to 78.348% when pulling a130bb5 on inomurko/16-sec-status into 07ec547 on master.

@InoMurko InoMurko marked this pull request as ready for review May 26, 2020 17:14
Comment on lines 41 to 44
ets = Keyword.fetch!(opts, :ets)
:ok = event_bus.subscribe({:root_chain, "ethereum_new_height"}, link: true)
state = ets
{:ok, eth_block_number} = EthereumHeight.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the additional assignment here?

Suggested change
ets = Keyword.fetch!(opts, :ets)
:ok = event_bus.subscribe({:root_chain, "ethereum_new_height"}, link: true)
state = ets
{:ok, eth_block_number} = EthereumHeight.get()
state = Keyword.fetch!(opts, :ets)
:ok = event_bus.subscribe({:root_chain, "ethereum_new_height"}, link: true)
{:ok, eth_block_number} = EthereumHeight.get()

Comment on lines +58 to +65
defp key() do
:status
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defp key() do
:status
end
defp key(), do: :status

contract_addr = contract_map_from_hex(contracts)

mined_child_block_number = RootChain.get_mined_child_block()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the newlines? Is this the formatter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatter is ass

Comment on lines +39 to +41
def events_bucket() do
@events_bucket
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def events_bucket() do
@events_bucket
end
def events_bucket(), do: @events_bucket

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're here for the free commits aren't you

Comment on lines 95 to 101
'''
Checks geth syncing status, errors are treated as not synced.
Returns:
* false - geth is synced
* true - geth is still syncing.
'''

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'''
Checks geth syncing status, errors are treated as not synced.
Returns:
* false - geth is synced
* true - geth is still syncing.
'''
# Checks geth syncing status, errors are treated as not synced.
# Returns:
# * false - geth is synced
# * true - geth is still syncing.

# See the License for the specific language governing permissions and
# limitations under the License.

defmodule OMG.Watcher.API.StatusCache do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a few tests to cover the new functions?

@InoMurko InoMurko merged commit 2e2893c into master May 28, 2020
@InoMurko InoMurko deleted the inomurko/16-sec-status branch May 28, 2020 12:46
@unnawut unnawut added the enhancement New feature or request label Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants