Speeds up the filter for NWC zap payments.

This commit is contained in:
Vitor Pamplona 2024-08-29 12:32:34 -04:00
parent 255f464046
commit 388ccdbe75
3 changed files with 12 additions and 3 deletions

View File

@ -1188,7 +1188,7 @@ class Account(
replyingToHex = event.id,
authSigner = signer,
)
wcListener.start()
wcListener.startSync()
LocalCache.consume(event, zappedNote) { it.response(signer) { onResponse(it) } }

View File

@ -1664,7 +1664,10 @@ object LocalCache {
@Suppress("UNUSED_PARAMETER")
fun consume(event: ChannelMuteUserEvent) {}
fun consume(event: LnZapEvent) {
fun consume(
event: LnZapEvent,
relay: Relay?,
) {
val note = getOrCreateNote(event.id)
// Already processed this event.
if (note.event != null) return
@ -2693,7 +2696,7 @@ object LocalCache {
event.zapRequest?.let {
// must have a valid request
verifyAndConsume(it, relay)
consume(event)
consume(event, relay)
}
}
is LnZapRequestEvent -> consume(event)

View File

@ -157,6 +157,12 @@ abstract class NostrDataSource(
resetFilters()
}
open fun startSync() {
Log.d("DataSource", "${this.javaClass.simpleName} Start")
active = true
resetFiltersSuspend()
}
@OptIn(DelicateCoroutinesApi::class)
open fun stop() {
active = false