Skip to content

Commit

Permalink
Merge pull request #30 from projectNEWM/ogmios_6
Browse files Browse the repository at this point in the history
Upgrades for Ogmios 6
  • Loading branch information
AndrewWestberg authored Jan 23, 2024
2 parents f47c5b7 + 61ef0a4 commit f0f312d
Show file tree
Hide file tree
Showing 378 changed files with 7,008 additions and 6,768 deletions.
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[*.{kt,kts}]
disabled_rules=import-ordering,no-wildcard-imports
ktlint_standard_import-ordering = disabled
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
max_line_length = off
2 changes: 1 addition & 1 deletion .github/workflows/ktlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
distribution: 'zulu'
java-version: '17'
- run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.43.2/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.1.1/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/
- name: run ktlint
run: |
ktlint --reporter=checkstyle,output=build/ktlint-report.xml
Expand Down
72 changes: 38 additions & 34 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import org.hibernate.build.publish.auth.maven.MavenRepoAuthPlugin

plugins {
java
id("com.github.ben-manes.versions") version Versions.versionsPlugin
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlintPlugin
kotlin("jvm") version Versions.kotlin
kotlin("plugin.serialization") version Versions.kotlin
id("com.github.ben-manes.versions") version Versions.VERSIONS_PLUGIN
id("org.jlleitschuh.gradle.ktlint") version Versions.KTLINT_PLUGIN
kotlin("jvm") version Versions.KOTLIN
kotlin("plugin.serialization") version Versions.KOTLIN
id("maven-publish")
id("signing")
id("org.hibernate.build.maven-repo-auth") version Versions.mavenRepoAuthPlugin apply false
id("org.hibernate.build.maven-repo-auth") version Versions.MAVEN_REPO_AUTH_PLUGIN apply false
}

if (!project.hasProperty("isGithubActions")) {
Expand All @@ -18,7 +18,7 @@ if (!project.hasProperty("isGithubActions")) {
}

group = "io.newm"
version = "1.0.3"
version = "2.0.0-SNAPSHOT"

java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17
Expand All @@ -33,26 +33,28 @@ repositories {
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}")
implementation("io.ktor:ktor-client-websockets:${Versions.ktor}")

implementation("io.ktor:ktor-client-cio-jvm:${Versions.ktor}")

implementation("commons-logging:commons-logging:${Versions.commonsLogging}")
implementation("ch.qos.logback:logback-classic:${Versions.logback}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.coroutines}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.kotlinxSerialization}")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.kotlinxDatetime}")

testImplementation("io.mockk:mockk:${Versions.mockk}")
testImplementation("com.google.truth:truth:${Versions.googleTruth}")
testImplementation("org.junit.jupiter:junit-jupiter:${Versions.junit}")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.coroutines}")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.KOTLIN}")
implementation("io.ktor:ktor-client-websockets:${Versions.KTOR}")

implementation("io.ktor:ktor-client-cio-jvm:${Versions.KTOR}")

implementation("commons-logging:commons-logging:${Versions.COMMONS_LOGGING}")
implementation("ch.qos.logback:logback-classic:${Versions.LOGBACK}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.COROUTINES}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.KOTLINX_SERIALIZATION}")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${Versions.KOTLINX_DATETIME}")

implementation("org.apache.commons:commons-numbers-fraction:${Versions.COMMONS_NUMBERS}")

testImplementation("io.mockk:mockk:${Versions.MOCKK}")
testImplementation("com.google.truth:truth:${Versions.GOOGLE_TRUTH}")
testImplementation("org.junit.jupiter:junit-jupiter:${Versions.JUNIT}")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.COROUTINES}")
}

ktlint {
version.set(Versions.ktlintVersion)
version.set(Versions.KTLINT)
}

