Skip to content

Commit

Permalink
Disconnect nodes at RequestDataManager.onMessage < 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chimp1984 authored and ripcurlx committed Dec 30, 2020
1 parent e92be14 commit a81188e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.Version;
import bisq.common.proto.network.NetworkEnvelope;

import javax.inject.Inject;
Expand All @@ -56,9 +57,9 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
private static final long RETRY_DELAY_SEC = 10;
private static final long CLEANUP_TIMER = 120;
// How many seeds we request the PreliminaryGetDataRequest from
private static int NUM_SEEDS_FOR_PRELIMINARY_REQUEST = 2;
private static int NUM_SEEDS_FOR_PRELIMINARY_REQUEST = 16;
// how many seeds additional to the first responding PreliminaryGetDataRequest seed we request the GetUpdatedDataRequest from
private static int NUM_ADDITIONAL_SEEDS_FOR_UPDATE_REQUEST = 1;
private static int NUM_ADDITIONAL_SEEDS_FOR_UPDATE_REQUEST = 16;
private boolean isPreliminaryDataRequest = true;

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -261,6 +262,11 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) {
if (peerManager.isSeedNode(connection))
connection.setPeerType(Connection.PeerType.SEED_NODE);

GetDataRequest getDataRequest = (GetDataRequest) networkEnvelope;
if (getDataRequest.getVersion() == null || !Version.isNewVersion(getDataRequest.getVersion(), "1.5.0")) {
connection.shutDown(CloseConnectionReason.MANDATORY_CAPABILITIES_NOT_SUPPORTED);
return;
}
final String uid = connection.getUid();
if (!getDataRequestHandlers.containsKey(uid)) {
GetDataRequestHandler getDataRequestHandler = new GetDataRequestHandler(networkNode, dataStorage,
Expand All @@ -284,7 +290,7 @@ public void onFault(String errorMessage, @Nullable Connection connection) {
}
});
getDataRequestHandlers.put(uid, getDataRequestHandler);
getDataRequestHandler.handle((GetDataRequest) networkEnvelope, connection);
getDataRequestHandler.handle(getDataRequest, connection);
} else {
log.warn("We have already a GetDataRequestHandler for that connection started. " +
"We start a cleanup timer if the handler has not closed by itself in between 2 minutes.");
Expand Down

0 comments on commit a81188e

Please sign in to comment.