feat: optimize relay selection for replaceable event queries

This commit is contained in:
codytseng
2025-11-02 15:57:36 +08:00
parent a3f02df539
commit 6b22380d26

View File

@@ -1126,7 +1126,7 @@ class ClientService extends EventTarget {
} }
async forceUpdateRelayListEvent(pubkey: string) { async forceUpdateRelayListEvent(pubkey: string) {
await this.replaceableEventBatchLoadFn([{ pubkey, kind: kinds.RelayList }]) await this.replaceableEventFromBigRelaysBatchLoadFn([{ pubkey, kind: kinds.RelayList }])
} }
async updateRelayListCache(event: NEvent) { async updateRelayListCache(event: NEvent) {
@@ -1262,7 +1262,9 @@ class ClientService extends EventTarget {
} }
: { authors: [pubkey], kinds: [kind] }) as Filter : { authors: [pubkey], kinds: [kind] }) as Filter
) )
const events = await this.query(BIG_RELAY_URLS, filters) const relayList = await this.fetchRelayList(pubkey)
const relays = relayList.write.concat(BIG_RELAY_URLS).slice(0, 5)
const events = await this.query(relays, filters)
for (const event of events) { for (const event of events) {
const key = getReplaceableCoordinateFromEvent(event) const key = getReplaceableCoordinateFromEvent(event)