Merge pull request #2952 from freimair/envelope_of_envelopes

Envelope of envelopes #2
This commit is contained in:
Christoph Atteneder 2019-07-12 10:29:22 +02:00 committed by GitHub
commit d9e088f469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -33,5 +33,5 @@ public enum Capability {
ACK_MSG,
BSQ_BLOCK,
DAO_STATE,
ENVELOPE_OF_ENVELOPES
BUNDLE_OF_ENVELOPES
}

View File

@ -29,7 +29,7 @@ import lombok.extern.slf4j.Slf4j;
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);

View File

@ -285,7 +285,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
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
@ -299,7 +299,11 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
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);