@@ -23,7 +23,6 @@ interface ServerState {
2323
2424interface ServerStateConfig {
2525 engineEmitter : EngineEmitter
26- engineStarted : boolean
2726 log : EdgeLog
2827 pluginInfo : PluginInfo
2928 pluginState : PluginState
@@ -61,18 +60,11 @@ interface Connections {
6160}
6261
6362export function makeServerStates ( config : ServerStateConfig ) : ServerStates {
64- const {
65- engineEmitter,
66- engineStarted,
67- log,
68- pluginInfo,
69- pluginState,
70- walletInfo
71- } = config
63+ const { engineEmitter, log, pluginInfo, pluginState, walletInfo } = config
7264 log ( 'Making server states' )
7365
7466 let serverStates : ServerStateCache = { }
75-
67+ let isEngineOn : boolean = true
7668 let connections : Connections = { }
7769 let serverList : string [ ] = [ ]
7870 let reconnectCounter = 0
@@ -159,6 +151,7 @@ export function makeServerStates(config: ServerStateConfig): ServerStates {
159151 }
160152
161153 const stop = async ( ) : Promise < void > => {
154+ isEngineOn = false
162155 log ( `stopping server states` )
163156 removeIdFromQueue ( walletInfo . id )
164157 clearTimeout ( reconnectTimer )
@@ -172,13 +165,13 @@ export function makeServerStates(config: ServerStateConfig): ServerStates {
172165 }
173166
174167 const reconnect = ( ) : void => {
175- if ( engineStarted ) {
176- if ( reconnectCounter < 5 ) reconnectCounter ++
168+ if ( isEngineOn ) {
177169 log ( `attempting server reconnect number ${ reconnectCounter } ` )
170+ const reconnectionDelay = Math . max ( 5 , reconnectCounter ++ ) * 1000
178171 reconnectTimer = setTimeout ( ( ) => {
179172 clearTimeout ( reconnectTimer )
180173 refillServers ( )
181- } , reconnectCounter * 1000 )
174+ } , reconnectionDelay )
182175 }
183176 }
184177
0 commit comments