tasks {
Expand All @@ -66,7 +68,7 @@ tasks {
val javadocJar by registering(Jar::class) {
archiveClassifier.set("javadoc")
dependsOn("javadoc")
from("$buildDir/javadoc")
from("${layout.buildDirectory}/javadoc")
}

artifacts {
Expand Down Expand Up @@ -136,7 +138,7 @@ signing {
}

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
Expand Down Expand Up @@ -171,21 +173,23 @@ tasks.withType<DependencyUpdatesTask> {

project.tasks.withType<org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain>().configureEach {
val service = project.extensions.getByType<JavaToolchainService>()
val customLauncher = service.launcherFor {
this.languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion))
}
val customLauncher =
service.launcherFor {
this.languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion))
}

this.kotlinJavaToolchain.toolchain.use(customLauncher)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf(
"-Xjsr305=strict",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
)
freeCompilerArgs =
listOf(
"-Xjsr305=strict",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
)
jvmTarget = "17"
}
}
Expand Down
29 changes: 15 additions & 14 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
object Versions {
const val commonsLogging = "1.2"
const val coroutines = "1.6.4"
const val googleTruth = "1.1.3"
const val junit = "5.9.2"
const val kotlin = "1.8.10"
const val ktor = "2.2.4"
const val kotlinxDatetime = "0.4.0"
const val kotlinxSerialization = "1.5.0"
const val ktlintPlugin = "11.1.0"
const val ktlintVersion = "0.43.2"
const val logback = "1.4.5"
const val mavenRepoAuthPlugin = "3.0.4"
const val mockk = "1.13.4"
const val versionsPlugin = "0.46.0"
const val COMMONS_LOGGING = "1.3.0"
const val COMMONS_NUMBERS = "1.1"
const val COROUTINES = "1.7.3"
const val GOOGLE_TRUTH = "1.3.0"
const val JUNIT = "5.10.1"
const val KOTLIN = "1.9.22"
const val KOTLINX_DATETIME = "0.5.0"
const val KOTLINX_SERIALIZATION = "1.6.2"
const val KTLINT = "1.1.1"
const val KTLINT_PLUGIN = "12.1.0"
const val KTOR = "2.3.7"
const val LOGBACK = "1.4.14"
const val MAVEN_REPO_AUTH_PLUGIN = "3.0.4"
const val MOCKK = "1.13.9"
const val VERSIONS_PLUGIN = "0.51.0"
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 22 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
9 changes: 4 additions & 5 deletions src/main/kotlin/io/newm/kogmios/ChainSyncClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ package io.newm.kogmios

import io.newm.kogmios.Client.Companion.DEFAULT_REQUEST_TIMEOUT_MS
import io.newm.kogmios.protocols.messages.MsgFindIntersectResponse
import io.newm.kogmios.protocols.messages.MsgRequestNextResponse
import io.newm.kogmios.protocols.messages.MsgNextBlockResponse
import io.newm.kogmios.protocols.model.PointDetailOrOrigin

/**
* Client interface for syncing the blockchain.
*/
interface ChainSyncClient : Client {

/**
* Ask for an intersection between the server's local chain and the given points.
*/
suspend fun findIntersect(
points: List<PointDetailOrOrigin>,
timeoutMs: Long = DEFAULT_REQUEST_TIMEOUT_MS
timeoutMs: Long = DEFAULT_REQUEST_TIMEOUT_MS,
): MsgFindIntersectResponse

/**
* Request the next block from the server
*/
suspend fun requestNext(timeoutMs: Long = DEFAULT_REQUEST_TIMEOUT_MS): MsgRequestNextResponse
suspend fun nextBlock(timeoutMs: Long = DEFAULT_REQUEST_TIMEOUT_MS): MsgNextBlockResponse
}

fun createChainSyncClient(
websocketHost: String,
websocketPort: Int,
secure: Boolean = false,
ogmiosCompact: Boolean = false,
loggerName: String? = null
loggerName: String? = null,
): ChainSyncClient {
return ClientImpl(websocketHost, websocketPort, secure, ogmiosCompact, loggerName)
}
Loading

0 comments on commit f0f312d

Please sign in to comment.