feat: implemented relay controller and use that for fetching and publishing events #149

Merged
s merged 10 commits from relay-controller into staging 2024-08-20 12:13:23 +00:00
Showing only changes of commit 2f1423a35a - Show all commits

View File

@ -121,7 +121,7 @@ export class RelayController {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
if (!relay.connected) { if (!relay.connected) {
console.log(`${relay.url} : Not connected!`, 'Skipping subscription') console.log(`${relay.url} : Not connected!`, 'Skipping subscription')
return return resolve()
} }
// Subscribe to the relay with the specified filter // Subscribe to the relay with the specified filter
@ -140,6 +140,14 @@ export class RelayController {
resolve() // Resolve the promise when EOSE is received resolve() // Resolve the promise when EOSE is received
} }
}) })
// add a 30 sec of timeout to subscription
setTimeout(() => {
if (!sub.closed) {
sub.close()
resolve()
}
}, 30 * 1000)
}) })
}) })