From d0397c1c621cebec4a94e7a2cd4cbc690544b660 Mon Sep 17 00:00:00 2001
From: ghubstan <36207203+ghubstan@users.noreply.github.com>
Date: Mon, 24 Aug 2020 15:09:15 -0300
Subject: [PATCH] Move gRPC boilerplate from :core to :daemon
This change moves gRPC boilerplate classes from the :core.grpc pkg
into a new :daemon.grpc pkg.
* The :core.grpc pkg was renamed :core.api, and no longer has any
dependencies on gRPC libraries.
* All core service classes in the :core.api pkg are now package
protected, excepting CoreApi, making CoreApi the only possible
entry point for all Grpc*Service -> -Core*Service calls.
* All grpc service classes in the :daemon.grpc pkg are now package
protected, excepting GrpcServer; the only class depending on
Grpc*Service class is GrpcServer.
* gRPC dependencies were moved from the gradle.build file's :core
subproject to :daemon.
---
build.gradle | 17 ++++-------------
.../java/bisq/core/{grpc => api}/CoreApi.java | 4 ++--
.../core/{grpc => api}/CoreOffersService.java | 4 ++--
.../CorePaymentAccountsService.java | 4 ++--
.../core/{grpc => api}/CoreWalletsService.java | 4 ++--
.../{grpc => api}/model/AddressBalanceInfo.java | 2 +-
.../core/{grpc => api}/model/OfferInfo.java | 2 +-
.../java/bisq/daemon/app/BisqDaemonMain.java | 8 +++++---
.../bisq/daemon}/grpc/GrpcOffersService.java | 5 +++--
.../grpc/GrpcPaymentAccountsService.java | 5 +++--
.../main/java/bisq/daemon}/grpc/GrpcServer.java | 3 ++-
.../bisq/daemon}/grpc/GrpcWalletsService.java | 5 +++--
.../daemon}/grpc/PasswordAuthInterceptor.java | 2 +-
13 files changed, 31 insertions(+), 34 deletions(-)
rename core/src/main/java/bisq/core/{grpc => api}/CoreApi.java (98%)
rename core/src/main/java/bisq/core/{grpc => api}/CoreOffersService.java (98%)
rename core/src/main/java/bisq/core/{grpc => api}/CorePaymentAccountsService.java (97%)
rename core/src/main/java/bisq/core/{grpc => api}/CoreWalletsService.java (99%)
rename core/src/main/java/bisq/core/{grpc => api}/model/AddressBalanceInfo.java (98%)
rename core/src/main/java/bisq/core/{grpc => api}/model/OfferInfo.java (99%)
rename {core/src/main/java/bisq/core => daemon/src/main/java/bisq/daemon}/grpc/GrpcOffersService.java (97%)
rename {core/src/main/java/bisq/core => daemon/src/main/java/bisq/daemon}/grpc/GrpcPaymentAccountsService.java (93%)
rename {core/src/main/java/bisq/core => daemon/src/main/java/bisq/daemon}/grpc/GrpcServer.java (98%)
rename {core/src/main/java/bisq/core => daemon/src/main/java/bisq/daemon}/grpc/GrpcWalletsService.java (98%)
rename {core/src/main/java/bisq/core => daemon/src/main/java/bisq/daemon}/grpc/PasswordAuthInterceptor.java (98%)
diff --git a/build.gradle b/build.gradle
index 46a9d969361..ab86fc152aa 100644
--- a/build.gradle
+++ b/build.gradle
@@ -328,19 +328,6 @@ configure(project(':core')) {
exclude(module: 'jackson-annotations')
}
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')
- }
- compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
- runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") {
- exclude(module: 'guava')
- exclude(module: 'animal-sniffer-annotations')
- }
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
@@ -577,6 +564,10 @@ configure(project(':daemon')) {
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"
diff --git a/core/src/main/java/bisq/core/grpc/CoreApi.java b/core/src/main/java/bisq/core/api/CoreApi.java
similarity index 98%
rename from core/src/main/java/bisq/core/grpc/CoreApi.java
rename to core/src/main/java/bisq/core/api/CoreApi.java
index 88302a82d2a..7041404ce51 100644
--- a/core/src/main/java/bisq/core/grpc/CoreApi.java
+++ b/core/src/main/java/bisq/core/api/CoreApi.java
@@ -15,9 +15,9 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.core.api;
-import bisq.core.grpc.model.AddressBalanceInfo;
+import bisq.core.api.model.AddressBalanceInfo;
import bisq.core.monetary.Price;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferPayload;
diff --git a/core/src/main/java/bisq/core/grpc/CoreOffersService.java b/core/src/main/java/bisq/core/api/CoreOffersService.java
similarity index 98%
rename from core/src/main/java/bisq/core/grpc/CoreOffersService.java
rename to core/src/main/java/bisq/core/api/CoreOffersService.java
index 35136ec1c5f..c5fac7442af 100644
--- a/core/src/main/java/bisq/core/grpc/CoreOffersService.java
+++ b/core/src/main/java/bisq/core/api/CoreOffersService.java
@@ -15,7 +15,7 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.core.api;
import bisq.core.monetary.Price;
import bisq.core.offer.CreateOfferService;
@@ -40,7 +40,7 @@
import static bisq.core.offer.OfferPayload.Direction.BUY;
@Slf4j
-public class CoreOffersService {
+class CoreOffersService {
private final CreateOfferService createOfferService;
private final OfferBookService offerBookService;
diff --git a/core/src/main/java/bisq/core/grpc/CorePaymentAccountsService.java b/core/src/main/java/bisq/core/api/CorePaymentAccountsService.java
similarity index 97%
rename from core/src/main/java/bisq/core/grpc/CorePaymentAccountsService.java
rename to core/src/main/java/bisq/core/api/CorePaymentAccountsService.java
index 9a7183d21ab..f40c56c20d7 100644
--- a/core/src/main/java/bisq/core/grpc/CorePaymentAccountsService.java
+++ b/core/src/main/java/bisq/core/api/CorePaymentAccountsService.java
@@ -15,7 +15,7 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.core.api;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.FiatCurrency;
@@ -34,7 +34,7 @@
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class CorePaymentAccountsService {
+class CorePaymentAccountsService {
private final Config config;
private final AccountAgeWitnessService accountAgeWitnessService;
diff --git a/core/src/main/java/bisq/core/grpc/CoreWalletsService.java b/core/src/main/java/bisq/core/api/CoreWalletsService.java
similarity index 99%
rename from core/src/main/java/bisq/core/grpc/CoreWalletsService.java
rename to core/src/main/java/bisq/core/api/CoreWalletsService.java
index 1d3719558b7..10feea5b8e6 100644
--- a/core/src/main/java/bisq/core/grpc/CoreWalletsService.java
+++ b/core/src/main/java/bisq/core/api/CoreWalletsService.java
@@ -15,13 +15,13 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.core.api;
+import bisq.core.api.model.AddressBalanceInfo;
import bisq.core.btc.Balances;
import bisq.core.btc.model.AddressEntry;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.WalletsManager;
-import bisq.core.grpc.model.AddressBalanceInfo;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.TransactionConfidence;
diff --git a/core/src/main/java/bisq/core/grpc/model/AddressBalanceInfo.java b/core/src/main/java/bisq/core/api/model/AddressBalanceInfo.java
similarity index 98%
rename from core/src/main/java/bisq/core/grpc/model/AddressBalanceInfo.java
rename to core/src/main/java/bisq/core/api/model/AddressBalanceInfo.java
index dd9ed19f90e..a9da82a917f 100644
--- a/core/src/main/java/bisq/core/grpc/model/AddressBalanceInfo.java
+++ b/core/src/main/java/bisq/core/api/model/AddressBalanceInfo.java
@@ -15,7 +15,7 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc.model;
+package bisq.core.api.model;
import bisq.common.Payload;
diff --git a/core/src/main/java/bisq/core/grpc/model/OfferInfo.java b/core/src/main/java/bisq/core/api/model/OfferInfo.java
similarity index 99%
rename from core/src/main/java/bisq/core/grpc/model/OfferInfo.java
rename to core/src/main/java/bisq/core/api/model/OfferInfo.java
index 0b2dc5fe0cd..fa6f0c95ea6 100644
--- a/core/src/main/java/bisq/core/grpc/model/OfferInfo.java
+++ b/core/src/main/java/bisq/core/api/model/OfferInfo.java
@@ -15,7 +15,7 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc.model;
+package bisq.core.api.model;
import bisq.common.Payload;
diff --git a/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java b/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java
index 64b5bcfc331..f7a5dac3d6b 100644
--- a/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java
+++ b/daemon/src/main/java/bisq/daemon/app/BisqDaemonMain.java
@@ -20,7 +20,6 @@
import bisq.core.app.BisqHeadlessAppMain;
import bisq.core.app.BisqSetup;
import bisq.core.app.CoreModule;
-import bisq.core.grpc.GrpcServer;
import bisq.common.UserThread;
import bisq.common.app.AppModule;
@@ -33,10 +32,14 @@
import lombok.extern.slf4j.Slf4j;
+
+
+import bisq.daemon.grpc.GrpcServer;
+
@Slf4j
public class BisqDaemonMain extends BisqHeadlessAppMain implements BisqSetup.BisqSetupListener {
- public static void main(String[] args) {
+ public static void main(String[] args) {
new BisqDaemonMain().execute(args);
}
@@ -67,7 +70,6 @@ protected void onApplicationLaunched() {
headlessApp.setGracefulShutDownHandler(this);
}
-
///////////////////////////////////////////////////////////////////////////////////////////
// We continue with a series of synchronous execution tasks
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/core/src/main/java/bisq/core/grpc/GrpcOffersService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java
similarity index 97%
rename from core/src/main/java/bisq/core/grpc/GrpcOffersService.java
rename to daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java
index c0f90a8abb9..8a3fa548d92 100644
--- a/core/src/main/java/bisq/core/grpc/GrpcOffersService.java
+++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java
@@ -15,9 +15,10 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.daemon.grpc;
-import bisq.core.grpc.model.OfferInfo;
+import bisq.core.api.CoreApi;
+import bisq.core.api.model.OfferInfo;
import bisq.core.trade.handlers.TransactionResultHandler;
import bisq.proto.grpc.CreateOfferReply;
diff --git a/core/src/main/java/bisq/core/grpc/GrpcPaymentAccountsService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java
similarity index 93%
rename from core/src/main/java/bisq/core/grpc/GrpcPaymentAccountsService.java
rename to daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java
index 8388b85e3bc..e630b30fc50 100644
--- a/core/src/main/java/bisq/core/grpc/GrpcPaymentAccountsService.java
+++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java
@@ -15,8 +15,9 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.daemon.grpc;
+import bisq.core.api.CoreApi;
import bisq.core.payment.PaymentAccount;
import bisq.proto.grpc.CreatePaymentAccountReply;
@@ -32,7 +33,7 @@
import java.util.stream.Collectors;
-public class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImplBase {
+class GrpcPaymentAccountsService extends PaymentAccountsGrpc.PaymentAccountsImplBase {
private final CoreApi coreApi;
diff --git a/core/src/main/java/bisq/core/grpc/GrpcServer.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcServer.java
similarity index 98%
rename from core/src/main/java/bisq/core/grpc/GrpcServer.java
rename to daemon/src/main/java/bisq/daemon/grpc/GrpcServer.java
index 4b5d195a2e1..a1293dfa0ac 100644
--- a/core/src/main/java/bisq/core/grpc/GrpcServer.java
+++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcServer.java
@@ -15,8 +15,9 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.daemon.grpc;
+import bisq.core.api.CoreApi;
import bisq.core.trade.statistics.TradeStatistics2;
import bisq.common.config.Config;
diff --git a/core/src/main/java/bisq/core/grpc/GrpcWalletsService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java
similarity index 98%
rename from core/src/main/java/bisq/core/grpc/GrpcWalletsService.java
rename to daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java
index f57cb69afb7..04dd3460234 100644
--- a/core/src/main/java/bisq/core/grpc/GrpcWalletsService.java
+++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java
@@ -15,9 +15,10 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.daemon.grpc;
-import bisq.core.grpc.model.AddressBalanceInfo;
+import bisq.core.api.CoreApi;
+import bisq.core.api.model.AddressBalanceInfo;
import bisq.proto.grpc.GetAddressBalanceReply;
import bisq.proto.grpc.GetAddressBalanceRequest;
diff --git a/core/src/main/java/bisq/core/grpc/PasswordAuthInterceptor.java b/daemon/src/main/java/bisq/daemon/grpc/PasswordAuthInterceptor.java
similarity index 98%
rename from core/src/main/java/bisq/core/grpc/PasswordAuthInterceptor.java
rename to daemon/src/main/java/bisq/daemon/grpc/PasswordAuthInterceptor.java
index 291c09c5944..7798857dd2a 100644
--- a/core/src/main/java/bisq/core/grpc/PasswordAuthInterceptor.java
+++ b/daemon/src/main/java/bisq/daemon/grpc/PasswordAuthInterceptor.java
@@ -15,7 +15,7 @@
* along with Bisq. If not, see .
*/
-package bisq.core.grpc;
+package bisq.daemon.grpc;
import io.grpc.Metadata;
import io.grpc.ServerCall;