All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.org.ton.api.dht.functions.DhtFindValue.kt Maven / Gradle / Ivy

package org.ton.api.dht.functions

import org.ton.api.dht.DhtKey
import org.ton.api.dht.DhtValueResult
import org.ton.tl.*

public data class DhtFindValue(
    val key: Bits256,
    val k: Int
) : TLFunction {
    public constructor(key: ByteArray, k: Int) : this(Bits256(key), k)
    public constructor(key: DhtKey, k: Int) : this(key.hash(), k)

    override fun tlCodec(): TlCodec = DhtFindValueTlConstructor

    override fun resultTlCodec(): TlCodec = DhtValueResult
}

private object DhtFindValueTlConstructor : TlConstructor(
    schema = "dht.findValue key:int256 k:int = dht.ValueResult"
) {
    override fun encode(output: TlWriter, value: DhtFindValue) {
        output.writeBits256(value.key)
        output.writeInt(value.k)
    }

    override fun decode(input: TlReader): DhtFindValue {
        val key = input.readBits256()
        val k = input.readInt()
        return DhtFindValue(key, k)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy