diff --git a/.idea/misc.xml b/.idea/misc.xml index e9349bf..7deb2c1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,9 +1,10 @@ + - + \ No newline at end of file diff --git a/README.md b/README.md index df37682..6b8c945 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Kiloparsec +> 0.7.0-SNAPSHOT is recommended for newer builds; due to extremely poor Kotlin time migration architecture, on Apple targets it is the only working version. + + __Recommended version is `0.6.8`: to keep the code compatible with current and further versions we ask to upgrade to `0.4.2` at least.__ Starting from this version some package names are changed for better clarity and fast UDP endpoints are added. diff --git a/build.gradle.kts b/build.gradle.kts index 37b2ce8..1b08e34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,15 +11,15 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl plugins { - kotlin("multiplatform") version "2.1.21" - id("org.jetbrains.kotlin.plugin.serialization") version "2.1.21" - id("com.android.library") version "8.5.2" apply true + kotlin("multiplatform") version "2.2.21" + id("org.jetbrains.kotlin.plugin.serialization") version "2.2.21" + id("com.android.library") version "8.7.2" apply true `maven-publish` id("org.jetbrains.dokka") version "1.9.20" } group = "net.sergeych" -version = "0.6.10-SNAPSHOT" +version = "0.7.0-SNAPSHOT" repositories { mavenCentral() @@ -30,11 +30,10 @@ repositories { } kotlin { - jvmToolchain(17) + jvmToolchain(21) jvm() js { - browser { - } + browser() nodejs() } linuxX64() @@ -61,14 +60,16 @@ kotlin { languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi") languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") languageSettings.optIn("kotlin.ExperimentalUnsignedTypes") + languageSettings.optIn("kotlin.time.ExperimentalTime") + } val commonMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0") api("io.ktor:ktor-client-core:$ktor_version") - api("net.sergeych:crypto2:0.8.4") + api("net.sergeych:crypto2:0.9.0") } } val androidMain by getting { @@ -85,8 +86,8 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.slf4j:slf4j-simple:2.0.9") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") + implementation("org.slf4j:slf4j-simple:2.0.17") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2") } } val ktorSocketTest by creating { diff --git a/gradle.properties b/gradle.properties index 470de7c..333acd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,5 +11,10 @@ kotlin.code.style=official kotlin.mpp.applyDefaultHierarchyTemplate=false -kotlin.daemon.jvmargs=-Xmx2048m -kotlin.native.ignoreDisabledTargets=true \ No newline at end of file +kotlin.daemon.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +kotlin.native.ignoreDisabledTargets=true + +org.gradle.parallel=true +org.gradle.configuration-cache=true +org.gradle.caching=true + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f364ac3..e5bc481 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -10,6 +10,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/src/commonMain/kotlin/net/sergeych/kiloparsec/Command.kt b/src/commonMain/kotlin/net/sergeych/kiloparsec/Command.kt index 5d3a9df..2ee1ef2 100644 --- a/src/commonMain/kotlin/net/sergeych/kiloparsec/Command.kt +++ b/src/commonMain/kotlin/net/sergeych/kiloparsec/Command.kt @@ -15,12 +15,11 @@ import kotlinx.serialization.Serializable import net.sergeych.bintools.toDataSource import net.sergeych.bipack.BipackDecoder import net.sergeych.bipack.BipackEncoder -import net.sergeych.kiloparsec.Command.Call import net.sergeych.kiloparsec.Command.Companion.unpackCall import net.sergeych.utools.unpack /** - * Typesafe command definition. Command is a universal entity in Divan: it is used + * Typesafe command definition. Command is a universal entity in kiloparsec (and also diwan): it is used * in node-2-node protocols and client API, and most importantly in calling smart contract * methods. This is essentially a Kotlin binding to typesafe serialize command calls and * deserialize results. diff --git a/src/commonMain/kotlin/net/sergeych/kiloparsec/Transport.kt b/src/commonMain/kotlin/net/sergeych/kiloparsec/Transport.kt index 79ad293..646ce40 100644 --- a/src/commonMain/kotlin/net/sergeych/kiloparsec/Transport.kt +++ b/src/commonMain/kotlin/net/sergeych/kiloparsec/Transport.kt @@ -27,13 +27,12 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.serializer import net.sergeych.bipack.Unsigned import net.sergeych.crypto2.toDump -import net.sergeych.kiloparsec.Transport.Device import net.sergeych.mp_logger.* import net.sergeych.utools.pack import net.sergeych.utools.unpack /** - * Divan channel that operates some block [Device] exporting a given [localInterface] + * Kiloparsec channel that operates some block [Device] exporting a given [localInterface] * to remote callers. [LocalInterface] allows session managing, transmitting exceptions * in a scure and multiplatform way and provide local command execution (typed RPC) */ @@ -251,7 +250,7 @@ class Transport( } catch (cce: LocalInterface.BreakConnectionException) { info { "closing connection by local request ($cce)" } device.close() - } catch (t: RemoteInterface.ClosedException) { + } catch (_: RemoteInterface.ClosedException) { // it is ok: we just exit the coroutine normally // and mark we're closing isClosed = true diff --git a/src/commonTest/kotlin/PackTest.kt b/src/commonTest/kotlin/PackTest.kt index 176fc57..c936293 100644 --- a/src/commonTest/kotlin/PackTest.kt +++ b/src/commonTest/kotlin/PackTest.kt @@ -9,7 +9,6 @@ */ import kotlinx.coroutines.test.runTest -import kotlinx.datetime.Instant import net.sergeych.bipack.BipackEncoder import net.sergeych.crypto2.initCrypto import net.sergeych.kiloparsec.KiloParams @@ -21,6 +20,7 @@ import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals import kotlin.time.Duration.Companion.microseconds +import kotlin.time.Instant class PackTest { inline fun check(x: T?) { diff --git a/src/commonTest/kotlin/TransportTest.kt b/src/commonTest/kotlin/TransportTest.kt index e4941ff..63b381c 100644 --- a/src/commonTest/kotlin/TransportTest.kt +++ b/src/commonTest/kotlin/TransportTest.kt @@ -76,7 +76,8 @@ class TransportTest { "p2: $it" } on(cmdSlow) { - delay(100) + // the problem: runTest() breaks delays so it is not enough + for( i in 0..10000) delay(1) "done" } } diff --git a/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/TcpProvider.kt b/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/TcpProvider.kt index 01f4480..bed37be 100644 --- a/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/TcpProvider.kt +++ b/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/TcpProvider.kt @@ -22,11 +22,11 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import kotlinx.datetime.Clock import net.sergeych.kiloparsec.* import net.sergeych.mp_logger.* import net.sergeych.mp_tools.globalLaunch import net.sergeych.tools.AtomicCounter +import kotlin.time.Clock import kotlin.time.Duration.Companion.seconds private val logCounter = AtomicCounter(0) @@ -140,7 +140,7 @@ private fun inetTransportDevice( sockInput.readFully(data, 0, size) inputBlocks.send(data.toUByteArray()) } - } catch (e: ClosedReceiveChannelException) { + } catch (_: ClosedReceiveChannelException) { log.error { "closed receive channel " } stop() break diff --git a/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/UdpSocketTransport.kt b/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/UdpSocketTransport.kt index 0b1879d..7750061 100644 --- a/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/UdpSocketTransport.kt +++ b/src/ktorSocketMain/kotlin/net/sergeych/kiloparsec/adapter/UdpSocketTransport.kt @@ -19,13 +19,13 @@ import kotlinx.coroutines.channels.ClosedSendChannelException import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch -import kotlinx.datetime.Clock import net.sergeych.kiloparsec.SyncValue import net.sergeych.mp_logger.Log import net.sergeych.mp_logger.Loggable import net.sergeych.mp_logger.debug import net.sergeych.mp_logger.exception import net.sergeych.mp_tools.globalLaunch +import kotlin.time.Clock import kotlin.time.Duration /** @@ -171,10 +171,10 @@ internal class UdpSocketTransport( while (!isClosed) { try { server.sendBlock(UdpBlock.Data(outputDataBlocks.receive()), socketAddress) - } catch (e: CancellationException) { + } catch (_: CancellationException) { // this is ok break - } catch (e: ClosedReceiveChannelException) { + } catch (_: ClosedReceiveChannelException) { debug { "input channel is closed, closing" } close() break