Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Jul 29, 2016
2 parents 13c2db8 + 3cf11e6 commit ef46e50
Show file tree
Hide file tree
Showing 136 changed files with 1,091 additions and 760 deletions.
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.4.9.1</version>
<version>0.4.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/io/bitsquare/app/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Version {
private static final Logger log = LoggerFactory.getLogger(Version.class);

// The application versions
public static final String VERSION = "0.4.9.1";
public static final String VERSION = "0.4.9.2";

// The version nr. for the objects sent over the network. A change will break the serialization of old objects.
// If objects are used for both network and database the network version is applied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.spec.*;
import java.util.Date;

// TODO: use a password protection for key storage
public class KeyStorage {
Expand Down Expand Up @@ -124,7 +125,7 @@ public KeyPair loadKeyPair(KeyEntry keyEntry) {
throw new RuntimeException("Unsupported key algo" + keyEntry.getAlgorithm());
}

//log.info("load completed in {} msec", System.currentTimeMillis() - now);
log.debug("load completed in {} msec", System.currentTimeMillis() - new Date().getTime());
return new KeyPair(publicKey, privateKey);
} catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchProviderException e) {
e.printStackTrace();
Expand Down
5 changes: 2 additions & 3 deletions common/src/main/java/io/bitsquare/common/util/Profiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ public class Profiler {
private static final Logger log = LoggerFactory.getLogger(Profiler.class);

public static void printSystemLoad(Logger log) {
log.warn(printSystemLoadString());
log.info(printSystemLoadString());
}

public static String printSystemLoadString() {
long used = getUsedMemoryInMB();
return "System load: Memory (MB)): " + used + " / Nr. of threads: " + Thread.activeCount();
return "System load: Memory (MB)): " + getUsedMemoryInMB() + " / Nr. of threads: " + Thread.activeCount();
}

public static long getUsedMemoryInMB() {
Expand Down
22 changes: 0 additions & 22 deletions common/src/main/java/io/bitsquare/common/util/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
import java.io.*;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Locale;
Expand Down Expand Up @@ -207,26 +205,6 @@ public static void openDirectory(File directory) throws IOException {
}
}

public static void openWebPage(String target) {
try {
openURI(new URI(target));
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
}

public static void openMail(String to, String subject, String body) {
try {
subject = URLEncoder.encode(subject, "UTF-8").replace("+", "%20");
body = URLEncoder.encode(body, "UTF-8").replace("+", "%20");
openURI(new URI("mailto:" + to + "?subject=" + subject + "&body=" + body));
} catch (IOException | URISyntaxException e) {
log.error("openMail failed " + e.getMessage());
e.printStackTrace();
}
}

public static void printSystemLoad() {
Runtime runtime = Runtime.getRuntime();
long free = runtime.freeMemory() / 1024 / 1024;
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/io/bitsquare/storage/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ private synchronized void saveToFile(T serializable, File dir, File storageFile)

renameTempFileToFile(tempFile, storageFile);
} catch (Throwable t) {
log.debug("storageFile " + storageFile.toString());
log.error("storageFile " + storageFile.toString());
t.printStackTrace();
log.error("Error at saveToFile: " + t.getMessage());
} finally {
if (tempFile != null && tempFile.exists()) {
log.warn("Temp file still exists after failed save. storageFile=" + storageFile);
log.warn("Temp file still exists after failed save. We will delete it now. storageFile=" + storageFile);
if (!tempFile.delete())
log.error("Cannot delete temp file.");
}
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.4.9.1</version>
<version>0.4.9.2</version>
</parent>

<artifactId>core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void setDefaultAppName(String defaultAppName) {
public static final String DEFAULT_USER_DATA_DIR = defaultUserDataDir();
public static final String DEFAULT_APP_DATA_DIR = appDataDir(DEFAULT_USER_DATA_DIR, DEFAULT_APP_NAME);

public static final String LOG_LEVEL_DEFAULT = (DevFlags.STRESS_TEST_MODE || DevFlags.DEV_MODE) ? Level.TRACE.levelStr : Level.WARN.levelStr;
public static final String LOG_LEVEL_DEFAULT = (DevFlags.STRESS_TEST_MODE || DevFlags.DEV_MODE) ? Level.TRACE.levelStr : Level.INFO.levelStr;

static final String BITSQUARE_COMMANDLINE_PROPERTY_SOURCE_NAME = "bitsquareCommandLineProperties";
static final String BITSQUARE_APP_DIR_PROPERTY_SOURCE_NAME = "bitsquareAppDirProperties";
Expand Down
11 changes: 9 additions & 2 deletions core/src/main/java/io/bitsquare/arbitration/Dispute.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,26 @@ public void setStorage(Storage<DisputeList<Dispute>> storage) {
}

public void setIsClosed(boolean isClosed) {
boolean changed = this.isClosed != isClosed;
this.isClosed = isClosed;
isClosedProperty.set(isClosed);
storage.queueUpForSave();
if (changed)
storage.queueUpForSave();
}

public void setDisputeResult(DisputeResult disputeResult) {
boolean changed = this.disputeResult == null || !this.disputeResult.equals(disputeResult);
this.disputeResult = disputeResult;
disputeResultProperty.set(disputeResult);
storage.queueUpForSave();
if (changed)
storage.queueUpForSave();
}

public void setDisputePayoutTxId(String disputePayoutTxId) {
boolean changed = this.disputePayoutTxId == null || !this.disputePayoutTxId.equals(disputePayoutTxId);
this.disputePayoutTxId = disputePayoutTxId;
if (changed)
storage.queueUpForSave();
}


Expand Down
14 changes: 8 additions & 6 deletions core/src/main/java/io/bitsquare/arbitration/DisputeList.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,23 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
@Override
public boolean add(DisputeCase disputeCase) {
if (!super.contains(disputeCase)) {
boolean result = super.add(disputeCase);
boolean changed = super.add(disputeCase);
getObservableList().add(disputeCase);
storage.queueUpForSave();
return result;
if (changed)
storage.queueUpForSave();
return changed;
} else {
return false;
}
}

@Override
public boolean remove(Object disputeCase) {
boolean result = super.remove(disputeCase);
boolean changed = super.remove(disputeCase);
getObservableList().remove(disputeCase);
storage.queueUpForSave();
return result;
if (changed)
storage.queueUpForSave();
return changed;
}

private ObservableList<DisputeCase> getObservableList() {
Expand Down
19 changes: 11 additions & 8 deletions core/src/main/java/io/bitsquare/btc/AddressEntryList.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public void onWalletReady(Wallet wallet) {
}

public AddressEntry addAddressEntry(AddressEntry addressEntry) {
add(addressEntry);
storage.queueUpForSave();
boolean changed = add(addressEntry);
if (changed)
storage.queueUpForSave();
return addressEntry;
}

Expand All @@ -78,17 +79,19 @@ public void swapTradeToSavings(String offerId) {
Optional<AddressEntry> addressEntryOptional = this.stream().filter(addressEntry -> offerId.equals(addressEntry.getOfferId())).findAny();
if (addressEntryOptional.isPresent()) {
AddressEntry addressEntry = addressEntryOptional.get();
add(new AddressEntry(addressEntry.getKeyPair(), wallet.getParams(), AddressEntry.Context.AVAILABLE));
remove(addressEntry);
storage.queueUpForSave();
boolean changed1 = add(new AddressEntry(addressEntry.getKeyPair(), wallet.getParams(), AddressEntry.Context.AVAILABLE));
boolean changed2 = remove(addressEntry);
if (changed1 || changed2)
storage.queueUpForSave();
}
}

public void swapToAvailable(AddressEntry addressEntry) {
remove(addressEntry);
add(new AddressEntry(addressEntry.getKeyPair(), wallet.getParams(), AddressEntry.Context.AVAILABLE));
remove(addressEntry);
storage.queueUpForSave();
boolean changed1 = add(new AddressEntry(addressEntry.getKeyPair(), wallet.getParams(), AddressEntry.Context.AVAILABLE));
boolean changed2 = remove(addressEntry);
if (changed1 || changed2)
storage.queueUpForSave();
}

public void queueUpForSave() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static InetSocketAddress lookup( Socks5Proxy proxy, InetSocketAddress add
InetAddress addrResolved = proxySocket.getInetAddress();
proxySocket.close();
if( addrResolved != null ) {
log.info("Resolved " + addr.getHostString() + " to " + addrResolved.getHostAddress() );
log.debug("Resolved " + addr.getHostString() + " to " + addrResolved.getHostAddress());
return new InetSocketAddress(addrResolved, addr.getPort() );
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ private Transaction createPayoutTx(Transaction depositTx,
transaction.addOutput(buyerPayoutAmount, new Address(params, buyerAddressString));
transaction.addOutput(sellerPayoutAmount, new Address(params, sellerAddressString));
if (lockTime != 0) {
log.info("We use a lockTime of " + lockTime);
log.debug("We use a lockTime of " + lockTime);
// When using lockTime we need to set sequenceNumber to 0
transaction.getInputs().stream().forEach(i -> i.setSequenceNumber(0));
transaction.setLockTime(lockTime);
Expand Down
16 changes: 8 additions & 8 deletions core/src/main/java/io/bitsquare/btc/WalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void initialize(@Nullable DeterministicSeed seed, ResultHandler resultHan
backupWallet();

final Socks5Proxy socks5Proxy = preferences.getUseTorForBitcoinJ() ? socks5ProxyProvider.getSocks5Proxy() : null;
log.info("Use socks5Proxy for bitcoinj: " + socks5Proxy);
log.debug("Use socks5Proxy for bitcoinj: " + socks5Proxy);

// If seed is non-null it means we are restoring from backup.
walletAppKit = new WalletAppKitBitSquare(params, socks5Proxy, walletDir, "Bitsquare") {
Expand Down Expand Up @@ -714,7 +714,7 @@ public void doubleSpendTransaction(String txId, Runnable resultHandler, ErrorMes
public void doubleSpendTransaction(Transaction txToDoubleSpend, Address toAddress, Runnable resultHandler, ErrorMessageHandler errorMessageHandler) throws InsufficientMoneyException, AddressFormatException, AddressEntryException {
final TransactionConfidence.ConfidenceType confidenceType = txToDoubleSpend.getConfidence().getConfidenceType();
if (confidenceType == TransactionConfidence.ConfidenceType.PENDING) {
log.info("txToDoubleSpend nr. of inputs " + txToDoubleSpend.getInputs().size());
log.debug("txToDoubleSpend nr. of inputs " + txToDoubleSpend.getInputs().size());

Transaction newTransaction = new Transaction(params);
txToDoubleSpend.getInputs().stream().forEach(input -> {
Expand All @@ -739,8 +739,8 @@ public void doubleSpendTransaction(Transaction txToDoubleSpend, Address toAddres
}
);

log.info("newTransaction nr. of inputs " + newTransaction.getInputs().size());
log.info("newTransaction size in kB " + newTransaction.bitcoinSerialize().length / 1024);
log.debug("newTransaction nr. of inputs " + newTransaction.getInputs().size());
log.debug("newTransaction size in kB " + newTransaction.bitcoinSerialize().length / 1024);

if (!newTransaction.getInputs().isEmpty()) {
Coin amount = Coin.valueOf(newTransaction.getInputs().stream()
Expand Down Expand Up @@ -795,7 +795,7 @@ public void doubleSpendTransaction(Transaction txToDoubleSpend, Address toAddres
}
}
if (sendResult != null) {
log.info("Broadcasting double spending transaction. " + newTransaction);
log.debug("Broadcasting double spending transaction. " + newTransaction);
Futures.addCallback(sendResult.broadcastComplete, new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction result) {
Expand Down Expand Up @@ -835,9 +835,9 @@ private Coin getFeeForDoubleSpend(Wallet.SendRequest sendRequest,
newSendRequest.feePerKb = FeePolicy.getNonTradeFeePerKb();
wallet.completeTx(newSendRequest);

log.info("After fee check: amount " + amount.toFriendlyString());
log.info("Output fee " + sendRequest.tx.getFee().toFriendlyString());
sendRequest.tx.getOutputs().stream().forEach(o -> log.info("Output value " + o.getValue().toFriendlyString()));
log.debug("After fee check: amount " + amount.toFriendlyString());
log.debug("Output fee " + sendRequest.tx.getFee().toFriendlyString());
sendRequest.tx.getOutputs().stream().forEach(o -> log.debug("Output value " + o.getValue().toFriendlyString()));
} catch (InsufficientMoneyException e) {
if (e.missing != null) {
log.trace("missing fee " + e.missing.toFriendlyString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SettableFuture<Coin> requestFee(String transactionId) {
Futures.addCallback(future, new FutureCallback<Coin>() {
public void onSuccess(Coin fee) {
if (!resultFuture.isDone()) {
log.info("Request fee from providers done after {} ms.", (System.currentTimeMillis() - startTime));
log.debug("Request fee from providers done after {} ms.", (System.currentTimeMillis() - startTime));
resultFuture.set(fee);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private SettableFuture<Coin> request(String transactionId, FeeProvider provider,
try {
return provider.getFee(transactionId);
} catch (IOException | HttpException e) {
log.info("Fee request failed for tx {} from provider {}\n" +
log.debug("Fee request failed for tx {} from provider {}\n" +
"That is expected if the tx was not propagated yet to the provider.\n" +
"error={}",
transactionId, provider, e.getMessage());
Expand All @@ -43,7 +43,7 @@ private SettableFuture<Coin> request(String transactionId, FeeProvider provider,

Futures.addCallback(future, new FutureCallback<Coin>() {
public void onSuccess(Coin fee) {
log.info("Received fee of {}\nfor tx {}\nfrom provider {}", fee.toFriendlyString(), transactionId, provider);
log.debug("Received fee of {}\nfor tx {}\nfrom provider {}", fee.toFriendlyString(), transactionId, provider);
resultFuture.set(fee);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void onSuccess(MarketPrice marketPrice) {
}

public void onFailure(@NotNull Throwable throwable) {
log.error("requestPrice.onFailure: throwable=" + throwable.toString());
resultFuture.setException(throwable);
}
});
Expand Down
Loading

0 comments on commit ef46e50

Please sign in to comment.