chainInfo from server, routes, wallet rework

This commit is contained in:
Tim Olson
2023-10-04 03:40:47 -04:00
parent e7a9600c54
commit 7239987867
26 changed files with 603 additions and 297 deletions

35
src/misc.js Normal file
View File

@@ -0,0 +1,35 @@
export class SingletonCoroutine {
constructor(f, delay=10, retry=true) {
this.f = f
this.delay = delay
this.timeout = null
this.args = null
}
pending() {
return this.timeout !== null
}
invoke(/*arguments*/) {
this.args = arguments
if( this.timeout !== null )
clearTimeout(this.timeout)
this.timeout = setTimeout(this.onTimeout, this.delay, this)
}
async onTimeout(self) {
self.timeout = null
console.log('invoking', self.f, self.args)
try {
await self.f(...self.args)
}
catch (e) {
if( self.retry )
self.invoke(self.args)
else
console.error(e)
}
}
}