Make RelayPool actor a global actor

This allows us to use the same actor for related classes to help with
thread safety.

Changelog-None
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2026-01-22 12:20:51 -08:00
parent ed9971f84f
commit ac05b83772

View File

@@ -27,8 +27,15 @@ struct SeenEvent: Hashable {
let evid: NoteId let evid: NoteId
} }
@globalActor
actor RelayPoolActor {
static let shared = RelayPoolActor()
private init() {}
}
/// Establishes and manages connections and subscriptions to a list of relays. /// Establishes and manages connections and subscriptions to a list of relays.
actor RelayPool { @RelayPoolActor
class RelayPool {
@MainActor @MainActor
private(set) var relays: [Relay] = [] private(set) var relays: [Relay] = []
var open: Bool = false var open: Bool = false
@@ -72,7 +79,7 @@ actor RelayPool {
seen.removeAll() seen.removeAll()
} }
init(ndb: Ndb?, keypair: Keypair? = nil) { nonisolated init(ndb: Ndb?, keypair: Keypair? = nil) {
self.ndb = ndb self.ndb = ndb
self.keypair = keypair self.keypair = keypair