Renames Gossip to Rumor to match names on the NIP-59

This commit is contained in:
Vitor Pamplona 2025-01-15 08:58:08 -05:00
parent d1c64a0d15
commit f3b049382e
17 changed files with 152 additions and 152 deletions

View File

@ -121,7 +121,7 @@ import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.nip59Giftwrap.WrappedEvent import com.vitorpamplona.quartz.nip59Giftwrap.WrappedEvent
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter
@ -3205,9 +3205,9 @@ class Account(
mine.forEach { giftWrap -> mine.forEach { giftWrap ->
giftWrap.unwrap(signer) { gift -> giftWrap.unwrap(signer) { gift ->
if (gift is SealedGossipEvent) { if (gift is SealedRumorEvent) {
gift.unseal(signer) { gossip -> gift.unseal(signer) { rumor ->
LocalCache.justConsume(gossip, null) LocalCache.justConsume(rumor, null)
} }
} }
@ -3742,7 +3742,7 @@ class Account(
} }
fun unseal( fun unseal(
event: SealedGossipEvent, event: SealedRumorEvent,
onReady: (Event) -> Unit, onReady: (Event) -> Unit,
) { ) {
if (!isWriteable()) return if (!isWriteable()) return

View File

@ -123,7 +123,7 @@ import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent
import com.vitorpamplona.quartz.nip58Badges.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip58Badges.BadgeDefinitionEvent
import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.nip59Giftwrap.WrappedEvent import com.vitorpamplona.quartz.nip59Giftwrap.WrappedEvent
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent
@ -1705,7 +1705,7 @@ object LocalCache {
} }
fun consume( fun consume(
event: SealedGossipEvent, event: SealedRumorEvent,
relay: Relay?, relay: Relay?,
) { ) {
val note = getOrCreateNote(event.id) val note = getOrCreateNote(event.id)
@ -2562,7 +2562,7 @@ object LocalCache {
event.containedPost()?.let { verifyAndConsume(it, relay) } event.containedPost()?.let { verifyAndConsume(it, relay) }
consume(event) consume(event)
} }
is SealedGossipEvent -> consume(event, relay) is SealedRumorEvent -> consume(event, relay)
is SearchRelayListEvent -> consume(event, relay) is SearchRelayListEvent -> consume(event, relay)
is StatusEvent -> consume(event, relay) is StatusEvent -> consume(event, relay)
is TextNoteEvent -> consume(event, relay) is TextNoteEvent -> consume(event, relay)

View File

@ -65,7 +65,7 @@ import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent
import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent
import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent
@ -368,10 +368,10 @@ object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
} }
} }
is SealedGossipEvent -> { is SealedRumorEvent -> {
// Avoid decrypting over and over again if the event already exist. // Avoid decrypting over and over again if the event already exist.
val note = LocalCache.getNoteIfExists(event.id) val note = LocalCache.getNoteIfExists(event.id)
val noteEvent = note?.event as? SealedGossipEvent val noteEvent = note?.event as? SealedRumorEvent
if (noteEvent != null) { if (noteEvent != null) {
if (relay.brief !in note.relays) { if (relay.brief !in note.relays) {
LocalCache.justConsume(noteEvent, relay) LocalCache.justConsume(noteEvent, relay)
@ -450,7 +450,7 @@ object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
noteEvent.innerEventId?.let { noteEvent.innerEventId?.let {
markInnerAsSeenOnRelay(it, relay) markInnerAsSeenOnRelay(it, relay)
} }
} else if (noteEvent is SealedGossipEvent) { } else if (noteEvent is SealedRumorEvent) {
noteEvent.innerEventId?.let { noteEvent.innerEventId?.let {
markInnerAsSeenOnRelay(it, relay) markInnerAsSeenOnRelay(it, relay)
} }

View File

@ -48,7 +48,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.NostrSignerExternal
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.utils.TimeUtils import com.vitorpamplona.quartz.utils.TimeUtils
import java.math.BigDecimal import java.math.BigDecimal
import kotlin.coroutines.cancellation.CancellationException import kotlin.coroutines.cancellation.CancellationException
@ -184,7 +184,7 @@ class EventNotificationConsumer(
LocalCache.justConsume(event, null) LocalCache.justConsume(event, null)
} }
} }
is SealedGossipEvent -> { is SealedRumorEvent -> {
event.unseal(signer) { event.unseal(signer) {
if (!LocalCache.hasConsumed(it)) { if (!LocalCache.hasConsumed(it)) {
// this is not verifiable // this is not verifiable

View File

@ -104,7 +104,7 @@ import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent
import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiserAmount import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiserAmount
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter
import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryResponseEvent import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryResponseEvent
@ -958,7 +958,7 @@ class AccountViewModel(
} }
fun unseal( fun unseal(
event: SealedGossipEvent, event: SealedRumorEvent,
onReady: (Event) -> Unit, onReady: (Event) -> Unit,
) { ) {
account.unseal(event, onReady) account.unseal(event, onReady)
@ -1456,7 +1456,7 @@ class AccountViewModel(
} }
} }
} }
is SealedGossipEvent -> { is SealedRumorEvent -> {
event.innerEventId?.let { event.innerEventId?.let {
val existingNote = LocalCache.getNoteIfExists(it) val existingNote = LocalCache.getNoteIfExists(it)
if (existingNote != null) { if (existingNote != null) {

View File

@ -52,7 +52,7 @@ import com.vitorpamplona.quartz.nip28PublicChat.ChannelMetadataEvent
import com.vitorpamplona.quartz.nip53LiveActivities.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.LiveActivitiesChatMessageEvent
import com.vitorpamplona.quartz.nip53LiveActivities.LiveActivitiesEvent import com.vitorpamplona.quartz.nip53LiveActivities.LiveActivitiesEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -149,7 +149,7 @@ fun redirect(
} ?: run { } ?: run {
accountViewModel.unwrap(event) { redirect(it, accountViewModel, nav) } accountViewModel.unwrap(event) { redirect(it, accountViewModel, nav) }
} }
} else if (event is SealedGossipEvent) { } else if (event is SealedRumorEvent) {
event.innerEventId?.let { event.innerEventId?.let {
redirect(it, accountViewModel, nav) redirect(it, accountViewModel, nav)
} ?: run { } ?: run {

View File

@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import com.vitorpamplona.quartz.nip17Dm.NIP17Factory
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import junit.framework.TestCase import junit.framework.TestCase
import org.junit.Assert import org.junit.Assert
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
@ -89,8 +89,8 @@ class GiftWrapBenchmark {
it.cachedGift(keyToUse) { event -> it.cachedGift(keyToUse) { event ->
event.checkSignature() event.checkSignature()
if (event is SealedGossipEvent) { if (event is SealedRumorEvent) {
event.cachedGossip(keyToUse) { innerData -> event.cachedRumor(keyToUse) { innerData ->
Assert.assertEquals(message, innerData.content) Assert.assertEquals(message, innerData.content)
countDownLatch2.countDown() countDownLatch2.countDown()
} }
@ -135,8 +135,8 @@ class GiftWrapBenchmark {
wrap.cachedGift(keyToUse) { seal -> wrap.cachedGift(keyToUse) { seal ->
seal.checkSignature() seal.checkSignature()
if (seal is SealedGossipEvent) { if (seal is SealedRumorEvent) {
seal.cachedGossip(keyToUse) { innerData -> seal.cachedRumor(keyToUse) { innerData ->
Assert.assertEquals(message, innerData.content) Assert.assertEquals(message, innerData.content)
counter.countDown() counter.countDown()
} }

View File

@ -33,8 +33,8 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.Gossip import com.vitorpamplona.quartz.nip59Giftwrap.Rumor
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import junit.framework.TestCase.assertNotNull import junit.framework.TestCase.assertNotNull
import junit.framework.TestCase.assertTrue import junit.framework.TestCase.assertTrue
import org.junit.Rule import org.junit.Rule
@ -73,7 +73,7 @@ class GiftWrapReceivingBenchmark {
isDraft = true, isDraft = true,
signer = sender, signer = sender,
) { ) {
SealedGossipEvent.create( SealedRumorEvent.create(
event = it, event = it,
encryptTo = receiver.pubKey, encryptTo = receiver.pubKey,
signer = sender, signer = sender,
@ -96,9 +96,9 @@ class GiftWrapReceivingBenchmark {
fun createSeal( fun createSeal(
sender: NostrSigner, sender: NostrSigner,
receiver: NostrSigner, receiver: NostrSigner,
): SealedGossipEvent { ): SealedRumorEvent {
val countDownLatch = CountDownLatch(1) val countDownLatch = CountDownLatch(1)
var seal: SealedGossipEvent? = null var seal: SealedRumorEvent? = null
ChatMessageEvent.create( ChatMessageEvent.create(
msg = "Hi there! This is a test message", msg = "Hi there! This is a test message",
@ -113,7 +113,7 @@ class GiftWrapReceivingBenchmark {
isDraft = true, isDraft = true,
signer = sender, signer = sender,
) { ) {
SealedGossipEvent.create( SealedRumorEvent.create(
event = it, event = it,
encryptTo = receiver.pubKey, encryptTo = receiver.pubKey,
signer = sender, signer = sender,
@ -225,6 +225,6 @@ class GiftWrapReceivingBenchmark {
seal.pubKey.hexToByteArray(), seal.pubKey.hexToByteArray(),
) )
benchmarkRule.measureRepeated { assertNotNull(innerJson?.let { Gossip.fromJson(it) }) } benchmarkRule.measureRepeated { assertNotNull(innerJson?.let { Rumor.fromJson(it) }) }
} }
} }

View File

@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.KeyPair
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import junit.framework.TestCase.assertTrue import junit.framework.TestCase.assertTrue
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
@ -103,7 +103,7 @@ class GiftWrapSigningBenchmark {
benchmarkRule.measureRepeated { benchmarkRule.measureRepeated {
val countDownLatch2 = CountDownLatch(1) val countDownLatch2 = CountDownLatch(1)
SealedGossipEvent.create( SealedRumorEvent.create(
event = msg!!, event = msg!!,
encryptTo = receiver.pubKey, encryptTo = receiver.pubKey,
signer = sender, signer = sender,
@ -122,7 +122,7 @@ class GiftWrapSigningBenchmark {
val countDownLatch = CountDownLatch(1) val countDownLatch = CountDownLatch(1)
var seal: SealedGossipEvent? = null var seal: SealedRumorEvent? = null
ChatMessageEvent.create( ChatMessageEvent.create(
msg = "Hi there! This is a test message", msg = "Hi there! This is a test message",
@ -137,7 +137,7 @@ class GiftWrapSigningBenchmark {
isDraft = false, isDraft = false,
signer = sender, signer = sender,
) { ) {
SealedGossipEvent.create( SealedRumorEvent.create(
event = it, event = it,
encryptTo = receiver.pubKey, encryptTo = receiver.pubKey,
signer = sender, signer = sender,
@ -183,7 +183,7 @@ class GiftWrapSigningBenchmark {
isDraft = false, isDraft = false,
signer = sender, signer = sender,
) { ) {
SealedGossipEvent.create( SealedRumorEvent.create(
event = it, event = it,
encryptTo = receiver.pubKey, encryptTo = receiver.pubKey,
signer = sender, signer = sender,

View File

@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import com.vitorpamplona.quartz.nip17Dm.NIP17Factory
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.utils.Hex import com.vitorpamplona.quartz.utils.Hex
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals import org.junit.Assert.assertNotEquals
@ -65,8 +65,8 @@ class GiftWrapEventTest {
val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) } val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) }
eventsReceiverGets.forEach { eventsReceiverGets.forEach {
it.cachedGift(receiver) { event -> it.cachedGift(receiver) { event ->
if (event is SealedGossipEvent) { if (event is SealedRumorEvent) {
event.cachedGossip(receiver) { innerData -> event.cachedRumor(receiver) { innerData ->
countDownLatch.countDown() countDownLatch.countDown()
assertEquals(message, innerData.content) assertEquals(message, innerData.content)
} }
@ -80,8 +80,8 @@ class GiftWrapEventTest {
val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) } val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) }
eventsSenderGets.forEach { eventsSenderGets.forEach {
it.cachedGift(sender) { event -> it.cachedGift(sender) { event ->
if (event is SealedGossipEvent) { if (event is SealedRumorEvent) {
event.cachedGossip(sender) { innerData -> event.cachedRumor(sender) { innerData ->
countDownLatch.countDown() countDownLatch.countDown()
assertEquals(message, innerData.content) assertEquals(message, innerData.content)
} }
@ -126,8 +126,8 @@ class GiftWrapEventTest {
val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) } val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) }
eventsReceiverGets.forEach { eventsReceiverGets.forEach {
it.cachedGift(receiver) { event -> it.cachedGift(receiver) { event ->
if (event is SealedGossipEvent) { if (event is SealedRumorEvent) {
event.cachedGossip(receiver) { innerData -> event.cachedRumor(receiver) { innerData ->
countDownLatch.countDown() countDownLatch.countDown()
assertEquals(message, innerData.content) assertEquals(message, innerData.content)
} }
@ -142,8 +142,8 @@ class GiftWrapEventTest {
val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) } val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) }
eventsSenderGets.forEach { eventsSenderGets.forEach {
it.cachedGift(sender) { event -> it.cachedGift(sender) { event ->
if (event is SealedGossipEvent) { if (event is SealedRumorEvent) {
event.cachedGossip(sender) { innerData -> event.cachedRumor(sender) { innerData ->
countDownLatch.countDown() countDownLatch.countDown()
assertEquals(message, innerData.content) assertEquals(message, innerData.content)
} }
@ -175,7 +175,7 @@ class GiftWrapEventTest {
) { senderMessage -> ) { senderMessage ->
// MsgFor the Receiver // MsgFor the Receiver
SealedGossipEvent.create( SealedRumorEvent.create(
event = senderMessage, event = senderMessage,
encryptTo = receiver.pubKey, encryptTo = receiver.pubKey,
signer = sender, signer = sender,
@ -206,7 +206,7 @@ class GiftWrapEventTest {
} }
// MsgFor the Sender // MsgFor the Sender
SealedGossipEvent.create( SealedRumorEvent.create(
event = senderMessage, event = senderMessage,
encryptTo = sender.pubKey, encryptTo = sender.pubKey,
signer = sender, signer = sender,
@ -248,16 +248,16 @@ class GiftWrapEventTest {
val countDownDecryptLatch = CountDownLatch(2) val countDownDecryptLatch = CountDownLatch(2)
giftWrapEventToSender!!.cachedGift(sender) { unwrappedMsgForSenderBySender -> giftWrapEventToSender!!.cachedGift(sender) { unwrappedMsgForSenderBySender ->
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForSenderBySender.kind) assertEquals(SealedRumorEvent.KIND, unwrappedMsgForSenderBySender.kind)
assertTrue(unwrappedMsgForSenderBySender is SealedGossipEvent) assertTrue(unwrappedMsgForSenderBySender is SealedRumorEvent)
if (unwrappedMsgForSenderBySender is SealedGossipEvent) { if (unwrappedMsgForSenderBySender is SealedRumorEvent) {
unwrappedMsgForSenderBySender.cachedGossip(sender) { unwrappedGossipToSenderBySender -> unwrappedMsgForSenderBySender.cachedRumor(sender) { unwrappedRumorToSenderBySender ->
assertEquals("Hi There!", unwrappedGossipToSenderBySender.content) assertEquals("Hi There!", unwrappedRumorToSenderBySender.content)
countDownDecryptLatch.countDown() countDownDecryptLatch.countDown()
} }
unwrappedMsgForSenderBySender.cachedGossip(receiver) { _ -> unwrappedMsgForSenderBySender.cachedRumor(receiver) { _ ->
fail( fail(
"Should not be able to decrypt msg for the sender by the sender but decrypted with receiver", "Should not be able to decrypt msg for the sender by the sender but decrypted with receiver",
) )
@ -274,16 +274,16 @@ class GiftWrapEventTest {
} }
giftWrapEventToReceiver!!.cachedGift(receiver) { unwrappedMsgForReceiverByReceiver -> giftWrapEventToReceiver!!.cachedGift(receiver) { unwrappedMsgForReceiverByReceiver ->
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForReceiverByReceiver.kind) assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverByReceiver.kind)
assertTrue(unwrappedMsgForReceiverByReceiver is SealedGossipEvent) assertTrue(unwrappedMsgForReceiverByReceiver is SealedRumorEvent)
if (unwrappedMsgForReceiverByReceiver is SealedGossipEvent) { if (unwrappedMsgForReceiverByReceiver is SealedRumorEvent) {
unwrappedMsgForReceiverByReceiver.cachedGossip(receiver) { unwrappedGossipToReceiverByReceiver -> unwrappedMsgForReceiverByReceiver.cachedRumor(receiver) { unwrappedRumorToReceiverByReceiver ->
assertEquals("Hi There!", unwrappedGossipToReceiverByReceiver?.content) assertEquals("Hi There!", unwrappedRumorToReceiverByReceiver?.content)
countDownDecryptLatch.countDown() countDownDecryptLatch.countDown()
} }
unwrappedMsgForReceiverByReceiver.cachedGossip(sender) { unwrappedGossipToReceiverBySender -> unwrappedMsgForReceiverByReceiver.cachedRumor(sender) { unwrappedRumorToReceiverBySender ->
fail( fail(
"Should not be able to decrypt msg for the receiver by the receiver but decrypted with the sender", "Should not be able to decrypt msg for the receiver by the receiver but decrypted with the sender",
) )
@ -312,7 +312,7 @@ class GiftWrapEventTest {
to = listOf(receiverA.pubKey, receiverB.pubKey), to = listOf(receiverA.pubKey, receiverB.pubKey),
signer = sender, signer = sender,
) { senderMessage -> ) { senderMessage ->
SealedGossipEvent.create( SealedRumorEvent.create(
event = senderMessage, event = senderMessage,
encryptTo = receiverA.pubKey, encryptTo = receiverA.pubKey,
signer = sender, signer = sender,
@ -343,7 +343,7 @@ class GiftWrapEventTest {
} }
} }
SealedGossipEvent.create( SealedRumorEvent.create(
event = senderMessage, event = senderMessage,
encryptTo = receiverB.pubKey, encryptTo = receiverB.pubKey,
signer = sender, signer = sender,
@ -374,7 +374,7 @@ class GiftWrapEventTest {
} }
} }
SealedGossipEvent.create( SealedRumorEvent.create(
event = senderMessage, event = senderMessage,
encryptTo = sender.pubKey, encryptTo = sender.pubKey,
signer = sender, signer = sender,
@ -419,21 +419,21 @@ class GiftWrapEventTest {
val countDownDecryptLatch = CountDownLatch(3) val countDownDecryptLatch = CountDownLatch(3)
giftWrapEventToSender?.cachedGift(sender) { unwrappedMsgForSenderBySender -> giftWrapEventToSender?.cachedGift(sender) { unwrappedMsgForSenderBySender ->
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForSenderBySender.kind) assertEquals(SealedRumorEvent.KIND, unwrappedMsgForSenderBySender.kind)
if (unwrappedMsgForSenderBySender is SealedGossipEvent) { if (unwrappedMsgForSenderBySender is SealedRumorEvent) {
unwrappedMsgForSenderBySender.cachedGossip(receiverA) { unwrappedGossipToSenderByReceiverA -> unwrappedMsgForSenderBySender.cachedRumor(receiverA) { unwrappedRumorToSenderByReceiverA ->
fail() fail()
} }
unwrappedMsgForSenderBySender.cachedGossip(receiverB) { unwrappedGossipToSenderByReceiverB -> unwrappedMsgForSenderBySender.cachedRumor(receiverB) { unwrappedRumorToSenderByReceiverB ->
fail() fail()
} }
unwrappedMsgForSenderBySender.cachedGossip(sender) { unwrappedGossipToSenderBySender -> unwrappedMsgForSenderBySender.cachedRumor(sender) { unwrappedRumorToSenderBySender ->
assertEquals( assertEquals(
"Who is going to the party tonight?", "Who is going to the party tonight?",
unwrappedGossipToSenderBySender.content, unwrappedRumorToSenderBySender.content,
) )
} }
} }
@ -454,21 +454,21 @@ class GiftWrapEventTest {
} }
giftWrapEventToReceiverA!!.cachedGift(receiverA) { unwrappedMsgForReceiverAByReceiverA -> giftWrapEventToReceiverA!!.cachedGift(receiverA) { unwrappedMsgForReceiverAByReceiverA ->
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForReceiverAByReceiverA.kind) assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverAByReceiverA.kind)
if (unwrappedMsgForReceiverAByReceiverA is SealedGossipEvent) { if (unwrappedMsgForReceiverAByReceiverA is SealedRumorEvent) {
unwrappedMsgForReceiverAByReceiverA.cachedGossip(receiverA) { unwrappedGossipToReceiverAByReceiverA -> unwrappedMsgForReceiverAByReceiverA.cachedRumor(receiverA) { unwrappedRumorToReceiverAByReceiverA ->
assertEquals( assertEquals(
"Who is going to the party tonight?", "Who is going to the party tonight?",
unwrappedGossipToReceiverAByReceiverA.content, unwrappedRumorToReceiverAByReceiverA.content,
) )
} }
unwrappedMsgForReceiverAByReceiverA.cachedGossip(sender) { unwrappedGossipToReceiverABySender -> unwrappedMsgForReceiverAByReceiverA.cachedRumor(sender) { unwrappedRumorToReceiverABySender ->
fail() fail()
} }
unwrappedMsgForReceiverAByReceiverA.cachedGossip(receiverB) { unwrappedGossipToReceiverAByReceiverB -> unwrappedMsgForReceiverAByReceiverA.cachedRumor(receiverB) { unwrappedRumorToReceiverAByReceiverB ->
fail() fail()
} }
} }
@ -487,23 +487,23 @@ class GiftWrapEventTest {
fail("Should not be able to decode msg to receiver A with the receiver B's key") fail("Should not be able to decode msg to receiver A with the receiver B's key")
} }
giftWrapEventToReceiverB!!.cachedGift(receiverB) { unwrappedMsgForReceiverBByReceiverB -> giftWrapEventToReceiverB!!.cachedGift(receiverB) { unwrappedMsgForReceiverBByReceiverB ->
assertEquals(SealedGossipEvent.KIND, unwrappedMsgForReceiverBByReceiverB.kind) assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverBByReceiverB.kind)
if (unwrappedMsgForReceiverBByReceiverB is SealedGossipEvent) { if (unwrappedMsgForReceiverBByReceiverB is SealedRumorEvent) {
unwrappedMsgForReceiverBByReceiverB.cachedGossip(receiverA) { unwrappedGossipToReceiverBByReceiverA -> unwrappedMsgForReceiverBByReceiverB.cachedRumor(receiverA) { unwrappedRumorToReceiverBByReceiverA ->
fail() fail()
} }
unwrappedMsgForReceiverBByReceiverB.cachedGossip(receiverB) { unwrappedGossipToReceiverBByReceiverB -> unwrappedMsgForReceiverBByReceiverB.cachedRumor(receiverB) { unwrappedRumorToReceiverBByReceiverB ->
assertEquals( assertEquals(
"Who is going to the party tonight?", "Who is going to the party tonight?",
unwrappedGossipToReceiverBByReceiverB.content, unwrappedRumorToReceiverBByReceiverB.content,
) )
countDownDecryptLatch.countDown() countDownDecryptLatch.countDown()
} }
unwrappedMsgForReceiverBByReceiverB.cachedGossip(sender) { unwrappedGossipToReceiverBBySender -> unwrappedMsgForReceiverBByReceiverB.cachedRumor(sender) { unwrappedRumorToReceiverBBySender ->
fail() fail()
} }
} }
@ -532,18 +532,18 @@ class GiftWrapEventTest {
} }
""".trimIndent() """.trimIndent()
var gossip: Event? = null var rumor: Event? = null
wait1SecondForResult { onDone -> wait1SecondForResult { onDone ->
val privateKey = "de6152a85a0dea3b09a08a6f8139a314d498a7b52f7e5c28858b64270abd4c70" val privateKey = "de6152a85a0dea3b09a08a6f8139a314d498a7b52f7e5c28858b64270abd4c70"
unwrapUnsealGossip(json, privateKey) { unwrapUnsealRumor(json, privateKey) {
gossip = it rumor = it
onDone() onDone()
} }
} }
assertNotNull(gossip) assertNotNull(rumor)
assertEquals("Hola, que tal?", gossip?.content) assertEquals("Hola, que tal?", rumor?.content)
} }
@Test @Test
@ -568,17 +568,17 @@ class GiftWrapEventTest {
val privateKey = "409ff7654141eaa16cd2161fe5bd127aeaef71f270c67587474b78998a8e3533" val privateKey = "409ff7654141eaa16cd2161fe5bd127aeaef71f270c67587474b78998a8e3533"
var gossip: Event? = null var rumor: Event? = null
wait1SecondForResult { onDone -> wait1SecondForResult { onDone ->
unwrapUnsealGossip(json, privateKey) { unwrapUnsealRumor(json, privateKey) {
gossip = it rumor = it
onDone() onDone()
} }
} }
assertNotNull(gossip) assertNotNull(rumor)
assertEquals("Hola, que tal?", gossip?.content) assertEquals("Hola, que tal?", rumor?.content)
} }
@Test @Test
@ -605,17 +605,17 @@ class GiftWrapEventTest {
""".trimIndent() """.trimIndent()
val privateKey = "09e0051fdf5fdd9dd7a54713583006442cbdbf87bdcdab1a402f26e527d56771" val privateKey = "09e0051fdf5fdd9dd7a54713583006442cbdbf87bdcdab1a402f26e527d56771"
var gossip: Event? = null var rumor: Event? = null
wait1SecondForResult { onDone -> wait1SecondForResult { onDone ->
unwrapUnsealGossip(json, privateKey) { unwrapUnsealRumor(json, privateKey) {
gossip = it rumor = it
onDone() onDone()
} }
} }
assertNotNull(gossip) assertNotNull(rumor)
assertEquals("test", gossip?.content) assertEquals("test", rumor?.content)
} }
@Test @Test
@ -640,21 +640,21 @@ class GiftWrapEventTest {
val privateKey = "09e0051fdf5fdd9dd7a54713583006442cbdbf87bdcdab1a402f26e527d56771" val privateKey = "09e0051fdf5fdd9dd7a54713583006442cbdbf87bdcdab1a402f26e527d56771"
var gossip: Event? = null var rumor: Event? = null
wait1SecondForResult { onDone -> wait1SecondForResult { onDone ->
unwrapUnsealGossip(json, privateKey) { unwrapUnsealRumor(json, privateKey) {
gossip = it rumor = it
onDone() onDone()
} }
} }
assertEquals("asdfasdfasdf", gossip?.content) assertEquals("asdfasdfasdf", rumor?.content)
assertEquals(1690659269L, gossip?.createdAt) assertEquals(1690659269L, rumor?.createdAt)
assertEquals("827ba09d32ab81d62c60f657b350198c8aaba84372dab9ad3f4f6b8b7274b707", gossip?.id) assertEquals("827ba09d32ab81d62c60f657b350198c8aaba84372dab9ad3f4f6b8b7274b707", rumor?.id)
assertEquals(14, gossip?.kind) assertEquals(14, rumor?.kind)
assertEquals("subject", gossip?.tags?.firstOrNull()?.get(0)) assertEquals("subject", rumor?.tags?.firstOrNull()?.get(0))
assertEquals("test", gossip?.tags?.firstOrNull()?.get(1)) assertEquals("test", rumor?.tags?.firstOrNull()?.get(1))
} }
@Test @Test
@ -679,29 +679,29 @@ class GiftWrapEventTest {
val privateKey = "7dd22cafc512c0bc363a259f6dcda515b13ae3351066d7976fd0bb79cbd0d700" val privateKey = "7dd22cafc512c0bc363a259f6dcda515b13ae3351066d7976fd0bb79cbd0d700"
var gossip: Event? = null var rumor: Event? = null
wait1SecondForResult { onDone -> wait1SecondForResult { onDone ->
unwrapUnsealGossip(json, privateKey) { unwrapUnsealRumor(json, privateKey) {
gossip = it rumor = it
onDone() onDone()
} }
} }
assertEquals("8d1a56008d4e31dae2fb8bef36b3efea519eff75f57033107e2aa16702466ef2", gossip?.id) assertEquals("8d1a56008d4e31dae2fb8bef36b3efea519eff75f57033107e2aa16702466ef2", rumor?.id)
assertEquals("Howdy", gossip?.content) assertEquals("Howdy", rumor?.content)
assertEquals(1690833960L, gossip?.createdAt) assertEquals(1690833960L, rumor?.createdAt)
assertEquals(14, gossip?.kind) assertEquals(14, rumor?.kind)
assertEquals("p", gossip?.tags?.firstOrNull()?.get(0)) assertEquals("p", rumor?.tags?.firstOrNull()?.get(0))
assertEquals( assertEquals(
"b08d8857a92b4d6aa580ff55cc3c18c4edf313c83388c34abc118621f74f1a78", "b08d8857a92b4d6aa580ff55cc3c18c4edf313c83388c34abc118621f74f1a78",
gossip?.tags?.firstOrNull()?.get(1), rumor?.tags?.firstOrNull()?.get(1),
) )
assertEquals("subject", gossip?.tags?.getOrNull(1)?.get(0)) assertEquals("subject", rumor?.tags?.getOrNull(1)?.get(0))
assertEquals("Stuff", gossip?.tags?.getOrNull(1)?.get(1)) assertEquals("Stuff", rumor?.tags?.getOrNull(1)?.get(1))
} }
fun unwrapUnsealGossip( fun unwrapUnsealRumor(
json: String, json: String,
privateKey: HexKey, privateKey: HexKey,
onReady: (Event) -> Unit, onReady: (Event) -> Unit,
@ -714,11 +714,11 @@ class GiftWrapEventTest {
assertEquals(pkBytes.pubKey, wrap.recipientPubKey()) assertEquals(pkBytes.pubKey, wrap.recipientPubKey())
wrap.cachedGift(pkBytes) { event -> wrap.cachedGift(pkBytes) { event ->
if (event is SealedGossipEvent) { if (event is SealedRumorEvent) {
event.cachedGossip(pkBytes, onReady) event.cachedRumor(pkBytes, onReady)
} else { } else {
println(event.toJson()) println(event.toJson())
fail("Event is not a Sealed Gossip") fail("Event is not a Sealed Rumor")
} }
} }
} }

View File

@ -93,7 +93,7 @@ import com.vitorpamplona.quartz.nip58Badges.BadgeAwardEvent
import com.vitorpamplona.quartz.nip58Badges.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip58Badges.BadgeDefinitionEvent
import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent import com.vitorpamplona.quartz.nip58Badges.BadgeProfilesEvent
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent
import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent
@ -242,7 +242,7 @@ class EventFactory {
RelaySetEvent.KIND -> RelaySetEvent(id, pubKey, createdAt, tags, content, sig) RelaySetEvent.KIND -> RelaySetEvent(id, pubKey, createdAt, tags, content, sig)
ReportEvent.KIND -> ReportEvent(id, pubKey, createdAt, tags, content, sig) ReportEvent.KIND -> ReportEvent(id, pubKey, createdAt, tags, content, sig)
RepostEvent.KIND -> RepostEvent(id, pubKey, createdAt, tags, content, sig) RepostEvent.KIND -> RepostEvent(id, pubKey, createdAt, tags, content, sig)
SealedGossipEvent.KIND -> SealedGossipEvent(id, pubKey, createdAt, tags, content, sig) SealedRumorEvent.KIND -> SealedRumorEvent(id, pubKey, createdAt, tags, content, sig)
SearchRelayListEvent.KIND -> SearchRelayListEvent(id, pubKey, createdAt, tags, content, sig) SearchRelayListEvent.KIND -> SearchRelayListEvent(id, pubKey, createdAt, tags, content, sig)
StatusEvent.KIND -> StatusEvent(id, pubKey, createdAt, tags, content, sig) StatusEvent.KIND -> StatusEvent(id, pubKey, createdAt, tags, content, sig)
TextNoteEvent.KIND -> TextNoteEvent(id, pubKey, createdAt, tags, content, sig) TextNoteEvent.KIND -> TextNoteEvent(id, pubKey, createdAt, tags, content, sig)

View File

@ -35,9 +35,9 @@ import com.vitorpamplona.quartz.nip47WalletConnect.Request
import com.vitorpamplona.quartz.nip47WalletConnect.RequestDeserializer import com.vitorpamplona.quartz.nip47WalletConnect.RequestDeserializer
import com.vitorpamplona.quartz.nip47WalletConnect.Response import com.vitorpamplona.quartz.nip47WalletConnect.Response
import com.vitorpamplona.quartz.nip47WalletConnect.ResponseDeserializer import com.vitorpamplona.quartz.nip47WalletConnect.ResponseDeserializer
import com.vitorpamplona.quartz.nip59Giftwrap.Gossip import com.vitorpamplona.quartz.nip59Giftwrap.Rumor
import com.vitorpamplona.quartz.nip59Giftwrap.GossipDeserializer import com.vitorpamplona.quartz.nip59Giftwrap.RumorDeserializer
import com.vitorpamplona.quartz.nip59Giftwrap.GossipSerializer import com.vitorpamplona.quartz.nip59Giftwrap.RumorSerializer
class EventMapper { class EventMapper {
companion object { companion object {
@ -49,8 +49,8 @@ class EventMapper {
SimpleModule() SimpleModule()
.addSerializer(Event::class.java, EventSerializer()) .addSerializer(Event::class.java, EventSerializer())
.addDeserializer(Event::class.java, EventDeserializer()) .addDeserializer(Event::class.java, EventDeserializer())
.addSerializer(Gossip::class.java, GossipSerializer()) .addSerializer(Rumor::class.java, RumorSerializer())
.addDeserializer(Gossip::class.java, GossipDeserializer()) .addDeserializer(Rumor::class.java, RumorDeserializer())
.addDeserializer(Response::class.java, ResponseDeserializer()) .addDeserializer(Response::class.java, ResponseDeserializer())
.addDeserializer(Request::class.java, RequestDeserializer()) .addDeserializer(Request::class.java, RequestDeserializer())
.addDeserializer(BunkerMessage::class.java, BunkerMessage.BunkerMessageDeserializer()) .addDeserializer(BunkerMessage::class.java, BunkerMessage.BunkerMessageDeserializer())

View File

@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrl
import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
import com.vitorpamplona.quartz.nip59Giftwrap.SealedGossipEvent import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
import com.vitorpamplona.quartz.nip92IMeta.IMetaTag import com.vitorpamplona.quartz.nip92IMeta.IMetaTag
import com.vitorpamplona.quartz.nip94FileMetadata.Dimension import com.vitorpamplona.quartz.nip94FileMetadata.Dimension
@ -51,7 +51,7 @@ class NIP17Factory {
val next = remainingTos.first() val next = remainingTos.first()
SealedGossipEvent.create( SealedRumorEvent.create(
event = event, event = event,
encryptTo = next, encryptTo = next,
signer = signer, signer = signer,

View File

@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.HexKey
import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
class Gossip( class Rumor(
val id: HexKey?, val id: HexKey?,
@JsonProperty("pubkey") val pubKey: HexKey?, @JsonProperty("pubkey") val pubKey: HexKey?,
@JsonProperty("created_at") val createdAt: Long?, @JsonProperty("created_at") val createdAt: Long?,
@ -35,7 +35,7 @@ class Gossip(
val tags: Array<Array<String>>?, val tags: Array<Array<String>>?,
val content: String?, val content: String?,
) { ) {
fun mergeWith(event: SealedGossipEvent): Event { fun mergeWith(event: SealedRumorEvent): Event {
val newPubKey = event.pubKey // forces to be the pubkey of the seal to make sure impersonators don't impersonate val newPubKey = event.pubKey // forces to be the pubkey of the seal to make sure impersonators don't impersonate
val newCreatedAt = if (createdAt != null && createdAt > 1000) createdAt else event.createdAt val newCreatedAt = if (createdAt != null && createdAt > 1000) createdAt else event.createdAt
val newKind = kind ?: -1 val newKind = kind ?: -1
@ -48,10 +48,10 @@ class Gossip(
} }
companion object { companion object {
fun fromJson(json: String): Gossip = EventMapper.mapper.readValue(json, Gossip::class.java) fun fromJson(json: String): Rumor = EventMapper.mapper.readValue(json, Rumor::class.java)
fun toJson(event: Gossip): String = EventMapper.mapper.writeValueAsString(event) fun toJson(event: Rumor): String = EventMapper.mapper.writeValueAsString(event)
fun create(event: Event): Gossip = Gossip(event.id, event.pubKey, event.createdAt, event.kind, event.tags, event.content) fun create(event: Event): Rumor = Rumor(event.id, event.pubKey, event.createdAt, event.kind, event.tags, event.content)
} }
} }

View File

@ -26,13 +26,13 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer
import com.vitorpamplona.quartz.nip01Core.jackson.toTypedArray import com.vitorpamplona.quartz.nip01Core.jackson.toTypedArray
class GossipDeserializer : StdDeserializer<Gossip>(Gossip::class.java) { class RumorDeserializer : StdDeserializer<Rumor>(Rumor::class.java) {
override fun deserialize( override fun deserialize(
jp: JsonParser, jp: JsonParser,
ctxt: DeserializationContext, ctxt: DeserializationContext,
): Gossip { ): Rumor {
val jsonObject: JsonNode = jp.codec.readTree(jp) val jsonObject: JsonNode = jp.codec.readTree(jp)
return Gossip( return Rumor(
id = jsonObject.get("id")?.asText()?.intern(), id = jsonObject.get("id")?.asText()?.intern(),
pubKey = jsonObject.get("pubkey")?.asText()?.intern(), pubKey = jsonObject.get("pubkey")?.asText()?.intern(),
createdAt = jsonObject.get("created_at")?.asLong(), createdAt = jsonObject.get("created_at")?.asLong(),

View File

@ -24,9 +24,9 @@ import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.ser.std.StdSerializer import com.fasterxml.jackson.databind.ser.std.StdSerializer
class GossipSerializer : StdSerializer<Gossip>(Gossip::class.java) { class RumorSerializer : StdSerializer<Rumor>(Rumor::class.java) {
override fun serialize( override fun serialize(
event: Gossip, event: Rumor,
gen: JsonGenerator, gen: JsonGenerator,
provider: SerializerProvider, provider: SerializerProvider,
) { ) {

View File

@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.utils.bytesUsedInMemory
import com.vitorpamplona.quartz.utils.pointerSizeInBytes import com.vitorpamplona.quartz.utils.pointerSizeInBytes
@Immutable @Immutable
class SealedGossipEvent( class SealedRumorEvent(
id: HexKey, id: HexKey,
pubKey: HexKey, pubKey: HexKey,
createdAt: Long, createdAt: Long,
@ -44,9 +44,9 @@ class SealedGossipEvent(
super.countMemory() + super.countMemory() +
pointerSizeInBytes + (innerEventId?.bytesUsedInMemory() ?: 0) pointerSizeInBytes + (innerEventId?.bytesUsedInMemory() ?: 0)
fun copyNoContent(): SealedGossipEvent { fun copyNoContent(): SealedRumorEvent {
val copy = val copy =
SealedGossipEvent( SealedRumorEvent(
id, id,
pubKey, pubKey,
createdAt, createdAt,
@ -67,7 +67,7 @@ class SealedGossipEvent(
message = "Heavy caching was removed from this class due to high memory use. Cache it separatedly", message = "Heavy caching was removed from this class due to high memory use. Cache it separatedly",
replaceWith = ReplaceWith("unseal"), replaceWith = ReplaceWith("unseal"),
) )
fun cachedGossip( fun cachedRumor(
signer: NostrSigner, signer: NostrSigner,
onReady: (Event) -> Unit, onReady: (Event) -> Unit,
) = unseal(signer, onReady) ) = unseal(signer, onReady)
@ -79,8 +79,8 @@ class SealedGossipEvent(
try { try {
plainContent(signer) { plainContent(signer) {
try { try {
val gossip = Gossip.fromJson(it) val rumor = Rumor.fromJson(it)
val event = gossip.mergeWith(this) val event = rumor.mergeWith(this)
if (event is WrappedEvent) { if (event is WrappedEvent) {
event.host = host ?: HostStub(this.id, this.pubKey, this.kind) event.host = host ?: HostStub(this.id, this.pubKey, this.kind)
} }
@ -88,11 +88,11 @@ class SealedGossipEvent(
onReady(event) onReady(event)
} catch (e: Exception) { } catch (e: Exception) {
Log.w("GossipEvent", "Fail to decrypt or parse Gossip", e) Log.w("RumorEvent", "Fail to decrypt or parse Rumor", e)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
Log.w("GossipEvent", "Fail to decrypt or parse Gossip", e) Log.w("RumorEvent", "Fail to decrypt or parse Rumor", e)
} }
} }
@ -113,20 +113,20 @@ class SealedGossipEvent(
encryptTo: HexKey, encryptTo: HexKey,
signer: NostrSigner, signer: NostrSigner,
createdAt: Long = TimeUtils.now(), createdAt: Long = TimeUtils.now(),
onReady: (SealedGossipEvent) -> Unit, onReady: (SealedRumorEvent) -> Unit,
) { ) {
val gossip = Gossip.create(event) val rumor = Rumor.create(event)
create(gossip, encryptTo, signer, createdAt, onReady) create(rumor, encryptTo, signer, createdAt, onReady)
} }
fun create( fun create(
gossip: Gossip, rumor: Rumor,
encryptTo: HexKey, encryptTo: HexKey,
signer: NostrSigner, signer: NostrSigner,
createdAt: Long = TimeUtils.randomWithTwoDays(), createdAt: Long = TimeUtils.randomWithTwoDays(),
onReady: (SealedGossipEvent) -> Unit, onReady: (SealedRumorEvent) -> Unit,
) { ) {
val msg = Gossip.toJson(gossip) val msg = Rumor.toJson(rumor)
signer.nip44Encrypt(msg, encryptTo) { content -> signer.nip44Encrypt(msg, encryptTo) { content ->
signer.sign(createdAt, KIND, emptyArray(), content, onReady) signer.sign(createdAt, KIND, emptyArray(), content, onReady)