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

AccountModule: Bypass connection hooks on local / unknown networks #1474

Merged
merged 2 commits into from
Jul 6, 2020

Conversation

Evalir
Copy link
Contributor

@Evalir Evalir commented Jul 6, 2020

On local networks that are not simulating block mining, the Account Module eventually will show there may be sync issues / no connection due to it not detecting any activity on-chain. This is desired behavior, but we need to avoid it on local chains.

Copy link
Contributor Author

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

A few notes for clarification:

}

if (
clientListening &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need to check the native client connection; if not we could have a false positive when the client websockets suddenly close.

const isWalletAndClientSynced =
Math.abs(walletSyncDelay - clientSyncDelay) <= OK_PROVIDER_SYNC_DELAY
const networkSlowdown =
walletSyncDelay >= MILD_PROVIDER_SYNC_DELAY &&
clientSyncDelay >= MILD_PROVIDER_SYNC_DELAY &&
isWalletAndClientSynced
const networkName = network.shortName.toLowerCase()
Copy link
Contributor Author

@Evalir Evalir Jul 6, 2020

Choose a reason for hiding this comment

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

Using network.shortName instead of network.type due to this issue. The reason I'm not using chainId is because this is only for local / unknown chains where we don't know its behavior, and the chainId can be changed with an environment variable for local networks. Might add a comment for clearing this up!

Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Nice, ❤️ how simple this was!

src/components/AccountModule/connection-hooks.js Outdated Show resolved Hide resolved
src/components/AccountModule/connection-hooks.js Outdated Show resolved Hide resolved
Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

🙌 LGTM!

@Evalir Evalir merged commit 380fb85 into master Jul 6, 2020
@Evalir Evalir deleted the suppress-sync-state-locally branch July 6, 2020 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants