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

ObscuroScan: load eth price on init #1626

Merged
merged 3 commits into from
Oct 27, 2023
Merged

Conversation

BedrockSquirrel
Copy link
Collaborator

Why this change is needed

Currently it takes one minute before the eth price is requested so we see a loading circle. The other data also has a slight (1 second) delay before it loads because it waits for its polling interval.

What changes were made as part of this PR

Change the poller semantics to make the request immediately when started and then at the interval thereafter.

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2023

Walkthrough

The changes primarily focus on modifying the polling interval for price updates in the frontend and adjusting the default server address in the backend. The polling interval is now set to 1 minute, improving readability and maintainability. The server address has been changed to "0.0.0.0:43910". Additionally, the polling process now starts with an immediate fetch callback execution.

Changes

File Path Summary
.../backend/cmd/cli.go The default server address has been changed from "0.0.0.0:80" to "0.0.0.0:43910".
.../frontend/src/lib/config.*.js The pricePollingInterval property in the Config class has been changed from 10000*10000 to 60*1000, representing a 1-minute interval.
.../frontend/src/lib/poller.js The start() method in the Poller class now initiates with an immediate execution of fetchCallback().
.../frontend/src/stores/priceStore.js The poller is now created with a new Poller instance with a polling interval set by Config.pricePollingInterval. The fetch action logs the fetched ethPriceUSD value.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 06e56bd and baaa0ab.
Files selected for processing (6)
  • tools/obscuroscan_v2/backend/cmd/cli.go (1} hunks)
  • tools/obscuroscan_v2/frontend/src/lib/config.dev.js (1} hunks)
  • tools/obscuroscan_v2/frontend/src/lib/config.js (1} hunks)
  • tools/obscuroscan_v2/frontend/src/lib/config.prod.js (1} hunks)
  • tools/obscuroscan_v2/frontend/src/lib/poller.js (1} hunks)
  • tools/obscuroscan_v2/frontend/src/stores/priceStore.js (2} hunks)
Files skipped from review due to trivial changes (4)
  • tools/obscuroscan_v2/frontend/src/lib/config.dev.js
  • tools/obscuroscan_v2/frontend/src/lib/config.js
  • tools/obscuroscan_v2/frontend/src/lib/config.prod.js
  • tools/obscuroscan_v2/frontend/src/lib/poller.js
Additional comments: 2
tools/obscuroscan_v2/backend/cmd/cli.go (1)
  • 12-12: The server address port has been changed from 80 to 43910. Ensure that this port is open and properly configured in your network settings to avoid connection issues. Also, verify that all parts of the system that interact with this server are updated to use the new port.
tools/obscuroscan_v2/frontend/src/stores/priceStore.js (1)
  • 12-12: The polling interval has been changed from 60*Config.pollingInterval to Config.pricePollingInterval. Ensure that the pricePollingInterval is defined and set correctly in the Config class. Also, verify that this change doesn't affect other parts of the code that might be using the old pollingInterval.

} catch (error) {
console.error("Failed to fetch count:", error);
}
},

startPolling() {
async startPolling() {
Copy link

Choose a reason for hiding this comment

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

The startPolling function has been made asynchronous, but there are no await expressions inside it. If you plan to add asynchronous operations inside this function in the future, this change is fine. Otherwise, it's unnecessary to declare it as async.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between baaa0ab and 68d8269.
Files selected for processing (1)
  • tools/obscuroscan_v2/frontend/src/stores/priceStore.js (2} hunks)
Files skipped from review due to trivial changes (1)
  • tools/obscuroscan_v2/frontend/src/stores/priceStore.js

@@ -9,7 +9,7 @@ export const usePriceStore = defineStore({
poller: new Poller(() => {
const store = usePriceStore();
store.fetch();
}, 60*Config.pollingInterval)
}, Config.pricePollingInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a need to have the price updated at the second ? Also, I think it happened to me getting limit rated for polling too fast, might want to avoid the client limit rated for polling too fast too.

@BedrockSquirrel BedrockSquirrel merged commit bddbf71 into main Oct 27, 2023
2 checks passed
@BedrockSquirrel BedrockSquirrel deleted the matt/initial-load-eth-price branch October 27, 2023 09:32
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

Successfully merging this pull request may close these issues.

2 participants