diff --git a/src/lib/components/settings/ExtraFeaturesSettings.svelte b/src/lib/components/settings/ExtraFeaturesSettings.svelte index bea0033..2287d5b 100644 --- a/src/lib/components/settings/ExtraFeaturesSettings.svelte +++ b/src/lib/components/settings/ExtraFeaturesSettings.svelte @@ -13,6 +13,7 @@ export let miningPoolMap: Map; let validBitaxe = false; + let validLocalPool = false; const testBitaxe = async () => { try { const response = await fetch(`http://${$settings.bitaxeHostname}/api/system/info`); @@ -61,6 +62,49 @@ miningPoolMap.get(pool) || pool, pool ]); + + const testLocalPool = async () => { + try { + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 1000); + + const response = await fetch( + `http://${$settings.localPoolEndpoint}/api/client/${$settings.miningPoolUser}`, + { signal: controller.signal } + ); + clearTimeout(timeoutId); + + if (!response.ok) { + dispatch('showToast', { + color: 'danger', + text: `Failed to connect to local pool! status: ${response.status}` + }); + validLocalPool = false; + throw new Error(); + } + + const poolInfo = await response.json(); + dispatch('showToast', { + color: 'success', + text: `Can connect to local public pool, ${poolInfo.workersCount} workers` + }); + validLocalPool = true; + } catch (error) { + if (error.name === 'AbortError') { + dispatch('showToast', { + color: 'danger', + text: `Connection to local pool timed out after 1 second` + }); + } else { + dispatch('showToast', { + color: 'danger', + text: `Failed to connect to local pool, check the endpoint and make sure you are connected to the same network.` + }); + } + console.error('Failed to fetch local pool info:', error); + validLocalPool = false; + } + }; @@ -178,6 +222,21 @@ size={$uiSettings.inputSize} selectClass={$uiSettings.selectClass} /> + {#if $settings.miningPoolName === 'local_public_pool'} + + + + {/if}