P2P network improvements

This commit is contained in:
Manfred Karrer 2016-02-26 00:10:44 +01:00
parent f0d727e345
commit 4bc8c70a83
19 changed files with 214 additions and 153 deletions

View file

@ -4,6 +4,7 @@ import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
import com.google.inject.Inject;
import io.bitsquare.app.Log;
import io.bitsquare.btc.pricefeed.providers.BitcoinAveragePriceProvider;
import io.bitsquare.btc.pricefeed.providers.PoloniexPriceProvider;
import io.bitsquare.btc.pricefeed.providers.PriceProvider;
@ -74,6 +75,7 @@ public class MarketPriceFeed {
this.faultHandler = faultHandler;
requestAllPrices(fiatPriceProvider, () -> {
log.trace("requestAllPrices result");
applyPrice();
UserThread.runPeriodically(() -> requestPrice(fiatPriceProvider), PERIOD_FIAT_SEC);
});
@ -144,7 +146,7 @@ public class MarketPriceFeed {
}
private void requestPrice(PriceProvider provider) {
//Log.traceCall();
Log.traceCall();
GetPriceRequest getPriceRequest = new GetPriceRequest();
SettableFuture<MarketPrice> future = getPriceRequest.requestPrice(currencyCode, provider);
Futures.addCallback(future, new FutureCallback<MarketPrice>() {
@ -163,7 +165,7 @@ public class MarketPriceFeed {
}
private void requestAllPrices(PriceProvider provider, @Nullable Runnable resultHandler) {
// Log.traceCall();
Log.traceCall();
GetPriceRequest getPriceRequest = new GetPriceRequest();
SettableFuture<Map<String, MarketPrice>> future = getPriceRequest.requestAllPrices(provider);
Futures.addCallback(future, new FutureCallback<Map<String, MarketPrice>>() {

View file

@ -74,7 +74,7 @@ public class PoloniexPriceProvider implements PriceProvider {
@Override
public String toString() {
return "BitcoinAveragePriceProvider{" +
return "PoloniexPriceProvider{" +
'}';
}
}

View file

@ -33,6 +33,7 @@ import io.bitsquare.p2p.NodeAddress;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.p2p.messaging.DecryptedDirectMessageListener;
import io.bitsquare.p2p.messaging.SendDirectMessageListener;
import io.bitsquare.p2p.peers.BroadcastHandler;
import io.bitsquare.p2p.peers.PeerManager;
import io.bitsquare.storage.Storage;
import io.bitsquare.trade.TradableList;
@ -138,6 +139,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
log.info("remove all open offers at shutDown");
// we remove own offers from offerbook when we go offline
// Normally we use a delay for broadcasting to the peers, but at shut down we want to get it fast out
BroadcastHandler.setDelayMs(1);
openOffers.forEach(openOffer -> offerBookService.removeOfferAtShutDown(openOffer.getOffer()));
if (completeHandler != null)