Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always include high prio payload in get data response #6501

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,27 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.common.proto.network;

/**
* Represents priority used at truncating data set at getDataResponse if total data exceeds limits.
*/
public enum GetDataResponsePriority {
LOW,
MID,
HIGH
}
Expand Up @@ -23,4 +23,7 @@
* Interface for objects used inside WireEnvelope or other WirePayloads.
*/
public interface NetworkPayload extends Payload {
default GetDataResponsePriority getGetDataResponsePriority() {
return GetDataResponsePriority.LOW;
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/bisq/core/account/sign/SignedWitness.java
Expand Up @@ -27,6 +27,7 @@
import bisq.common.app.Capability;
import bisq.common.crypto.Hash;
import bisq.common.proto.ProtoUtil;
import bisq.common.proto.network.GetDataResponsePriority;
import bisq.common.util.Utilities;

import com.google.protobuf.ByteString;
Expand Down Expand Up @@ -137,6 +138,11 @@ public static SignedWitness fromProto(protobuf.SignedWitness proto) {
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public GetDataResponsePriority getGetDataResponsePriority() {
return GetDataResponsePriority.MID;
}

@Override
public boolean isDateInTolerance(Clock clock) {
// We don't allow older or newer than 1 day.
Expand Down
Expand Up @@ -22,6 +22,7 @@
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload;

import bisq.common.proto.network.GetDataResponsePriority;
import bisq.common.util.Utilities;

import com.google.protobuf.ByteString;
Expand Down Expand Up @@ -84,6 +85,11 @@ public static AccountAgeWitness fromProto(protobuf.AccountAgeWitness proto) {
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public GetDataResponsePriority getGetDataResponsePriority() {
return GetDataResponsePriority.MID;
}

@Override
public boolean isDateInTolerance(Clock clock) {
// We don't allow older or newer than 1 day.
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/bisq/core/alert/Alert.java
Expand Up @@ -24,6 +24,7 @@

import bisq.common.app.Version;
import bisq.common.crypto.Sig;
import bisq.common.proto.network.GetDataResponsePriority;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;

Expand Down Expand Up @@ -140,6 +141,11 @@ public static Alert fromProto(protobuf.Alert proto) {
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public GetDataResponsePriority getGetDataResponsePriority() {
return GetDataResponsePriority.HIGH;
}

@Override
public long getTTL() {
return TTL;
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/bisq/core/filter/Filter.java
Expand Up @@ -22,6 +22,7 @@

import bisq.common.crypto.Sig;
import bisq.common.proto.ProtoUtil;
import bisq.common.proto.network.GetDataResponsePriority;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import bisq.common.util.Utilities;
Expand Down Expand Up @@ -445,6 +446,11 @@ public static Filter fromProto(protobuf.Filter proto) {
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public GetDataResponsePriority getGetDataResponsePriority() {
return GetDataResponsePriority.HIGH;
}

@Override
public long getTTL() {
return TTL;
Expand Down
Expand Up @@ -22,6 +22,7 @@
import bisq.network.p2p.storage.payload.ProtectedStoragePayload;

import bisq.common.crypto.PubKeyRing;
import bisq.common.proto.network.GetDataResponsePriority;
import bisq.common.util.ExtraDataMapValidator;
import bisq.common.util.Utilities;

Expand Down Expand Up @@ -85,6 +86,11 @@ public DisputeAgent(NodeAddress nodeAddress,
// API
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public GetDataResponsePriority getGetDataResponsePriority() {
return GetDataResponsePriority.HIGH;
}

@Override
public long getTTL() {
return TTL;
Expand Down
9 changes: 0 additions & 9 deletions p2p/src/main/java/bisq/network/p2p/peers/Broadcaster.java
Expand Up @@ -38,7 +38,6 @@
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import lombok.Value;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -119,21 +118,13 @@ public void broadcast(BroadcastMessage message,
@Nullable NodeAddress sender,
@Nullable BroadcastHandler.Listener listener) {
broadcastRequests.add(new BroadcastRequest(message, sender, listener));
// Keep that log on INFO for better debugging if the feature works as expected. Later it can
// be remove or set to DEBUG
log.debug("Broadcast requested for {}. We queue it up for next bundled broadcast.",
message.getClass().getSimpleName());

if (timer == null) {
timer = UserThread.runAfter(this::maybeBroadcastBundle, BROADCAST_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
}

private void maybeBroadcastBundle() {
if (!broadcastRequests.isEmpty()) {
log.debug("Broadcast bundled requests of {} messages. Message types: {}",
broadcastRequests.size(),
broadcastRequests.stream().map(e -> e.getMessage().getClass().getSimpleName()).collect(Collectors.toList()));
BroadcastHandler broadcastHandler = new BroadcastHandler(networkNode, peerManager, this);
broadcastHandlers.add(broadcastHandler);
broadcastHandler.broadcast(new ArrayList<>(broadcastRequests), shutDownRequested, executor);
Expand Down
Expand Up @@ -98,11 +98,11 @@ public void handle(GetDataRequest getDataRequest, final Connection connection) {
connection.getCapabilities());

if (wasPersistableNetworkPayloadsTruncated.get()) {
log.warn("The getDataResponse for peer {} got truncated.", connectionInfo);
log.info("The getDataResponse for peer {} got truncated.", connectionInfo);
}

if (wasProtectedStorageEntriesTruncated.get()) {
log.warn("The getDataResponse for peer {} got truncated.", connectionInfo);
log.info("The getDataResponse for peer {} got truncated.", connectionInfo);
}

log.info("The getDataResponse to peer with {} contains {} ProtectedStorageEntries and {} PersistableNetworkPayloads",
Expand Down