From 57f2b43845a1caf52f2215184a3f477dbff43d6a Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Thu, 6 Nov 2014 14:59:59 +0100 Subject: [PATCH] Extract isSuccess(BaseFuture) method into util class --- .../io/bitsquare/msg/TomP2PMessageFacade.java | 8 ++--- .../network/tomp2p/BaseFutureUtil.java | 29 +++++++++++++++++++ .../offer/TomP2POfferRepository.java | 8 ++--- 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 src/main/java/io/bitsquare/network/tomp2p/BaseFutureUtil.java diff --git a/src/main/java/io/bitsquare/msg/TomP2PMessageFacade.java b/src/main/java/io/bitsquare/msg/TomP2PMessageFacade.java index 0548e793c2..614586e053 100644 --- a/src/main/java/io/bitsquare/msg/TomP2PMessageFacade.java +++ b/src/main/java/io/bitsquare/msg/TomP2PMessageFacade.java @@ -53,6 +53,8 @@ import net.tomp2p.utils.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static io.bitsquare.network.tomp2p.BaseFutureUtil.isSuccess; + /** * That facade delivers direct messaging and DHT functionality from the TomP2P library @@ -280,12 +282,6 @@ class TomP2PMessageFacade implements MessageFacade { incomingMessageListeners.remove(listener); } - // Isolate the success handling as there is bug in port forwarding mode - private boolean isSuccess(BaseFuture baseFuture) { - // return baseFuture.isSuccess(); - return true; - } - /////////////////////////////////////////////////////////////////////////////////////////// // Incoming message handler /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/main/java/io/bitsquare/network/tomp2p/BaseFutureUtil.java b/src/main/java/io/bitsquare/network/tomp2p/BaseFutureUtil.java new file mode 100644 index 0000000000..7d35bfc73c --- /dev/null +++ b/src/main/java/io/bitsquare/network/tomp2p/BaseFutureUtil.java @@ -0,0 +1,29 @@ +/* + * This file is part of Bitsquare. + * + * Bitsquare 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. + * + * Bitsquare 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 Bitsquare. If not, see . + */ + +package io.bitsquare.network.tomp2p; + +import net.tomp2p.futures.BaseFuture; + +public class BaseFutureUtil { + + // Isolate the success handling as there is bug in port forwarding mode + public static boolean isSuccess(BaseFuture baseFuture) { + // return baseFuture.isSuccess(); + return true; + } +} diff --git a/src/main/java/io/bitsquare/offer/TomP2POfferRepository.java b/src/main/java/io/bitsquare/offer/TomP2POfferRepository.java index 6cd949b0d1..19fd758847 100644 --- a/src/main/java/io/bitsquare/offer/TomP2POfferRepository.java +++ b/src/main/java/io/bitsquare/offer/TomP2POfferRepository.java @@ -46,6 +46,8 @@ import net.tomp2p.storage.Data; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static io.bitsquare.network.tomp2p.BaseFutureUtil.isSuccess; + class TomP2POfferRepository implements OfferRepository { private static final Logger log = LoggerFactory.getLogger(TomP2POfferRepository.class); @@ -289,10 +291,4 @@ class TomP2POfferRepository implements OfferRepository { private Number160 getInvalidatedLocationKey(Number160 locationKey) { return Number160.createHash(locationKey + "invalidated"); } - - // Isolate the success handling as there is bug in port forwarding mode - private boolean isSuccess(BaseFuture baseFuture) { - // return baseFuture.isSuccess(); - return true; - } }