diff options
| author | Adam Soltys <[email protected]> | 2026-03-14 04:49:54 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-14 04:49:54 +0000 |
| commit | fddfe10f84908c058e239b93985dfe02ba37df04 (patch) | |
| tree | 563740d528cf7cc2f4ebe5a06a598a40a8cfed1c /lib | |
| parent | 76f886edde74e8a77d62ecf7caa0b7bd8232a2fe (diff) | |
| download | coinos-server-fddfe10f84908c058e239b93985dfe02ba37df04.tar.gz coinos-server-fddfe10f84908c058e239b93985dfe02ba37df04.zip | |
slow down ark checksark2
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ark.ts | 14 | ||||
| -rw-r--r-- | lib/payments.ts | 7 |
2 files changed, 10 insertions, 11 deletions
@@ -36,7 +36,7 @@ const getWallet = async () => { let refreshing = false; let lastRefresh = 0; -const REFRESH_COOLDOWN = 30_000; +const REFRESH_COOLDOWN = 300_000; let failedBoardingOutpoints = new Set<string>(); const FAILED_BOARDING_KEY = "ark:failedBoardingOutpoints"; const loadFailedOutpoints = async () => { @@ -66,6 +66,7 @@ export const refreshArkWallet = async (force = false) => { lastRefresh = now; const w = await getWallet(); const balance = await w.getBalance(); + cachedArkBalance = balance; const manager = new VtxoManager(w); const provider = new RestArkProvider(config.ark.arkServerUrl); const info = await provider.getInfo(); @@ -184,8 +185,8 @@ export const refreshArkWallet = async (force = false) => { }; // Initial check after 60s startup delay; retry every 60s to catch ark rounds -setTimeout(refreshArkWallet, 60_000); -setInterval(() => refreshArkWallet(), 60_000); +setTimeout(refreshArkWallet, 300_000); +setInterval(() => refreshArkWallet(), 300_000); export const sendArk = async (address: string, amount: number) => { @@ -219,10 +220,9 @@ export const getArkAddress = async () => { return w.getAddress(); }; -export const getArkBalance = async () => { - const w = await getWallet(); - return w.getBalance(); -}; +let cachedArkBalance: any = null; + +export const getArkBalance = () => cachedArkBalance; export const verifyArkVtxo = async (hash: string) => { const { bech32m } = await import("@scure/base"); diff --git a/lib/payments.ts b/lib/payments.ts index dfbdd3c4..5650dda4 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -1750,12 +1750,11 @@ const freezeCheck = async () => { await s("ecash:limit", Math.max(lnbalance - lnthreshold, 0)); await s("bolt12:limit", Math.max(lnbalance - lnthreshold, 0)); - try { - const arkBalance = await getArkBalance(); + const arkBalance = getArkBalance(); + if (arkBalance) { const arkthreshold = (await g("ark:threshold")) || 0; + await s("ark:available", arkBalance.available); await s("ark:limit", Math.max(arkBalance.available - arkthreshold, 0)); - } catch (e) { - warn("freezeCheck ark balance failed:", e.message); } setTimeout(freezeCheck, 10000); |
