Compare commits

..

No commits in common. "2829bcfecdc7ee2aa92bbb9b38783f023dec04cb" and "fe4cb2ca2133b5624b0dcfc6ad1b350b29a04811" have entirely different histories.

11 changed files with 28 additions and 37 deletions

3
.idea/misc.xml generated
View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,8 +1,5 @@
# 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.

View File

@ -11,15 +11,15 @@
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
plugins {
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
kotlin("multiplatform") version "2.2.20"
id("org.jetbrains.kotlin.plugin.serialization") version "2.2.20"
id("com.android.library") version "8.5.2" apply true
`maven-publish`
id("org.jetbrains.dokka") version "1.9.20"
}
group = "net.sergeych"
version = "0.7.0-SNAPSHOT"
version = "0.6.12"
repositories {
mavenCentral()
@ -30,10 +30,11 @@ repositories {
}
kotlin {
jvmToolchain(21)
jvmToolchain(17)
jvm()
js {
browser()
browser {
}
nodejs()
}
linuxX64()
@ -60,16 +61,14 @@ 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.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
api("io.ktor:ktor-client-core:$ktor_version")
api("net.sergeych:crypto2:0.9.0")
api("net.sergeych:crypto2:0.8.5")
}
}
val androidMain by getting {
@ -86,8 +85,8 @@ kotlin {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.slf4j:slf4j-simple:2.0.17")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2")
implementation("org.slf4j:slf4j-simple:2.0.9")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1")
}
}
val ktorSocketTest by creating {

View File

@ -11,10 +11,5 @@
kotlin.code.style=official
kotlin.mpp.applyDefaultHierarchyTemplate=false
kotlin.daemon.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.daemon.jvmargs=-Xmx2048m
kotlin.native.ignoreDisabledTargets=true
org.gradle.parallel=true
org.gradle.configuration-cache=true
org.gradle.caching=true

View File

@ -10,6 +10,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -15,11 +15,12 @@ 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 kiloparsec (and also diwan): it is used
* Typesafe command definition. Command is a universal entity in Divan: 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.

View File

@ -27,12 +27,13 @@ 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
/**
* Kiloparsec channel that operates some block [Device] exporting a given [localInterface]
* Divan 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)
*/
@ -250,7 +251,7 @@ class Transport<S>(
} catch (cce: LocalInterface.BreakConnectionException) {
info { "closing connection by local request ($cce)" }
device.close()
} catch (_: RemoteInterface.ClosedException) {
} catch (t: RemoteInterface.ClosedException) {
// it is ok: we just exit the coroutine normally
// and mark we're closing
isClosed = true

View File

@ -9,6 +9,7 @@
*/
import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Instant
import net.sergeych.bipack.BipackEncoder
import net.sergeych.crypto2.initCrypto
import net.sergeych.kiloparsec.KiloParams
@ -20,7 +21,6 @@ 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 <reified T>check(x: T?) {

View File

@ -76,8 +76,7 @@ class TransportTest {
"p2: $it"
}
on(cmdSlow) {
// the problem: runTest() breaks delays so it is not enough
for( i in 0..10000) delay(1)
delay(100)
"done"
}
}

View File

@ -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 (_: ClosedReceiveChannelException) {
} catch (e: ClosedReceiveChannelException) {
log.error { "closed receive channel " }
stop()
break

View File

@ -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 (_: CancellationException) {
} catch (e: CancellationException) {
// this is ok
break
} catch (_: ClosedReceiveChannelException) {
} catch (e: ClosedReceiveChannelException) {
debug { "input channel is closed, closing" }
close()
break