From fbdf26792f411e20286e49481c9540b489964a1c Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Thu, 3 Nov 2022 14:25:52 +0000 Subject: [PATCH] Ensure config resets when running for multi chains --- src/autostake/index.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/autostake/index.mjs b/src/autostake/index.mjs index 1fecb1f7..afdef096 100644 --- a/src/autostake/index.mjs +++ b/src/autostake/index.mjs @@ -108,6 +108,7 @@ export default function Autostake(mnemonic, opts) { async function getNetworkRunner(data) { const network = new Network(data) + let config = { ...opts } try { await network.load() } catch { @@ -132,7 +133,7 @@ export default function Autostake(mnemonic, opts) { if (!network.authzSupport) return timeStamp('No Authz support') - await network.connect({ timeout: opts.delegationsTimeout || 20000 }) + await network.connect({ timeout: config.delegationsTimeout || 20000 }) const { restUrl, usingDirectory } = network @@ -143,7 +144,7 @@ export default function Autostake(mnemonic, opts) { if (usingDirectory) { timeStamp('You are using public nodes, they may not be reliable. Check the README to use your own') timeStamp('Delaying briefly and adjusting config to reduce load...') - opts = {...opts, batchPageSize: 50, batchQueries: 10, queryThrottle: 2500} + config = {...config, batchPageSize: 50, batchQueries: 10, queryThrottle: 2500} await new Promise(r => setTimeout(r, (Math.random() * 31) * 1000)); } @@ -154,7 +155,7 @@ export default function Autostake(mnemonic, opts) { network, operator, signingClient, - opts + config ) }