Skip to content

Commit

Permalink
Merge pull request #329 from libp2p/1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Sep 16, 2023
2 parents 115a481 + 64c6783 commit 433d0b1
Show file tree
Hide file tree
Showing 167 changed files with 7,148 additions and 6,848 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: publish
on:
push:
branches:
- "develop"
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Publish to Cloudsmith
run: ./gradlew publish -PcloudsmithUser=${{ secrets.CLOUDSMITH_USER }} -PcloudsmithApiKey=${{ secrets.CLOUDSMITH_API_KEY }}
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ Add the required repositories to the `dependencyManagement` section of the pom
<repository>
<id>libp2p-jvm-libp2p</id>
<url>https://dl.cloudsmith.io/public/libp2p/jvm-libp2p/maven/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>JitPack</id>
Expand All @@ -123,7 +115,6 @@ Add the library to the `dependencies` section of the pom file:
<groupId>io.libp2p</groupId>
<artifactId>jvm-libp2p</artifactId>
<version>X.Y.Z-RELEASE</version>
<type>pom</type>
</dependency>
```

Expand Down
33 changes: 23 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL

// To publish the release artifact to CloudSmith repo run the following :
// ./gradlew publish -PcloudsmithUser=<user> -PcloudsmithApiKey=<api-key>

description = "an implementation of libp2p for the jvm"
description = "a libp2p implementation for the JVM, written in Kotlin"

plugins {
val kotlinVersion = "1.6.21"

id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false

id("com.github.ben-manes.versions").version("0.44.0")
id("com.github.ben-manes.versions").version("0.48.0")
id("idea")
id("io.gitlab.arturbosch.detekt").version("1.22.0")
id("java")
id("maven-publish")
id("org.jetbrains.dokka").version("1.7.20")
id("org.jmailen.kotlinter").version("3.10.0")
id("org.jetbrains.dokka").version("1.9.0")
id("com.diffplug.spotless").version("6.21.0")
id("java-test-fixtures")
id("io.spring.dependency-management").version("1.1.0")
id("io.spring.dependency-management").version("1.1.3")

id("org.jetbrains.kotlin.android") version kotlinVersion apply false
id("com.android.application") version "7.4.2" apply false
Expand All @@ -36,7 +37,7 @@ configure(
}
) {
group = "io.libp2p"
version = "1.0.0-RELEASE"
version = "1.0.1-RELEASE"

apply(plugin = "kotlin")
apply(plugin = "idea")
Expand All @@ -45,7 +46,7 @@ configure(
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jmailen.kotlinter")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "java-test-fixtures")
apply(plugin = "io.spring.dependency-management")
apply(from = "$rootDir/versions.gradle")
Expand All @@ -57,7 +58,6 @@ configure(

implementation("com.google.guava:guava")
implementation("org.slf4j:slf4j-api")
implementation("com.github.multiformats:java-multibase:v1.1.1")

testFixturesImplementation("com.google.guava:guava")
testFixturesImplementation("org.slf4j:slf4j-api")
Expand Down Expand Up @@ -108,8 +108,21 @@ configure(
// Runtime.getRuntime().availableProcessors().div(2))
}

kotlinter {
disabledRules = arrayOf("no-wildcard-imports", "enum-entry-name-case")
configure<SpotlessExtension> {
kotlin {
ktlint().editorConfigOverride(
mapOf(
"ktlint_standard_no-wildcard-imports" to "disabled",
"ktlint_standard_enum-entry-name-case" to "disabled",
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled"
)
)
}
java {
targetExclude("**/generated/**/proto/**")
googleJavaFormat()
}
}

val sourcesJar by tasks.registering(Jar::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class ChatNode(private val printMsg: OnMessage) {
fun send(message: String) {
peers.values.forEach { it.controller.send(message) }

if (message.startsWith("alias "))
if (message.startsWith("alias ")) {
currentAlias = message.substring(6).trim()
}
} // send

fun stop() {
Expand Down Expand Up @@ -83,8 +84,9 @@ class ChatNode(private val printMsg: OnMessage) {
if (
info.peerId == chatHost.peerId ||
knownNodes.contains(info.peerId)
)
) {
return
}

knownNodes.add(info.peerId)

Expand Down Expand Up @@ -126,10 +128,11 @@ class ChatNode(private val printMsg: OnMessage) {
.filterIsInstance<Inet4Address>()
.filter { it.isSiteLocalAddress }
.sortedBy { it.hostAddress }
return if (addresses.isNotEmpty())
return if (addresses.isNotEmpty()) {
addresses[0]
else
} else {
InetAddress.getLoopbackAddress()
}
}
}
} // class ChatNode
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ fun main() {
print(">> ")
message = readLine()?.trim()

if (message == null || message.isEmpty())
if (message == null || message.isEmpty()) {
continue
}

node.send(message)
} while ("bye" != message)
Expand Down
14 changes: 3 additions & 11 deletions examples/pinger/src/main/java/io/libp2p/example/ping/Pinger.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
import io.libp2p.core.multiformats.Multiaddr;
import io.libp2p.protocol.Ping;
import io.libp2p.protocol.PingController;

import java.util.concurrent.ExecutionException;

public class Pinger {
public static void main(String[] args)
throws ExecutionException, InterruptedException {
public static void main(String[] args) throws ExecutionException, InterruptedException {
// Create a libp2p node and configure it
// to accept TCP connections on a random port
Host node = new HostBuilder()
.protocol(new Ping())
.listen("/ip4/127.0.0.1/tcp/0")
.build();
Host node = new HostBuilder().protocol(new Ping()).listen("/ip4/127.0.0.1/tcp/0").build();

// start listening
node.start().get();
Expand All @@ -26,10 +21,7 @@ public static void main(String[] args)

if (args.length > 0) {
Multiaddr address = Multiaddr.fromString(args[0]);
PingController pinger = new Ping().dial(
node,
address
).getController().get();
PingController pinger = new Ping().dial(node, address).getController().get();

System.out.println("Sending 5 ping messages to " + address.toString());
for (int i = 1; i <= 5; ++i) {
Expand Down
11 changes: 6 additions & 5 deletions libp2p/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.google.protobuf").version("0.9.2")
id("me.champeau.jmh").version("0.6.8")
id("com.google.protobuf").version("0.9.4")
id("me.champeau.jmh").version("0.7.1")
}

// https://docs.gradle.org/current/userguide/java_testing.html#ex-disable-publishing-of-test-fixtures-variants
Expand All @@ -17,11 +17,12 @@ dependencies {

api("com.google.protobuf:protobuf-java")

implementation("com.github.multiformats:java-multibase")
implementation("tech.pegasys:noise-java")

implementation("org.bouncycastle:bcprov-jdk15on")
implementation("org.bouncycastle:bcpkix-jdk15on")
implementation("org.bouncycastle:bctls-jdk15on")
implementation("org.bouncycastle:bcprov-jdk18on")
implementation("org.bouncycastle:bcpkix-jdk18on")
implementation("org.bouncycastle:bctls-jdk18on")

testImplementation(project(":tools:schedulers"))

Expand Down
Loading

0 comments on commit 433d0b1

Please sign in to comment.