From b44cb452f991ca1c3ee4edabe193d0cb5f368ab5 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 10 Jul 2019 16:31:58 +0200 Subject: [PATCH 1/2] Rename stuff --- common/src/main/java/bisq/common/app/Capability.java | 2 +- core/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java | 2 +- p2p/src/main/java/bisq/network/p2p/network/Connection.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/bisq/common/app/Capability.java b/common/src/main/java/bisq/common/app/Capability.java index dc15baaf24f..e01814fd35d 100644 --- a/common/src/main/java/bisq/common/app/Capability.java +++ b/common/src/main/java/bisq/common/app/Capability.java @@ -33,5 +33,5 @@ public enum Capability { ACK_MSG, BSQ_BLOCK, DAO_STATE, - ENVELOPE_OF_ENVELOPES + BUNDLE_OF_ENVELOPES } diff --git a/core/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java b/core/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java index e0e2bbaa9b9..b49cf9ac6b4 100644 --- a/core/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java +++ b/core/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java @@ -29,7 +29,7 @@ public class CoreNetworkCapabilities { public static void setSupportedCapabilities(BisqEnvironment bisqEnvironment) { Capabilities.app.addAll(Capability.TRADE_STATISTICS, Capability.TRADE_STATISTICS_2, Capability.ACCOUNT_AGE_WITNESS, Capability.ACK_MSG); - Capabilities.app.addAll(Capability.ENVELOPE_OF_ENVELOPES); + Capabilities.app.addAll(Capability.BUNDLE_OF_ENVELOPES); if (BisqEnvironment.isDaoActivated(bisqEnvironment)) { Capabilities.app.addAll(Capability.PROPOSAL, Capability.BLIND_VOTE, Capability.BSQ_BLOCK, Capability.DAO_STATE); diff --git a/p2p/src/main/java/bisq/network/p2p/network/Connection.java b/p2p/src/main/java/bisq/network/p2p/network/Connection.java index 3530a7f2f5f..49d5bf77e67 100644 --- a/p2p/src/main/java/bisq/network/p2p/network/Connection.java +++ b/p2p/src/main/java/bisq/network/p2p/network/Connection.java @@ -287,7 +287,7 @@ public void sendMessage(NetworkEnvelope networkEnvelope) { networkEnvelope.getClass().getSimpleName()); // check if BundleOfEnvelopes is supported - if (getCapabilities().containsAll(new Capabilities(Capability.ENVELOPE_OF_ENVELOPES))) { + if (getCapabilities().containsAll(new Capabilities(Capability.BUNDLE_OF_ENVELOPES))) { synchronized (lock) { // check if current envelope fits size // - no? create new envelope From 31a4ba3ff6f71d7d016ce8b50e81aa4898223026 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 10 Jul 2019 16:32:53 +0200 Subject: [PATCH 2/2] Only send bundle if necessary --- p2p/src/main/java/bisq/network/p2p/network/Connection.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/p2p/src/main/java/bisq/network/p2p/network/Connection.java b/p2p/src/main/java/bisq/network/p2p/network/Connection.java index 49d5bf77e67..9ae9e8b8853 100644 --- a/p2p/src/main/java/bisq/network/p2p/network/Connection.java +++ b/p2p/src/main/java/bisq/network/p2p/network/Connection.java @@ -301,7 +301,11 @@ public void sendMessage(NetworkEnvelope networkEnvelope) { bundleSender.schedule(() -> { if (!stopped) { synchronized (lock) { - protoOutputStream.writeEnvelope(queueOfBundles.poll()); + BundleOfEnvelopes current = queueOfBundles.poll(); + if(current.getEnvelopes().size() == 1) + protoOutputStream.writeEnvelope(current.getEnvelopes().get(0)); + else + protoOutputStream.writeEnvelope(current); } } }, lastSendTimeStamp - now, TimeUnit.MILLISECONDS);