diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 7eb9a72ed2f..d38834b5ad6 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -33,6 +33,10 @@ + + + + diff --git a/build.gradle b/build.gradle index 2e2b6ab91be..19c2d56679b 100644 --- a/build.gradle +++ b/build.gradle @@ -47,6 +47,7 @@ configure(subprojects) { ioVersion = '2.6' jacksonVersion = '2.8.10' javafxVersion = '11.0.2' + javaxAnnotationVersion = '1.2' jcsvVersion = '1.4.0' jetbrainsAnnotationsVersion = '13.0' jfoenixVersion = '9.0.6' @@ -154,6 +155,47 @@ configure([project(':cli'), } } +configure(project(':proto')) { + apply plugin: 'com.google.protobuf' + + dependencies { + implementation "com.google.protobuf:protobuf-java:$protobufVersion" + implementation("io.grpc:grpc-protobuf:$grpcVersion") { + exclude(module: 'guava') + exclude(module: 'animal-sniffer-annotations') + } + implementation("io.grpc:grpc-stub:$grpcVersion") { + exclude(module: 'guava') + exclude(module: 'animal-sniffer-annotations') + } + implementation "com.google.guava:guava:$guavaVersion" + implementation "org.slf4j:slf4j-api:$slf4jVersion" + implementation "ch.qos.logback:logback-core:$logbackVersion" + implementation "ch.qos.logback:logback-classic:$logbackVersion" + compileOnly "org.projectlombok:lombok:$lombokVersion" + compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion" + annotationProcessor "org.projectlombok:lombok:$lombokVersion" + } + + sourceSets.main.java.srcDirs += [ + 'build/generated/source/proto/main/grpc', + 'build/generated/source/proto/main/java' + ] + + protobuf { + protoc { + artifact = "com.google.protobuf:protoc:${protocVersion}" + } + plugins { + grpc { + artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" + } + } + generateProtoTasks { + all()*.plugins { grpc {} } + } + } +} configure(project(':assets')) { dependencies { @@ -171,17 +213,8 @@ configure(project(':assets')) { configure(project(':common')) { - apply plugin: 'com.google.protobuf' - - sourceSets.main.java.srcDir "$buildDir/generated/source/proto/main/java" - - protobuf { - protoc { - artifact = "com.google.protobuf:protoc:$protocVersion" - } - } - dependencies { + compile project(':proto') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" compile "org.openjfx:javafx-base:$javafxVersion:$os" compile "org.openjfx:javafx-graphics:$javafxVersion:$os" @@ -202,6 +235,10 @@ configure(project(':common')) { exclude(module: 'guava') exclude(module: 'protobuf-java') } + runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") { + exclude(module: 'guava') + exclude(module: 'animal-sniffer-annotations') + } compile "org.jetbrains:annotations:$jetbrainsAnnotationsVersion" compile "org.bouncycastle:bcpg-jdk15on:$bcVersion" compile "commons-io:commons-io:$ioVersion" @@ -236,14 +273,13 @@ configure(project(':p2p')) { configure(project(':core')) { - apply plugin: 'com.google.protobuf' - dependencies { + compile project(':proto') compile project(':assets') compile project(':p2p') - implementation "commons-codec:commons-codec:$codecVersion" - implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion" - implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") { + implementation "commons-codec:commons-codec:$codecVersion" + implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion" + implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") { exclude(module: 'commons-codec') } compile("network.bisq.btcd-cli4j:btcd-cli4j-core:$btcdCli4jVersion") { @@ -276,8 +312,8 @@ configure(project(':core')) { exclude(module: 'guava') exclude(module: 'animal-sniffer-annotations') } - compileOnly "javax.annotation:javax.annotation-api:1.2" - runtimeOnly ("io.grpc:grpc-netty-shaded:$grpcVersion") { + compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion" + runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") { exclude(module: 'guava') exclude(module: 'animal-sniffer-annotations') } @@ -291,25 +327,6 @@ configure(project(':core')) { testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion" } - protobuf { - protoc { - artifact = "com.google.protobuf:protoc:${protocVersion}" - } - plugins { - grpc { - artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" - } - } - generateProtoTasks { - all()*.plugins { grpc {} } - } - } - - sourceSets.main.java.srcDirs += [ - 'build/generated/source/proto/main/grpc', - 'build/generated/source/proto/main/java' - ] - test { systemProperty 'jdk.attach.allowAttachSelf', true } @@ -319,7 +336,9 @@ configure(project(':cli')) { mainClassName = 'bisq.cli.app.BisqCliMain' dependencies { - compile project(':core') + compile project(':proto') + implementation "com.google.guava:guava:$guavaVersion" + implementation "com.google.protobuf:protobuf-java:$protobufVersion" implementation("io.grpc:grpc-core:$grpcVersion") { exclude(module: 'guava') exclude(module: 'animal-sniffer-annotations') @@ -328,6 +347,13 @@ configure(project(':cli')) { exclude(module: 'guava') exclude(module: 'animal-sniffer-annotations') } + runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") { + exclude(module: 'guava') + exclude(module: 'animal-sniffer-annotations') + } + implementation "org.slf4j:slf4j-api:$slf4jVersion" + implementation "ch.qos.logback:logback-core:$logbackVersion" + implementation "ch.qos.logback:logback-classic:$logbackVersion" compileOnly "org.projectlombok:lombok:$lombokVersion" annotationProcessor "org.projectlombok:lombok:$lombokVersion" } @@ -355,6 +381,7 @@ configure(project(':desktop')) { compile "de.jensd:fontawesomefx:$fontawesomefxVersion" compile "de.jensd:fontawesomefx-commons:$fontawesomefxCommonsVersion" compile "de.jensd:fontawesomefx-materialdesignfont:$fontawesomefxMaterialdesignfontVersion" + compile "com.google.guava:guava:$guavaVersion" compile "com.googlecode.jcsv:jcsv:$jcsvVersion" compile "com.github.sarxos:webcam-capture:$sarxosVersion" compile "org.openjfx:javafx-controls:$javafxVersion:$os" @@ -418,8 +445,8 @@ configure(project(':pricenode')) { dependencies { compile project(":core") implementation "commons-codec:commons-codec:$codecVersion" - implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion" - implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") { + implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion" + implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") { exclude(module: 'commons-codec') } compile("org.knowm.xchange:xchange-bitcoinaverage:$knowmXchangeVersion") @@ -441,12 +468,12 @@ configure(project(':relay')) { dependencies { compile project(':common') compile "com.sparkjava:spark-core:$sparkVersion" - compile "com.turo:pushy:$pushyVersion" + compile "com.turo:pushy:$pushyVersion" implementation("com.google.firebase:firebase-admin:$firebaseVersion") { exclude(module: 'commons-logging') exclude(module: 'httpclient') - exclude(module: 'httpcore') - } + exclude(module: 'httpcore') + } compile "commons-codec:commons-codec:$codecVersion" } } @@ -481,8 +508,21 @@ configure(project(':daemon')) { dependencies { compile project(':core') + implementation "com.google.guava:guava:$guavaVersion" + implementation "com.google.protobuf:protobuf-java:$protobufVersion" + implementation("io.grpc:grpc-protobuf:$grpcVersion") { + exclude(module: 'guava') + exclude(module: 'animal-sniffer-annotations') + } + implementation("io.grpc:grpc-stub:$grpcVersion") { + exclude(module: 'guava') + exclude(module: 'animal-sniffer-annotations') + } + implementation "org.slf4j:slf4j-api:$slf4jVersion" + implementation "ch.qos.logback:logback-core:$logbackVersion" + implementation "ch.qos.logback:logback-classic:$logbackVersion" compileOnly "org.projectlombok:lombok:$lombokVersion" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion" annotationProcessor "org.projectlombok:lombok:$lombokVersion" } } diff --git a/cli/src/main/java/bisq/cli/app/BisqCliMain.java b/cli/src/main/java/bisq/cli/app/BisqCliMain.java index 754a47fac43..5f1dec323e3 100644 --- a/cli/src/main/java/bisq/cli/app/BisqCliMain.java +++ b/cli/src/main/java/bisq/cli/app/BisqCliMain.java @@ -17,150 +17,65 @@ package bisq.cli.app; -import bisq.core.grpc.GetBalanceGrpc; -import bisq.core.grpc.GetBalanceRequest; -import bisq.core.grpc.GetOffersGrpc; -import bisq.core.grpc.GetOffersRequest; -import bisq.core.grpc.GetPaymentAccountsGrpc; -import bisq.core.grpc.GetPaymentAccountsRequest; -import bisq.core.grpc.GetTradeStatisticsGrpc; -import bisq.core.grpc.GetTradeStatisticsRequest; -import bisq.core.grpc.GetVersionGrpc; -import bisq.core.grpc.GetVersionRequest; -import bisq.core.grpc.PlaceOfferGrpc; -import bisq.core.grpc.PlaceOfferRequest; -import bisq.core.grpc.StopServerGrpc; -import bisq.core.grpc.StopServerRequest; -import bisq.core.payment.PaymentAccount; -import bisq.core.proto.network.CoreNetworkProtoResolver; -import bisq.core.proto.persistable.CorePersistenceProtoResolver; - import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; -import io.grpc.StatusRuntimeException; - -import org.bitcoinj.core.Coin; - -import java.time.Clock; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; -import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; +import static java.lang.System.currentTimeMillis; +import static java.lang.System.exit; +import static java.lang.System.in; /** * gRPC client. - * - * FIXME We get warning 'DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - direct buffer constructor: unavailable - * java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled' which is - * related to Java 10 changes. Requests are working but we should find out why we get that warning */ @Slf4j public class BisqCliMain { private final ManagedChannel channel; - private final GetVersionGrpc.GetVersionBlockingStub getVersionStub; - private final GetBalanceGrpc.GetBalanceBlockingStub getBalanceStub; - private final StopServerGrpc.StopServerBlockingStub stopServerStub; - private final GetTradeStatisticsGrpc.GetTradeStatisticsBlockingStub getTradeStatisticsStub; - private final GetOffersGrpc.GetOffersBlockingStub getOffersStub; - private final GetPaymentAccountsGrpc.GetPaymentAccountsBlockingStub getPaymentAccountsStub; - private final PlaceOfferGrpc.PlaceOfferBlockingStub placeOfferBlockingStub; - private final CorePersistenceProtoResolver corePersistenceProtoResolver; + private final CliCommand cmd; - public static void main(String[] args) throws Exception { + public static void main(String[] args) { new BisqCliMain("localhost", 8888); } private BisqCliMain(String host, int port) { - this(ManagedChannelBuilder.forAddress(host, port) - // Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid - // needing certificates. - .usePlaintext(true).build()); + // Channels are secure by default (via SSL/TLS); for the example disable TLS to avoid needing certificates. + this(ManagedChannelBuilder.forAddress(host, port).usePlaintext().build()); // Simple input scanner // TODO use some more sophisticated input processing with validation.... - try (Scanner scanner = new Scanner(System.in);) { + try (Scanner scanner = new Scanner(in)) { while (true) { - long startTs = System.currentTimeMillis(); + long startTs = currentTimeMillis(); String[] tokens = scanner.nextLine().split(" "); if (tokens.length == 0) { return; } String command = tokens[0]; - List params = new ArrayList<>(); if (tokens.length > 1) { - params.addAll(Arrays.asList(tokens)); + List params = new ArrayList<>(Arrays.asList(tokens)); params.remove(0); } - String result = ""; + String result; switch (command) { - case "getVersion": - result = getVersion(); - break; case "getBalance": - result = Coin.valueOf(getBalance()).toFriendlyString(); - break; - case "getTradeStatistics": - List tradeStatistics = getTradeStatistics().stream() - .map(bisq.core.trade.statistics.TradeStatistics2::fromProto) - .collect(Collectors.toList()); - - result = tradeStatistics.toString(); - break; - case "getOffers": - List offers = getOffers().stream() - .map(bisq.core.offer.Offer::fromProto) - .collect(Collectors.toList()); - result = offers.toString(); + long satoshis = cmd.getBalance(); + // TODO mimic bitcoin-cli? Depends on an error code: Loading block index... Verifying blocks... + result = satoshis == -1 ? "Server initializing..." : cmd.prettyBalance.apply(satoshis); break; - case "getPaymentAccounts": - List paymentAccounts = getPaymentAccounts().stream() - .map(proto -> PaymentAccount.fromProto(proto, corePersistenceProtoResolver)) - .collect(Collectors.toList()); - result = paymentAccounts.toString(); + case "getVersion": + result = cmd.getVersion(); break; - case "placeOffer": - // test input: placeOffer CNY BUY 750000000 true -0.2251 1000000 500000 0.15 5a972121-c30a-4b0e-b519-b17b63795d16 - // payment accountId and currency need to be adopted - - // We expect 9 params - // TODO add basic input validation - try { - checkArgument(params.size() == 9); - String currencyCode = params.get(0); - String directionAsString = params.get(1); - long priceAsLong = Long.parseLong(params.get(2)); - boolean useMarketBasedPrice = Boolean.parseBoolean(params.get(3)); - double marketPriceMargin = Double.parseDouble(params.get(4)); - long amountAsLong = Long.parseLong(params.get(5)); - long minAmountAsLong = Long.parseLong(params.get(6)); - double buyerSecurityDeposit = Double.parseDouble(params.get(7)); - String paymentAccountId = params.get(8); - boolean success = placeOffer(currencyCode, - directionAsString, - priceAsLong, - useMarketBasedPrice, - marketPriceMargin, - amountAsLong, - minAmountAsLong, - buyerSecurityDeposit, - paymentAccountId); - result = String.valueOf(success); - break; - } catch (Throwable t) { - log.error(t.toString(), t); - break; - } case "stop": result = "Shut down client"; try { @@ -170,7 +85,7 @@ private BisqCliMain(String host, int port) { } break; case "stopServer": - stopServer(); + cmd.stopServer(); result = "Server stopped"; break; default: @@ -178,8 +93,7 @@ private BisqCliMain(String host, int port) { } // First response is rather slow (300 ms) but following responses are fast (3-5 ms). - log.info("Request took: {} ms", System.currentTimeMillis() - startTs); - log.info(result); + log.info("{}\t{}", result, cmd.responseTime.apply(startTs)); } } } @@ -189,108 +103,11 @@ private BisqCliMain(String host, int port) { */ private BisqCliMain(ManagedChannel channel) { this.channel = channel; - - getVersionStub = GetVersionGrpc.newBlockingStub(channel); - getBalanceStub = GetBalanceGrpc.newBlockingStub(channel); - getTradeStatisticsStub = GetTradeStatisticsGrpc.newBlockingStub(channel); - getOffersStub = GetOffersGrpc.newBlockingStub(channel); - getPaymentAccountsStub = GetPaymentAccountsGrpc.newBlockingStub(channel); - placeOfferBlockingStub = PlaceOfferGrpc.newBlockingStub(channel); - stopServerStub = StopServerGrpc.newBlockingStub(channel); - - CoreNetworkProtoResolver coreNetworkProtoResolver = new CoreNetworkProtoResolver(Clock.systemDefaultZone()); - //TODO - corePersistenceProtoResolver = new CorePersistenceProtoResolver(null, coreNetworkProtoResolver, null, null); - } - - private String getVersion() { - GetVersionRequest request = GetVersionRequest.newBuilder().build(); - try { - return getVersionStub.getVersion(request).getVersion(); - } catch (StatusRuntimeException e) { - return "RPC failed: " + e.getStatus(); - } - } - - private long getBalance() { - GetBalanceRequest request = GetBalanceRequest.newBuilder().build(); - try { - return getBalanceStub.getBalance(request).getBalance(); - } catch (StatusRuntimeException e) { - log.warn("RPC failed: {}", e.getStatus()); - return -1; - } - } - - private List getTradeStatistics() { - GetTradeStatisticsRequest request = GetTradeStatisticsRequest.newBuilder().build(); - try { - return getTradeStatisticsStub.getTradeStatistics(request).getTradeStatisticsList(); - } catch (StatusRuntimeException e) { - log.warn("RPC failed: {}", e.getStatus()); - return null; - } - } - - private List getOffers() { - GetOffersRequest request = GetOffersRequest.newBuilder().build(); - try { - return getOffersStub.getOffers(request).getOffersList(); - } catch (StatusRuntimeException e) { - log.warn("RPC failed: {}", e.getStatus()); - return null; - } - } - - private List getPaymentAccounts() { - GetPaymentAccountsRequest request = GetPaymentAccountsRequest.newBuilder().build(); - try { - return getPaymentAccountsStub.getPaymentAccounts(request).getPaymentAccountsList(); - } catch (StatusRuntimeException e) { - log.warn("RPC failed: {}", e.getStatus()); - return null; - } - } - - private boolean placeOffer(String currencyCode, - String directionAsString, - long priceAsLong, - boolean useMarketBasedPrice, - double marketPriceMargin, - long amountAsLong, - long minAmountAsLong, - double buyerSecurityDeposit, - String paymentAccountId) { - PlaceOfferRequest request = PlaceOfferRequest.newBuilder() - .setCurrencyCode(currencyCode) - .setDirection(directionAsString) - .setPrice(priceAsLong) - .setUseMarketBasedPrice(useMarketBasedPrice) - .setMarketPriceMargin(marketPriceMargin) - .setAmount(amountAsLong) - .setMinAmount(minAmountAsLong) - .setBuyerSecurityDeposit(buyerSecurityDeposit) - .setPaymentAccountId(paymentAccountId) - .build(); - try { - return placeOfferBlockingStub.placeOffer(request).getResult(); - } catch (StatusRuntimeException e) { - log.warn("RPC failed: {}", e.getStatus()); - return false; - } - } - - private void stopServer() { - StopServerRequest request = StopServerRequest.newBuilder().build(); - try { - stopServerStub.stopServer(request); - } catch (StatusRuntimeException e) { - log.warn("RPC failed: {}", e.getStatus()); - } + this.cmd = new CliCommand(channel); } private void shutdown() throws InterruptedException { channel.shutdown().awaitTermination(1, TimeUnit.SECONDS); - System.exit(0); + exit(0); } } diff --git a/cli/src/main/java/bisq/cli/app/CliCommand.java b/cli/src/main/java/bisq/cli/app/CliCommand.java new file mode 100644 index 00000000000..f40a39c673c --- /dev/null +++ b/cli/src/main/java/bisq/cli/app/CliCommand.java @@ -0,0 +1,70 @@ +package bisq.cli.app; + +import bisq.proto.grpc.GetBalanceGrpc; +import bisq.proto.grpc.GetBalanceRequest; +import bisq.proto.grpc.GetVersionGrpc; +import bisq.proto.grpc.GetVersionRequest; +import bisq.proto.grpc.StopServerGrpc; +import bisq.proto.grpc.StopServerRequest; + +import io.grpc.ManagedChannel; +import io.grpc.StatusRuntimeException; + +import java.text.DecimalFormat; + +import java.math.BigDecimal; + +import java.util.function.Function; + +import lombok.extern.slf4j.Slf4j; + +import static java.lang.System.currentTimeMillis; + +@Slf4j +final class CliCommand { + + private final GetBalanceGrpc.GetBalanceBlockingStub getBalanceStub; + private final GetVersionGrpc.GetVersionBlockingStub getVersionStub; + private final StopServerGrpc.StopServerBlockingStub stopServerStub; + + private final DecimalFormat btcFormat = new DecimalFormat("###,##0.00000000"); + private final BigDecimal satoshiDivisor = new BigDecimal(100000000); + @SuppressWarnings("BigDecimalMethodWithoutRoundingCalled") + final Function prettyBalance = (sats) -> btcFormat.format(BigDecimal.valueOf(sats).divide(satoshiDivisor)); + + final Function responseTime = (t0) -> "(response time: " + (currentTimeMillis() - t0) + " ms)"; + + CliCommand(ManagedChannel channel) { + getBalanceStub = GetBalanceGrpc.newBlockingStub(channel); + getVersionStub = GetVersionGrpc.newBlockingStub(channel); + stopServerStub = StopServerGrpc.newBlockingStub(channel); + } + + String getVersion() { + GetVersionRequest request = GetVersionRequest.newBuilder().build(); + try { + return getVersionStub.getVersion(request).getVersion(); + } catch (StatusRuntimeException e) { + return "RPC failed: " + e.getStatus(); + } + } + + long getBalance() { + GetBalanceRequest request = GetBalanceRequest.newBuilder().build(); + try { + return getBalanceStub.getBalance(request).getBalance(); + } catch (StatusRuntimeException e) { + log.warn("RPC failed: {}", e.getStatus()); + return -1; + } + } + + void stopServer() { + StopServerRequest request = StopServerRequest.newBuilder().build(); + try { + stopServerStub.stopServer(request); + } catch (StatusRuntimeException e) { + log.warn("RPC failed: {}", e.getStatus()); + } + } +} diff --git a/cli/src/main/resources/logback.xml b/cli/src/main/resources/logback.xml new file mode 100644 index 00000000000..c5b1fcf9aa3 --- /dev/null +++ b/cli/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + + + %highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{30}: %msg %xEx%n) + + + + + + + + + + + + diff --git a/core/src/main/java/bisq/core/grpc/BisqGrpcServer.java b/core/src/main/java/bisq/core/grpc/BisqGrpcServer.java index 55db5011175..fc6a09726a7 100644 --- a/core/src/main/java/bisq/core/grpc/BisqGrpcServer.java +++ b/core/src/main/java/bisq/core/grpc/BisqGrpcServer.java @@ -22,6 +22,28 @@ import bisq.core.trade.handlers.TransactionResultHandler; import bisq.core.trade.statistics.TradeStatistics2; +import bisq.proto.grpc.GetBalanceGrpc; +import bisq.proto.grpc.GetBalanceReply; +import bisq.proto.grpc.GetBalanceRequest; +import bisq.proto.grpc.GetOffersGrpc; +import bisq.proto.grpc.GetOffersReply; +import bisq.proto.grpc.GetOffersRequest; +import bisq.proto.grpc.GetPaymentAccountsGrpc; +import bisq.proto.grpc.GetPaymentAccountsReply; +import bisq.proto.grpc.GetPaymentAccountsRequest; +import bisq.proto.grpc.GetTradeStatisticsGrpc; +import bisq.proto.grpc.GetTradeStatisticsReply; +import bisq.proto.grpc.GetTradeStatisticsRequest; +import bisq.proto.grpc.GetVersionGrpc; +import bisq.proto.grpc.GetVersionReply; +import bisq.proto.grpc.GetVersionRequest; +import bisq.proto.grpc.PlaceOfferGrpc; +import bisq.proto.grpc.PlaceOfferReply; +import bisq.proto.grpc.PlaceOfferRequest; +import bisq.proto.grpc.StopServerGrpc; +import bisq.proto.grpc.StopServerReply; +import bisq.proto.grpc.StopServerRequest; + import io.grpc.Server; import io.grpc.ServerBuilder; import io.grpc.stub.StreamObserver; diff --git a/core/src/test/java/bisq/core/util/ProtoUtilTest.java b/core/src/test/java/bisq/core/util/ProtoUtilTest.java index f982ab122b1..dee3b4a2490 100644 --- a/core/src/test/java/bisq/core/util/ProtoUtilTest.java +++ b/core/src/test/java/bisq/core/util/ProtoUtilTest.java @@ -21,15 +21,13 @@ import bisq.common.proto.ProtoUtil; +import protobuf.OfferPayload; + import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; - - -import protobuf.OfferPayload; - @SuppressWarnings("UnusedAssignment") public class ProtoUtilTest { diff --git a/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java b/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java index 292eeaf01b7..bcdd930d006 100644 --- a/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java +++ b/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java @@ -37,7 +37,7 @@ @Slf4j public class BisqDaemonMain extends BisqHeadlessAppMain implements BisqSetup.BisqSetupListener { - public static void main(String[] args) throws Exception { + public static void main(String[] args) { new BisqDaemonMain().execute(args); } diff --git a/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetUpdatedDataRequest.java b/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetUpdatedDataRequest.java index eae85f6edef..0539fa02bc6 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetUpdatedDataRequest.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetUpdatedDataRequest.java @@ -23,6 +23,8 @@ import bisq.common.app.Version; import bisq.common.proto.ProtoUtil; +import protobuf.NetworkEnvelope; + import com.google.protobuf.ByteString; import java.util.Set; @@ -34,10 +36,6 @@ import static com.google.common.base.Preconditions.checkNotNull; - - -import protobuf.NetworkEnvelope; - @Slf4j @EqualsAndHashCode(callSuper = true) @Value diff --git a/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/PreliminaryGetDataRequest.java b/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/PreliminaryGetDataRequest.java index db0e51eb7f6..a47a2f86054 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/PreliminaryGetDataRequest.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/PreliminaryGetDataRequest.java @@ -24,6 +24,8 @@ import bisq.common.app.Version; import bisq.common.proto.ProtoUtil; +import protobuf.NetworkEnvelope; + import com.google.protobuf.ByteString; import java.util.Set; @@ -35,8 +37,6 @@ import org.jetbrains.annotations.NotNull; -import protobuf.NetworkEnvelope; - @Slf4j @EqualsAndHashCode(callSuper = true) @Value diff --git a/core/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto similarity index 91% rename from core/src/main/proto/grpc.proto rename to proto/src/main/proto/grpc.proto index 33957fb4124..6a013daa8b1 100644 --- a/core/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -18,10 +18,9 @@ syntax = "proto3"; package io.bisq.protobuffer; -// FIXME: IntelliJ does not recognize the import but the compiler does import "pb.proto"; -option java_package = "bisq.core.grpc"; +option java_package = "bisq.proto.grpc"; option java_multiple_files = true; /////////////////////////////////////////////////////////////////////////////////////////// @@ -68,7 +67,6 @@ service GetTradeStatistics { message GetTradeStatisticsRequest { } -// FIXME: IntelliJ does not recognize the imported TradeStatistics2 but the compiler does message GetTradeStatisticsReply { repeated TradeStatistics2 TradeStatistics = 1; } @@ -85,7 +83,6 @@ service GetOffers { message GetOffersRequest { } -// FIXME: IntelliJ does not recognize the imported Offer but the compiler does message GetOffersReply { repeated Offer offers = 1; } @@ -102,7 +99,6 @@ service GetPaymentAccounts { message GetPaymentAccountsRequest { } -// FIXME: IntelliJ does not recognize the imported PaymentAccount but the compiler does message GetPaymentAccountsReply { repeated PaymentAccount paymentAccounts = 1; } diff --git a/common/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto similarity index 100% rename from common/src/main/proto/pb.proto rename to proto/src/main/proto/pb.proto diff --git a/settings.gradle b/settings.gradle index b12eb486d4d..cdfa7c7126a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ +include 'proto' include 'assets' include 'common' include 'p2p'