Skip to content

Commit

Permalink
Merge pull request #2952 from freimair/envelope_of_envelopes
Browse files Browse the repository at this point in the history
Envelope of envelopes #2
  • Loading branch information
ripcurlx authored Jul 12, 2019
2 parents e2bb538 + 31a4ba3 commit d9e088f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/bisq/common/app/Capability.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ public enum Capability {
ACK_MSG,
BSQ_BLOCK,
DAO_STATE,
ENVELOPE_OF_ENVELOPES
BUNDLE_OF_ENVELOPES
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions p2p/src/main/java/bisq/network/p2p/network/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,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
Expand All @@ -299,7 +299,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);
Expand Down

0 comments on commit d9e088f

Please sign in to comment.