From baaa0ab7672901baa55b58ad11ca779f213fa138 Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Fri, 27 Oct 2023 07:06:17 +0100 Subject: [PATCH 1/3] ObscuroScan: load data immediately on init --- tools/obscuroscan_v2/backend/cmd/cli.go | 2 +- tools/obscuroscan_v2/frontend/src/lib/config.dev.js | 2 +- tools/obscuroscan_v2/frontend/src/lib/config.js | 2 +- tools/obscuroscan_v2/frontend/src/lib/config.prod.js | 2 +- tools/obscuroscan_v2/frontend/src/lib/poller.js | 2 ++ tools/obscuroscan_v2/frontend/src/stores/priceStore.js | 6 +++--- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/obscuroscan_v2/backend/cmd/cli.go b/tools/obscuroscan_v2/backend/cmd/cli.go index 863876ff31..4cc20f59f9 100644 --- a/tools/obscuroscan_v2/backend/cmd/cli.go +++ b/tools/obscuroscan_v2/backend/cmd/cli.go @@ -9,7 +9,7 @@ import ( func parseCLIArgs() *config.Config { defaultConfig := &config.Config{ NodeHostAddress: "http://erpc.dev-testnet.obscu.ro:80", - ServerAddress: "0.0.0.0:80", + ServerAddress: "0.0.0.0:43910", LogPath: "obscuroscan_logs.txt", } diff --git a/tools/obscuroscan_v2/frontend/src/lib/config.dev.js b/tools/obscuroscan_v2/frontend/src/lib/config.dev.js index d3ee7ef092..cf242044b4 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/config.dev.js +++ b/tools/obscuroscan_v2/frontend/src/lib/config.dev.js @@ -1,7 +1,7 @@ class Config { static backendServerAddress = "http://127.0.0.1:43910" static pollingInterval = 1000 - static pricePollingInterval = 10000*10000 + static pricePollingInterval = 60*1000 // 1 minute static version = "dev" } diff --git a/tools/obscuroscan_v2/frontend/src/lib/config.js b/tools/obscuroscan_v2/frontend/src/lib/config.js index d3ee7ef092..cf242044b4 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/config.js +++ b/tools/obscuroscan_v2/frontend/src/lib/config.js @@ -1,7 +1,7 @@ class Config { static backendServerAddress = "http://127.0.0.1:43910" static pollingInterval = 1000 - static pricePollingInterval = 10000*10000 + static pricePollingInterval = 60*1000 // 1 minute static version = "dev" } diff --git a/tools/obscuroscan_v2/frontend/src/lib/config.prod.js b/tools/obscuroscan_v2/frontend/src/lib/config.prod.js index 99f6467308..affe11ac2b 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/config.prod.js +++ b/tools/obscuroscan_v2/frontend/src/lib/config.prod.js @@ -2,7 +2,7 @@ class Config { // VITE_APIHOSTADDRESS should be used as an env var at the prod server static backendServerAddress = import.meta.env.VITE_APIHOSTADDRESS static pollingInterval = 1000 - static pricePollingInterval = 10*this.pollingInterval + static pricePollingInterval = 60*1000 // 1 minute static version = import.meta.env.VITE_FE_VERSION } diff --git a/tools/obscuroscan_v2/frontend/src/lib/poller.js b/tools/obscuroscan_v2/frontend/src/lib/poller.js index 0afac84746..8a758bd94b 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/poller.js +++ b/tools/obscuroscan_v2/frontend/src/lib/poller.js @@ -5,8 +5,10 @@ class Poller { this.timer = null; } + // Start polling - executes the fetchCallback immediately and every interval thereafter start() { this.stop(); // Ensure previous intervals are cleared + this.fetchCallback(); this.timer = setInterval(async () => { await this.fetchCallback(); }, this.interval); diff --git a/tools/obscuroscan_v2/frontend/src/stores/priceStore.js b/tools/obscuroscan_v2/frontend/src/stores/priceStore.js index 7134ff7e1c..61739b542b 100644 --- a/tools/obscuroscan_v2/frontend/src/stores/priceStore.js +++ b/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) }), actions: { async fetch() { @@ -18,13 +18,13 @@ export const usePriceStore = defineStore({ const data = await response.json(); this.ethPriceUSD = data.ethereum.usd; - console.log("Fetched "+this.ethPriceUSD); + console.log("Fetched " + this.ethPriceUSD); } catch (error) { console.error("Failed to fetch count:", error); } }, - startPolling() { + async startPolling() { this.poller.start(); }, From e3fb933564266643cad734f0ae42975cdb32c43a Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Fri, 27 Oct 2023 07:17:06 +0100 Subject: [PATCH 2/3] revert port change --- tools/obscuroscan_v2/backend/cmd/cli.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/obscuroscan_v2/backend/cmd/cli.go b/tools/obscuroscan_v2/backend/cmd/cli.go index 4cc20f59f9..863876ff31 100644 --- a/tools/obscuroscan_v2/backend/cmd/cli.go +++ b/tools/obscuroscan_v2/backend/cmd/cli.go @@ -9,7 +9,7 @@ import ( func parseCLIArgs() *config.Config { defaultConfig := &config.Config{ NodeHostAddress: "http://erpc.dev-testnet.obscu.ro:80", - ServerAddress: "0.0.0.0:43910", + ServerAddress: "0.0.0.0:80", LogPath: "obscuroscan_logs.txt", } From 68d826973b795eb6b7f66a40ee5655db99216491 Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Fri, 27 Oct 2023 10:14:41 +0100 Subject: [PATCH 3/3] revert unused async --- tools/obscuroscan_v2/frontend/src/stores/priceStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/obscuroscan_v2/frontend/src/stores/priceStore.js b/tools/obscuroscan_v2/frontend/src/stores/priceStore.js index 61739b542b..60c07a7dc3 100644 --- a/tools/obscuroscan_v2/frontend/src/stores/priceStore.js +++ b/tools/obscuroscan_v2/frontend/src/stores/priceStore.js @@ -24,7 +24,7 @@ export const usePriceStore = defineStore({ } }, - async startPolling() { + startPolling() { this.poller.start(); },