From 9e1a2bb1e4f5c02a0fb9498145412acc8fd024c9 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 18 Feb 2025 11:29:52 -0500 Subject: [PATCH] Removes the notion of generic Address references --- .../tags/addressables/AddressReference.kt | 36 ------------------- .../nip22Comments/tags/ReplyAddressTag.kt | 8 ++--- .../nip22Comments/tags/RootAddressTag.kt | 8 ++--- 3 files changed, 6 insertions(+), 46 deletions(-) delete mode 100644 quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/tags/addressables/AddressReference.kt diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/tags/addressables/AddressReference.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/tags/addressables/AddressReference.kt deleted file mode 100644 index c5d504674..000000000 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/tags/addressables/AddressReference.kt +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2024 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.quartz.nip01Core.tags.addressables - -import androidx.compose.runtime.Immutable -import com.vitorpamplona.quartz.utils.bytesUsedInMemory -import com.vitorpamplona.quartz.utils.pointerSizeInBytes - -@Immutable -data class AddressReference( - val addressId: String, - var relay: String? = null, -) { - fun countMemory(): Long = - 2 * pointerSizeInBytes + // 7 fields, 4 bytes each reference (32bit) - addressId.bytesUsedInMemory() + - (relay?.bytesUsedInMemory() ?: 0) -} diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/ReplyAddressTag.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/ReplyAddressTag.kt index b80a558bf..e37b6afbc 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/ReplyAddressTag.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/ReplyAddressTag.kt @@ -26,16 +26,14 @@ import com.vitorpamplona.quartz.nip01Core.core.Tag import com.vitorpamplona.quartz.nip01Core.core.match import com.vitorpamplona.quartz.nip01Core.core.valueIfMatches import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address -import com.vitorpamplona.quartz.nip01Core.tags.addressables.AddressReference import com.vitorpamplona.quartz.utils.arrayOfNotNull @Immutable class ReplyAddressTag( - val ref: AddressReference, + val addressId: String, + val relay: String? = null, ) { - constructor(aTagId: String, relayHint: String?) : this(AddressReference(aTagId, relayHint)) - - fun toTagArray() = assemble(ref.addressId, ref.relay) + fun toTagArray() = assemble(addressId, relay) companion object { const val TAG_NAME = "a" diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/RootAddressTag.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/RootAddressTag.kt index 2d035639f..e4dbbc220 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/RootAddressTag.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip22Comments/tags/RootAddressTag.kt @@ -26,16 +26,14 @@ import com.vitorpamplona.quartz.nip01Core.core.Tag import com.vitorpamplona.quartz.nip01Core.core.match import com.vitorpamplona.quartz.nip01Core.core.valueIfMatches import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address -import com.vitorpamplona.quartz.nip01Core.tags.addressables.AddressReference import com.vitorpamplona.quartz.utils.arrayOfNotNull @Immutable class RootAddressTag( - val ref: AddressReference, + val addressId: String, + val relay: String? = null, ) { - constructor(aTagId: String, relayHint: String?) : this(AddressReference(aTagId, relayHint)) - - fun toTagArray() = assemble(ref.addressId, ref.relay) + fun toTagArray() = assemble(addressId, relay) companion object { const val TAG_NAME = "A"