vault creation loop bugfix

This commit is contained in:
Tim Olson
2023-12-28 18:26:58 -04:00
parent a8de41af12
commit 9c882ab283
3 changed files with 13 additions and 9 deletions

View File

@@ -167,7 +167,7 @@ async function doEnsureVault(chainId, owner, num) {
console.log(`requesting vault ${owner} ${num}`)
socket.emit('ensureVault', chainId, owner, num)
}
await sleep(5)
// await sleep(5000) // prevent this process from running more than once every 5 seconds
}
const ensureVaultRoutine = new SingletonCoroutine(doEnsureVault, 100, false)

View File

@@ -16,8 +16,8 @@ export class SingletonCoroutine {
invoke(/*arguments*/) {
this.args = arguments
if( this.timeout !== null )
clearTimeout(this.timeout)
console.log('invoke', arguments)
if( this.timeout === null )
this.timeout = setTimeout(this.onTimeout, this.delay, this)
}
@@ -26,8 +26,10 @@ export class SingletonCoroutine {
await self.f(...self.args)
}
catch (e) {
if( self.retry )
if( self.retry ) {
console.log('retrying', this.f, 'due to error', e)
self.invoke(self.args)
}
else
console.error(e)
}

View File

@@ -48,11 +48,13 @@ socket.on('vaults', (chainId, owner, vaults)=>{
console.log('vaults', vaults)
if( s.chainId.value !== chainId || s.account !== owner )
return
if( vaults.length > s.vaults.length ) {
s.vaults = vaults
if( vaults.length ) {
const vault = vaults[0]
flushOrders(vault)
}
}
})