mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-17 21:31:57 +01:00
Removes the notion of generic Address references
This commit is contained in:
parent
8720b00d4f
commit
9e1a2bb1e4
@ -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)
|
||||
}
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user