kopia lustrzana https://github.com/vitorpamplona/amethyst
refactoring of cache methods in GiftWraps
rodzic
e1c134830e
commit
7fd37367fc
|
@ -44,6 +44,13 @@ class GiftWrapEvent(
|
|||
return cachedInnerEvent[signer.pubKey]
|
||||
}
|
||||
|
||||
fun addToCache(
|
||||
pubKey: HexKey,
|
||||
gift: Event,
|
||||
) {
|
||||
cachedInnerEvent = cachedInnerEvent + Pair(pubKey, gift)
|
||||
}
|
||||
|
||||
fun cachedGift(
|
||||
signer: NostrSigner,
|
||||
onReady: (Event) -> Unit,
|
||||
|
@ -56,7 +63,7 @@ class GiftWrapEvent(
|
|||
if (gift is WrappedEvent) {
|
||||
gift.host = this
|
||||
}
|
||||
cachedInnerEvent = cachedInnerEvent + Pair(signer.pubKey, gift)
|
||||
addToCache(signer.pubKey, gift)
|
||||
|
||||
onReady(gift)
|
||||
}
|
||||
|
@ -98,8 +105,8 @@ class GiftWrapEvent(
|
|||
val serializedContent = toJson(event)
|
||||
val tags = arrayOf(arrayOf("p", recipientPubKey))
|
||||
|
||||
signer.nip44Encrypt(serializedContent, recipientPubKey) {
|
||||
signer.sign(createdAt, KIND, tags, it, onReady)
|
||||
signer.nip44Encrypt(serializedContent, recipientPubKey) { content ->
|
||||
signer.sign(createdAt, KIND, tags, content, onReady)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,13 @@ class SealedGossipEvent(
|
|||
return cachedInnerEvent[signer.pubKey]
|
||||
}
|
||||
|
||||
fun addToCache(
|
||||
pubKey: HexKey,
|
||||
gift: Event,
|
||||
) {
|
||||
cachedInnerEvent = cachedInnerEvent + Pair(pubKey, gift)
|
||||
}
|
||||
|
||||
fun cachedGossip(
|
||||
signer: NostrSigner,
|
||||
onReady: (Event) -> Unit,
|
||||
|
@ -59,8 +66,8 @@ class SealedGossipEvent(
|
|||
if (event is WrappedEvent) {
|
||||
event.host = host ?: this
|
||||
}
|
||||
addToCache(signer.pubKey, event)
|
||||
|
||||
cachedInnerEvent = cachedInnerEvent + Pair(signer.pubKey, event)
|
||||
onReady(event)
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue