mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 19:06:34 +02:00
Exposes active filters per relay on the Nostr Client for debugging purposes
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.quartz.nip01Core.relay.client
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.listeners.IRelayClientListener
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.listeners.RelayState
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.PoolEventOutboxRepository
|
||||
@@ -395,6 +396,12 @@ class NostrClient(
|
||||
listeners = listeners.minus(listener)
|
||||
}
|
||||
|
||||
fun activeRequests(url: NormalizedRelayUrl): Map<String, List<Filter>> = activeRequests.activeFiltersFor(url)
|
||||
|
||||
fun activeCounts(url: NormalizedRelayUrl): Map<String, List<Filter>> = activeCounts.activeFiltersFor(url)
|
||||
|
||||
fun activeOutboxCache(url: NormalizedRelayUrl): Set<HexKey> = eventOutbox.activeOutboxCacheFor(url)
|
||||
|
||||
fun getSubscriptionFiltersOrNull(subId: String): Map<NormalizedRelayUrl, List<Filter>>? = activeRequests.getSubscriptionFiltersOrNull(subId)
|
||||
|
||||
fun relayStatusFlow() = relayPool.statusFlow
|
||||
|
@@ -40,6 +40,16 @@ class PoolEventOutboxRepository {
|
||||
}
|
||||
}
|
||||
|
||||
fun activeOutboxCacheFor(url: NormalizedRelayUrl): Set<HexKey> {
|
||||
val myEvents = mutableSetOf<HexKey>()
|
||||
eventOutbox.forEach { eventId, outboxCache ->
|
||||
if (url in outboxCache.relays) {
|
||||
myEvents.add(eventId)
|
||||
}
|
||||
}
|
||||
return myEvents
|
||||
}
|
||||
|
||||
fun markAsSending(
|
||||
event: Event,
|
||||
relays: Set<NormalizedRelayUrl>,
|
||||
|
@@ -40,6 +40,17 @@ class PoolSubscriptionRepository {
|
||||
}
|
||||
}
|
||||
|
||||
fun activeFiltersFor(url: NormalizedRelayUrl): Map<String, List<Filter>> {
|
||||
val myRelays = mutableMapOf<String, List<Filter>>()
|
||||
subscriptions.forEach { sub, perRelayFilters ->
|
||||
val filters = perRelayFilters.get(url)
|
||||
if (filters != null) {
|
||||
myRelays.put(sub, filters)
|
||||
}
|
||||
}
|
||||
return myRelays
|
||||
}
|
||||
|
||||
fun addOrUpdate(
|
||||
subscriptionId: String,
|
||||
filters: Map<NormalizedRelayUrl, List<Filter>>,
|
||||
|
Reference in New Issue
Block a user