Skip to content

Commit

Permalink
Cleanup formatting, organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Oct 19, 2016
1 parent 9a72532 commit 3ea9ad4
Show file tree
Hide file tree
Showing 28 changed files with 80 additions and 84 deletions.
25 changes: 10 additions & 15 deletions core/src/main/java/io/bitsquare/btc/ProxySocketFactory.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@

/**
* Copyright (C) 2010-2014 Leon Blakey <lord.quackstar at gmail.com>
*
* <p>
* This file is part of PircBotX.
*
* <p>
* PircBotX is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* <p>
* PircBotX 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 General Public License for more details.
*
* <p>
* You should have received a copy of the GNU General Public License along with
* PircBotX. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.btc;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
import java.io.IOException;
import java.net.*;

/**
* A basic SocketFactory for creating sockets that connect through the specified
Expand All @@ -49,8 +44,8 @@ public ProxySocketFactory(Proxy proxy) {
* and port.
*
* @param proxyType The type of proxy were connecting to
* @param hostname The hostname of the proxy server
* @param port The port of the proxy server
* @param hostname The hostname of the proxy server
* @param port The port of the proxy server
*/
public ProxySocketFactory(Proxy.Type proxyType, String hostname, int port) {
this.proxy = new Proxy(proxyType, new InetSocketAddress(hostname, port));
Expand All @@ -60,8 +55,8 @@ public ProxySocketFactory(Proxy.Type proxyType, String hostname, int port) {
public Socket createSocket() throws IOException {
Socket socket = new Socket(proxy);
return socket;
}
}

@Override
public Socket createSocket(String string, int i) throws IOException, UnknownHostException {
Socket socket = new Socket(proxy);
Expand Down
57 changes: 28 additions & 29 deletions core/src/main/java/io/bitsquare/btc/SeedPeersSocks5Dns.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2011 Micheal Swiggs
*
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -41,34 +41,34 @@ public class SeedPeersSocks5Dns implements PeerDiscovery {
private int pnseedIndex;

private final InetSocketAddress[] seedAddrsResolved;

private static final Logger log = LoggerFactory.getLogger(SeedPeersSocks5Dns.class);

/**
* Supports finding peers by hostname over a socks5 proxy.
*
* @param Socks5Proxy proxy the socks5 proxy to connect over.
*
* @param Socks5Proxy proxy the socks5 proxy to connect over.
* @param NetworkParameters param to be used for seed and port information.
*/
public SeedPeersSocks5Dns(Socks5Proxy proxy, NetworkParameters params) {

this.proxy = proxy;
this.params = params;
this.seedAddrs = convertAddrsString( params.getDnsSeeds(), params.getPort() );
this.seedAddrs = convertAddrsString(params.getDnsSeeds(), params.getPort());

if( false ) {
if (false) {
// This is an example of how .onion servers could be used. Unfortunately there is presently no way
// to hand the onion address (or a connected socket) back to bitcoinj without it crashing in PeerAddress.
// note: the onion addresses should be added into bitcoinj NetworkParameters classes, eg for mainnet, testnet
// not here!
this.seedAddrs = new InetSocketAddress[] { InetSocketAddress.createUnresolved( "cajrifqkvalh2ooa.onion", 8333 ),
InetSocketAddress.createUnresolved( "bk7yp6epnmcllq72.onion", 8333 )
this.seedAddrs = new InetSocketAddress[]{InetSocketAddress.createUnresolved("cajrifqkvalh2ooa.onion", 8333),
InetSocketAddress.createUnresolved("bk7yp6epnmcllq72.onion", 8333)
};
}

seedAddrsResolved = new InetSocketAddress[seedAddrs.length];
for(int idx = seedAddrs.length; idx < seedAddrsResolved.length; idx ++) {
seedAddrsResolved[idx] = seedAddrsIP[idx-seedAddrs.length];
for (int idx = seedAddrs.length; idx < seedAddrsResolved.length; idx++) {
seedAddrsResolved[idx] = seedAddrsIP[idx - seedAddrs.length];
}
}

Expand Down Expand Up @@ -100,11 +100,11 @@ private InetSocketAddress nextPeer() throws UnknownHostException, PeerDiscoveryE
if (pnseedIndex >= seedAddrsResolved.length) {
return null;
}
if( seedAddrsResolved[pnseedIndex] == null ) {
seedAddrsResolved[pnseedIndex] = lookup( proxy, seedAddrs[pnseedIndex] );
if (seedAddrsResolved[pnseedIndex] == null) {
seedAddrsResolved[pnseedIndex] = lookup(proxy, seedAddrs[pnseedIndex]);
}
log.error("SeedPeersSocks5Dns::nextPeer: " + seedAddrsResolved[pnseedIndex]);

return seedAddrsResolved[pnseedIndex++];
}

Expand All @@ -125,8 +125,8 @@ public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) thr
*/
private InetSocketAddress[] allPeers() throws UnknownHostException {
for (int i = 0; i < seedAddrsResolved.length; ++i) {
if( seedAddrsResolved[i] == null ) {
seedAddrsResolved[i] = lookup( proxy, seedAddrs[i] );
if (seedAddrsResolved[i] == null) {
seedAddrsResolved[i] = lookup(proxy, seedAddrs[i]);
}
}
return seedAddrsResolved;
Expand All @@ -136,22 +136,21 @@ private InetSocketAddress[] allPeers() throws UnknownHostException {
* Resolves a hostname via remote DNS over socks5 proxy.
*/
@Nullable
public static InetSocketAddress lookup( Socks5Proxy proxy, InetSocketAddress addr ) {
if( !addr.isUnresolved() ) {
public static InetSocketAddress lookup(Socks5Proxy proxy, InetSocketAddress addr) {
if (!addr.isUnresolved()) {
return addr;
}
try {
SocksSocket proxySocket = new SocksSocket( proxy, addr.getHostString(), addr.getPort() );
SocksSocket proxySocket = new SocksSocket(proxy, addr.getHostString(), addr.getPort());
InetAddress addrResolved = proxySocket.getInetAddress();
proxySocket.close();
if( addrResolved != null ) {
if (addrResolved != null) {
log.debug("Resolved " + addr.getHostString() + " to " + addrResolved.getHostAddress());
return new InetSocketAddress(addrResolved, addr.getPort() );
}
else {
return new InetSocketAddress(addrResolved, addr.getPort());
} else {
// note: .onion nodes fall in here when proxy is Tor. But they have no IP address.
// Unfortunately bitcoinj crashes in PeerAddress if it finds an unresolved address.
log.error("Connected to " + addr.getHostString() + ". But did not resolve to address." );
log.error("Connected to " + addr.getHostString() + ". But did not resolve to address.");
}
} catch (Exception e) {
log.warn("Error resolving " + addr.getHostString() + ". Exception:\n" + e.toString());
Expand All @@ -164,12 +163,12 @@ public static InetSocketAddress lookup( Socks5Proxy proxy, InetSocketAddress add
*/
private InetSocketAddress[] convertAddrsString(String[] addrs, int port) {
InetSocketAddress[] list = new InetSocketAddress[addrs.length];
for( int i = 0; i < addrs.length; i++) {
for (int i = 0; i < addrs.length; i++) {
list[i] = InetSocketAddress.createUnresolved(addrs[i], port);
}
return list;
}

@Override
public void shutdown() {
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/io/bitsquare/payment/PaymentMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public final class PaymentMethod implements Persistable, Comparable {
public static PaymentMethod SWISH;
public static PaymentMethod ALI_PAY;
public static PaymentMethod CLEAR_X_CHANGE;
public static PaymentMethod CHASE_QUICK_PAY;
public static PaymentMethod INTERAC_E_TRANSFER;
public static PaymentMethod CHASE_QUICK_PAY;
public static PaymentMethod INTERAC_E_TRANSFER;
public static PaymentMethod US_POSTAL_MONEY_ORDER;
public static PaymentMethod CASH_DEPOSIT;
public static PaymentMethod BLOCK_CHAINS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PlaceOfferModel implements Model {

public PlaceOfferModel(Offer offer,
Coin reservedFundsForOffer,
boolean useSavingsWallet,
boolean useSavingsWallet,
WalletService walletService,
TradeWalletService tradeWalletService,
OfferBookService offerBookService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public TradeProtocol(Trade trade) {
doHandleDecryptedMessage(tradeMessage, peersNodeAddress);
}
} //else {
//TODO not clear anymore what case is handled here
// it might be that we received a msg from the arbitrator, we don't handle that here but we don't want to log an error
//TODO not clear anymore what case is handled here
// it might be that we received a msg from the arbitrator, we don't handle that here but we don't want to log an error
/*Optional<Arbitrator> arbitratorOptional = processModel.getArbitratorManager().getArbitratorsObservableMap().values().stream()
.filter(e -> e.getArbitratorAddress().equals(trade.getArbitratorAddress())).findFirst();
PubKeyRing arbitratorPubKeyRing = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void run() {
removeMailboxMessageAfterProcessing();

trade.setState(Trade.State.OFFERER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG);

complete();
} catch (Throwable t) {
failed(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void run() {
removeMailboxMessageAfterProcessing();

trade.setState(Trade.State.SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG);

complete();
} catch (Throwable t) {
failed(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void run() {
checkNotNull(message);
checkArgument(message.payoutTx != null);
trade.setPayoutTx(processModel.getTradeWalletService().addTransactionToWallet(message.payoutTx));


// update to the latest peer address of our peer if the message is correct
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public TxIdTextField() {
AnchorPane.setRightAnchor(copyIcon, 30.0);

Tooltip tooltip = new Tooltip("Open a blockchain explorer with that transactions ID");

blockExplorerIcon = new Label();
blockExplorerIcon.getStyleClass().add("external-link-icon");
blockExplorerIcon.setTooltip(tooltip);
Expand Down
2 changes: 0 additions & 2 deletions gui/src/main/java/io/bitsquare/gui/images.css
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@
-fx-image: url("../../../images/invert.png");
}



#avatar_1 {
-fx-image: url("../../../images/avatars/avatar_1.png");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class FiatAccountsView extends ActivatableViewAndModel<GridPane, FiatAcco
private final ChaseQuickPayValidator chaseQuickPayValidator;
private final InteracETransferValidator interacETransferValidator;
private final USPostalMoneyOrderValidator usPostalMoneyOrderValidator;

private BSFormatter formatter;

private PaymentMethodForm paymentMethodForm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void checkIfEncrypted() {
private void doRestore() {
long date = restoreDatePicker.getValue().atStartOfDay().toEpochSecond(ZoneOffset.UTC);
DeterministicSeed seed = new DeterministicSeed(Splitter.on(" ").splitToList(restoreSeedWordsTextArea.getText()), null, "", date);
walletService.restoreSeedWords(seed,
walletService.restoreSeedWords(seed,
() -> UserThread.execute(() -> {
log.info("Wallet restored with seed words");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class CandleTooltip extends GridPane {
setHgap(Layout.GRID_GAP);

setVgap(2);

Label open = new Label("Open:");
Label close = new Label("Close:");
Label high = new Label("High:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected void activate() {
else {
tradeCurrency = CurrencyUtil.getDefaultTradeCurrency();
}

root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
root.getTabs().addListener(tabListChangeListener);
navigation.addListener(navigationListener);
Expand Down
6 changes: 3 additions & 3 deletions gui/src/main/java/io/bitsquare/gui/main/overlays/Overlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected enum Type {
protected boolean hideCloseButton;
protected boolean useAnimation = true;
private String headlineStyle;


///////////////////////////////////////////////////////////////////////////////////////////
// Public API
Expand Down Expand Up @@ -357,7 +357,7 @@ public T setHeadlineStyle(String headlineStyle) {
this.headlineStyle = headlineStyle;
return (T) this;
}


///////////////////////////////////////////////////////////////////////////////////////////
// Protected
Expand Down Expand Up @@ -629,7 +629,7 @@ protected void addHeadLine() {

if (headlineStyle != null)
headLineLabel.setStyle(headlineStyle);

GridPane.setHalignment(headLineLabel, HPos.LEFT);
GridPane.setRowIndex(headLineLabel, rowIndex);
GridPane.setColumnSpan(headLineLabel, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void addContent() {
BSResources.get(sellerPaymentAccountContractData.getPaymentDetails())).second.setMouseTransparent(false);

addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "Selected arbitrator:", contract.arbitratorNodeAddress.getFullAddress());

if (showAcceptedCountryCodes) {
String countries;
Tooltip tooltip = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void initialize() {
else
return 0;
});

stateColumn.setComparator((o1, o2) -> model.getState(o1).compareTo(model.getState(o2)));
marketColumn.setComparator((o1, o2) -> model.getMarketLabel(o1).compareTo(model.getMarketLabel(o2)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected String getInfoBlockTitle() {
if (model.getLockTime() > 0)
return "Wait until payout lock time is over";
else
return "Sending payout transaction to peer";
return "Sending payout transaction to peer";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion monitor/src/main/java/io/bitsquare/monitor/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void onRequestCustomBridges(Runnable resultHandler) {

}
});

gateway = new Gateway(offerBookService);
}

Expand Down
3 changes: 2 additions & 1 deletion network/src/main/java/io/bitsquare/http/FakeDnsResolver.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.bitsquare.http;

import org.apache.http.conn.DnsResolver;

import java.net.InetAddress;
import java.net.UnknownHostException;

Expand All @@ -10,6 +11,6 @@ class FakeDnsResolver implements DnsResolver {
@Override
public InetAddress[] resolve(String host) throws UnknownHostException {
// Return some fake DNS record for every request, we won't be using it
return new InetAddress[] { InetAddress.getByAddress(new byte[] { 1, 1, 1, 1 }) };
return new InetAddress[]{InetAddress.getByAddress(new byte[]{1, 1, 1, 1})};
}
}
Loading

0 comments on commit 3ea9ad4

Please sign in to comment.