Merge pull request #4573 from chimp1984/remove-debug-logs

Cleanup debug logs
This commit is contained in:
Christoph Atteneder 2020-09-30 16:09:37 +02:00 committed by GitHub
commit 8b751d095c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 87 additions and 198 deletions

View file

@ -35,7 +35,7 @@ public class MasterTimer {
timer.scheduleAtFixedRate(new TimerTask() { timer.scheduleAtFixedRate(new TimerTask() {
@Override @Override
public void run() { public void run() {
UserThread.execute(() -> listeners.stream().forEach(Runnable::run)); UserThread.execute(() -> listeners.forEach(Runnable::run));
} }
}, FRAME_INTERVAL_MS, FRAME_INTERVAL_MS); }, FRAME_INTERVAL_MS, FRAME_INTERVAL_MS);
} }

View file

@ -47,6 +47,7 @@ public class Capabilities {
// Defines which most recent capability any node need to support. // Defines which most recent capability any node need to support.
// This helps to clean network from very old inactive but still running nodes. // This helps to clean network from very old inactive but still running nodes.
@SuppressWarnings("deprecation")
private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE; private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE;
protected final Set<Capability> capabilities = new HashSet<>(); protected final Set<Capability> capabilities = new HashSet<>();

View file

@ -39,7 +39,7 @@ public enum BaseCurrencyNetwork {
@Getter @Getter
private final String network; private final String network;
@Getter @Getter
private String currencyName; private final String currencyName;
BaseCurrencyNetwork(NetworkParameters parameters, String currencyCode, String network, String currencyName) { BaseCurrencyNetwork(NetworkParameters parameters, String currencyCode, String network, String currencyName) {
this.parameters = parameters; this.parameters = parameters;

View file

@ -110,7 +110,7 @@ public class BisqHelpFormatter implements HelpFormatter {
// without any spaces (e.g. a URL) are allowed to overflow the 80-char margin. // without any spaces (e.g. a URL) are allowed to overflow the 80-char margin.
while (remainder.length() > 72) { while (remainder.length() > 72) {
int idxFirstSpace = remainder.indexOf(' '); int idxFirstSpace = remainder.indexOf(' ');
int chunkLen = idxFirstSpace == -1 ? remainder.length() : idxFirstSpace > 73 ? idxFirstSpace : 73; int chunkLen = idxFirstSpace == -1 ? remainder.length() : Math.max(idxFirstSpace, 73);
String chunk = remainder.substring(0, chunkLen); String chunk = remainder.substring(0, chunkLen);
int idxLastSpace = chunk.lastIndexOf(' '); int idxLastSpace = chunk.lastIndexOf(' ');
int idxBreak = idxLastSpace > 0 ? idxLastSpace : chunk.length(); int idxBreak = idxLastSpace > 0 ? idxLastSpace : chunk.length();

View file

@ -722,7 +722,7 @@ public class Config {
this.providers = options.valuesOf(providersOpt); this.providers = options.valuesOf(providersOpt);
this.seedNodes = options.valuesOf(seedNodesOpt); this.seedNodes = options.valuesOf(seedNodesOpt);
this.banList = options.valuesOf(banListOpt); this.banList = options.valuesOf(banListOpt);
this.useLocalhostForP2P = this.baseCurrencyNetwork.isMainnet() ? false : options.valueOf(useLocalhostForP2POpt); this.useLocalhostForP2P = !this.baseCurrencyNetwork.isMainnet() && options.valueOf(useLocalhostForP2POpt);
this.maxConnections = options.valueOf(maxConnectionsOpt); this.maxConnections = options.valueOf(maxConnectionsOpt);
this.socks5ProxyBtcAddress = options.valueOf(socks5ProxyBtcAddressOpt); this.socks5ProxyBtcAddress = options.valueOf(socks5ProxyBtcAddressOpt);
this.socks5ProxyHttpAddress = options.valueOf(socks5ProxyHttpAddressOpt); this.socks5ProxyHttpAddress = options.valueOf(socks5ProxyHttpAddressOpt);
@ -815,6 +815,7 @@ public class Config {
private static String randomAppName() { private static String randomAppName() {
try { try {
File file = Files.createTempFile("Bisq", "Temp").toFile(); File file = Files.createTempFile("Bisq", "Temp").toFile();
//noinspection ResultOfMethodCallIgnored
file.delete(); file.delete();
return file.toPath().getFileName().toString(); return file.toPath().getFileName().toString();
} catch (IOException ex) { } catch (IOException ex) {

View file

@ -17,8 +17,8 @@
package bisq.common.crypto; package bisq.common.crypto;
import bisq.common.util.Utilities;
import bisq.common.util.Hex; import bisq.common.util.Hex;
import bisq.common.util.Utilities;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.KeyGenerator; import javax.crypto.KeyGenerator;
@ -65,9 +65,7 @@ public class Encryption {
try { try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO);
keyPairGenerator.initialize(2048); keyPairGenerator.initialize(2048);
KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPairGenerator.genKeyPair();
log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts);
return keyPair;
} catch (Throwable e) { } catch (Throwable e) {
log.error("Could not create key.", e); log.error("Could not create key.", e);
throw new RuntimeException("Could not create key."); throw new RuntimeException("Could not create key.");

View file

@ -5,7 +5,7 @@ import com.google.inject.Provider;
public class PubKeyRingProvider implements Provider<PubKeyRing> { public class PubKeyRingProvider implements Provider<PubKeyRing> {
private PubKeyRing pubKeyRing; private final PubKeyRing pubKeyRing;
@Inject @Inject
public PubKeyRingProvider(KeyRing keyRing) { public PubKeyRingProvider(KeyRing keyRing) {

View file

@ -17,8 +17,8 @@
package bisq.common.crypto; package bisq.common.crypto;
import bisq.common.util.Utilities;
import bisq.common.util.Base64; import bisq.common.util.Base64;
import bisq.common.util.Utilities;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
@ -60,9 +60,7 @@ public class Sig {
try { try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO);
keyPairGenerator.initialize(1024); keyPairGenerator.initialize(1024);
KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPairGenerator.genKeyPair();
log.trace("Generate msgSignatureKeyPair needed {} ms", System.currentTimeMillis() - ts);
return keyPair;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
log.error("Could not create key.", e); log.error("Could not create key.", e);
throw new RuntimeException("Could not create key."); throw new RuntimeException("Could not create key.");

View file

@ -39,7 +39,6 @@ public interface UserThreadMappedPersistableEnvelope extends PersistableEnvelope
default Message toPersistableMessage() { default Message toPersistableMessage() {
FutureTask<Message> toProtoOnUserThread = new FutureTask<>(this::toProtoMessage); FutureTask<Message> toProtoOnUserThread = new FutureTask<>(this::toProtoMessage);
UserThread.execute(toProtoOnUserThread); UserThread.execute(toProtoOnUserThread);
//noinspection UnstableApiUsage
return Futures.getUnchecked(toProtoOnUserThread); return Futures.getUnchecked(toProtoOnUserThread);
} }
} }

View file

@ -29,7 +29,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@Singleton @Singleton
public class CorruptedDatabaseFilesHandler { public class CorruptedDatabaseFilesHandler {
private List<String> corruptedDatabaseFiles = new ArrayList<>(); private final List<String> corruptedDatabaseFiles = new ArrayList<>();
@Inject @Inject
public CorruptedDatabaseFilesHandler() { public CorruptedDatabaseFilesHandler() {

View file

@ -239,7 +239,6 @@ public class FileManager<T extends PersistableEnvelope> {
try { try {
if (fileOutputStream != null) if (fileOutputStream != null)
fileOutputStream.close(); fileOutputStream.close();
//noinspection ConstantConditions,ConstantConditions
if (printWriter != null) if (printWriter != null)
printWriter.close(); printWriter.close();
} catch (IOException e) { } catch (IOException e) {

View file

@ -110,14 +110,14 @@ public class FileUtil {
File[] files = file.listFiles(); File[] files = file.listFiles();
if (files != null) if (files != null)
for (File f : files) { for (File f : files) {
boolean excludeFileFoundLocal = exclude != null ? f.getAbsolutePath().equals(exclude.getAbsolutePath()) : false; boolean excludeFileFoundLocal = exclude != null && f.getAbsolutePath().equals(exclude.getAbsolutePath());
excludeFileFound |= excludeFileFoundLocal; excludeFileFound |= excludeFileFoundLocal;
if (!excludeFileFoundLocal) if (!excludeFileFoundLocal)
deleteDirectory(f, exclude, ignoreLockedFiles); deleteDirectory(f, exclude, ignoreLockedFiles);
} }
} }
// Finally delete main file/dir if exclude file was not found in directory // Finally delete main file/dir if exclude file was not found in directory
if (!excludeFileFound && !(exclude != null ? file.getAbsolutePath().equals(exclude.getAbsolutePath()) : false)) { if (!excludeFileFound && !(exclude != null && file.getAbsolutePath().equals(exclude.getAbsolutePath()))) {
try { try {
deleteFileIfExists(file, ignoreLockedFiles); deleteFileIfExists(file, ignoreLockedFiles);
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -62,7 +62,7 @@ class DesktopUtil {
} }
if (os.isWindows()) { if (os.isWindows()) {
if (runCommand("explorer", "%s", what)) return true; return runCommand("explorer", "%s", what);
} }
return false; return false;
@ -156,11 +156,10 @@ class DesktopUtil {
int value = p.exitValue(); int value = p.exitValue();
if (value == 0) { if (value == 0) {
logErr("Process ended immediately."); logErr("Process ended immediately.");
return false;
} else { } else {
logErr("Process crashed."); logErr("Process crashed.");
return false;
} }
return false;
} catch (IllegalThreadStateException e) { } catch (IllegalThreadStateException e) {
logErr("Process is running."); logErr("Process is running.");
return true; return true;

View file

@ -1,87 +0,0 @@
/*
* This file is part of Bisq.
*
* Bisq 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.
*
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.common.util;
import java.util.concurrent.Callable;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Supplier;
import lombok.Getter;
public class FunctionalReadWriteLock {
@Getter
private final Lock readLock;
@Getter
private final Lock writeLock;
public FunctionalReadWriteLock(boolean isFair) {
this(new ReentrantReadWriteLock(isFair));
}
private FunctionalReadWriteLock(ReadWriteLock lock) {
readLock = lock.readLock();
writeLock = lock.writeLock();
}
public <T> T read(Supplier<T> block) {
readLock.lock();
try {
return block.get();
} finally {
readLock.unlock();
}
}
public void read(Runnable block) {
readLock.lock();
try {
block.run();
} finally {
readLock.unlock();
}
}
public <T> T write(Supplier<T> block) {
writeLock.lock();
try {
return block.get();
} finally {
writeLock.unlock();
}
}
public void write(Runnable block) {
writeLock.lock();
try {
block.run();
} finally {
writeLock.unlock();
}
}
public void write2(Callable block) throws Exception {
writeLock.lock();
try {
block.call();
} finally {
writeLock.unlock();
}
}
}

View file

@ -72,7 +72,7 @@ public class MathUtils {
} }
public static long doubleToLong(double value) { public static long doubleToLong(double value) {
return new Double(value).longValue(); return Double.valueOf(value).longValue();
} }
public static double scaleUpByPowerOf10(double value, int exponent) { public static double scaleUpByPowerOf10(double value, int exponent) {
@ -115,10 +115,10 @@ public class MathUtils {
} }
public static class MovingAverage { public static class MovingAverage {
Deque<Long> window; final Deque<Long> window;
private int size; private final int size;
private long sum; private long sum;
private double outlier; private final double outlier;
// Outlier as ratio // Outlier as ratio
public MovingAverage(int size, double outlier) { public MovingAverage(int size, double outlier) {

View file

@ -425,13 +425,13 @@ public class Utilities {
return toTruncatedString(message, maxLength, true); return toTruncatedString(message, maxLength, true);
} }
public static String toTruncatedString(Object message, int maxLength, boolean removeLinebreaks) { public static String toTruncatedString(Object message, int maxLength, boolean removeLineBreaks) {
if (message == null) if (message == null)
return "null"; return "null";
String result = StringUtils.abbreviate(message.toString(), maxLength); String result = StringUtils.abbreviate(message.toString(), maxLength);
if (removeLinebreaks) if (removeLineBreaks)
return result.replace("\n", ""); return result.replace("\n", "");
return result; return result;

View file

@ -336,7 +336,6 @@ public class LiteNodeNetworkService implements MessageListener, ConnectionListen
retryCounter++; retryCounter++;
if (retryCounter <= MAX_RETRY) { if (retryCounter <= MAX_RETRY) {
retryTimer = UserThread.runAfter(() -> { retryTimer = UserThread.runAfter(() -> {
log.trace("retryTimer called");
stopped = false; stopped = false;
stopRetryTimer(); stopRetryTimer();

View file

@ -379,7 +379,7 @@ public abstract class DisputeManager<T extends DisputeList<? extends DisputeList
Trade trade = optionalTrade.get(); Trade trade = optionalTrade.get();
try { try {
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
trade.getDelayedPayoutTx(), trade.getDelayedPayoutTx(),
dispute, dispute,
daoFacade, daoFacade,

View file

@ -66,7 +66,7 @@ public abstract class DisputeAgentService<T extends DisputeAgent> {
!Utilities.encodeToHex(disputeAgent.getRegistrationPubKey()).equals(DevEnv.DEV_PRIVILEGE_PUB_KEY)) { !Utilities.encodeToHex(disputeAgent.getRegistrationPubKey()).equals(DevEnv.DEV_PRIVILEGE_PUB_KEY)) {
boolean result = p2PService.addProtectedStorageEntry(disputeAgent); boolean result = p2PService.addProtectedStorageEntry(disputeAgent);
if (result) { if (result) {
log.trace("Add disputeAgent to network was successful. DisputeAgent.hashCode() = " + disputeAgent.hashCode()); log.trace("Add disputeAgent to network was successful. DisputeAgent.hashCode() = {}", disputeAgent.hashCode());
resultHandler.handleResult(); resultHandler.handleResult();
} else { } else {
errorMessageHandler.handleErrorMessage("Add disputeAgent failed"); errorMessageHandler.handleErrorMessage("Add disputeAgent failed");
@ -82,7 +82,7 @@ public abstract class DisputeAgentService<T extends DisputeAgent> {
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
log.debug("removeDisputeAgent disputeAgent.hashCode() " + disputeAgent.hashCode()); log.debug("removeDisputeAgent disputeAgent.hashCode() " + disputeAgent.hashCode());
if (p2PService.removeData(disputeAgent)) { if (p2PService.removeData(disputeAgent)) {
log.trace("Remove disputeAgent from network was successful. DisputeAgent.hashCode() = " + disputeAgent.hashCode()); log.trace("Remove disputeAgent from network was successful. DisputeAgent.hashCode() = {}", disputeAgent.hashCode());
resultHandler.handleResult(); resultHandler.handleResult();
} else { } else {
errorMessageHandler.handleErrorMessage("Remove disputeAgent failed"); errorMessageHandler.handleErrorMessage("Remove disputeAgent failed");

View file

@ -382,7 +382,7 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
private void sendPeerPublishedPayoutTxMessage(Transaction transaction, Dispute dispute, Contract contract) { private void sendPeerPublishedPayoutTxMessage(Transaction transaction, Dispute dispute, Contract contract) {
PubKeyRing peersPubKeyRing = dispute.isDisputeOpenerIsBuyer() ? contract.getSellerPubKeyRing() : contract.getBuyerPubKeyRing(); PubKeyRing peersPubKeyRing = dispute.isDisputeOpenerIsBuyer() ? contract.getSellerPubKeyRing() : contract.getBuyerPubKeyRing();
NodeAddress peersNodeAddress = dispute.isDisputeOpenerIsBuyer() ? contract.getSellerNodeAddress() : contract.getBuyerNodeAddress(); NodeAddress peersNodeAddress = dispute.isDisputeOpenerIsBuyer() ? contract.getSellerNodeAddress() : contract.getBuyerNodeAddress();
log.trace("sendPeerPublishedPayoutTxMessage to peerAddress " + peersNodeAddress); log.trace("sendPeerPublishedPayoutTxMessage to peerAddress {}", peersNodeAddress);
PeerPublishedDisputePayoutTxMessage message = new PeerPublishedDisputePayoutTxMessage(transaction.bitcoinSerialize(), PeerPublishedDisputePayoutTxMessage message = new PeerPublishedDisputePayoutTxMessage(transaction.bitcoinSerialize(),
dispute.getTradeId(), dispute.getTradeId(),
p2PService.getAddress(), p2PService.getAddress(),

View file

@ -183,13 +183,13 @@ public class TradeDataValidation {
} }
} }
public static void validatePayoutTx(Trade trade, public static void validateDelayedPayoutTx(Trade trade,
Transaction delayedPayoutTx, Transaction delayedPayoutTx,
DaoFacade daoFacade, DaoFacade daoFacade,
BtcWalletService btcWalletService) BtcWalletService btcWalletService)
throws AddressException, MissingTxException, throws AddressException, MissingTxException,
InvalidTxException, InvalidLockTimeException, InvalidAmountException { InvalidTxException, InvalidLockTimeException, InvalidAmountException {
validatePayoutTx(trade, validateDelayedPayoutTx(trade,
delayedPayoutTx, delayedPayoutTx,
null, null,
daoFacade, daoFacade,
@ -197,14 +197,14 @@ public class TradeDataValidation {
null); null);
} }
public static void validatePayoutTx(Trade trade, public static void validateDelayedPayoutTx(Trade trade,
Transaction delayedPayoutTx, Transaction delayedPayoutTx,
@Nullable Dispute dispute, @Nullable Dispute dispute,
DaoFacade daoFacade, DaoFacade daoFacade,
BtcWalletService btcWalletService) BtcWalletService btcWalletService)
throws AddressException, MissingTxException, throws AddressException, MissingTxException,
InvalidTxException, InvalidLockTimeException, InvalidAmountException { InvalidTxException, InvalidLockTimeException, InvalidAmountException {
validatePayoutTx(trade, validateDelayedPayoutTx(trade,
delayedPayoutTx, delayedPayoutTx,
dispute, dispute,
daoFacade, daoFacade,
@ -212,14 +212,14 @@ public class TradeDataValidation {
null); null);
} }
public static void validatePayoutTx(Trade trade, public static void validateDelayedPayoutTx(Trade trade,
Transaction delayedPayoutTx, Transaction delayedPayoutTx,
DaoFacade daoFacade, DaoFacade daoFacade,
BtcWalletService btcWalletService, BtcWalletService btcWalletService,
@Nullable Consumer<String> addressConsumer) @Nullable Consumer<String> addressConsumer)
throws AddressException, MissingTxException, throws AddressException, MissingTxException,
InvalidTxException, InvalidLockTimeException, InvalidAmountException { InvalidTxException, InvalidLockTimeException, InvalidAmountException {
validatePayoutTx(trade, validateDelayedPayoutTx(trade,
delayedPayoutTx, delayedPayoutTx,
null, null,
daoFacade, daoFacade,
@ -227,12 +227,12 @@ public class TradeDataValidation {
addressConsumer); addressConsumer);
} }
public static void validatePayoutTx(Trade trade, public static void validateDelayedPayoutTx(Trade trade,
Transaction delayedPayoutTx, Transaction delayedPayoutTx,
@Nullable Dispute dispute, @Nullable Dispute dispute,
DaoFacade daoFacade, DaoFacade daoFacade,
BtcWalletService btcWalletService, BtcWalletService btcWalletService,
@Nullable Consumer<String> addressConsumer) @Nullable Consumer<String> addressConsumer)
throws AddressException, MissingTxException, throws AddressException, MissingTxException,
InvalidTxException, InvalidLockTimeException, InvalidAmountException { InvalidTxException, InvalidLockTimeException, InvalidAmountException {
String errorMsg; String errorMsg;

View file

@ -306,7 +306,7 @@ public class TradeManager implements PersistedDataHost {
} }
try { try {
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
trade.getDelayedPayoutTx(), trade.getDelayedPayoutTx(),
daoFacade, daoFacade,
btcWalletService); btcWalletService);

View file

@ -44,7 +44,7 @@ public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask {
Transaction delayedPayoutTx = trade.getDelayedPayoutTx(); Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
checkNotNull(delayedPayoutTx, "trade.getDelayedPayoutTx() must not be null"); checkNotNull(delayedPayoutTx, "trade.getDelayedPayoutTx() must not be null");
// Check again tx // Check again tx
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
delayedPayoutTx, delayedPayoutTx,
processModel.getDaoFacade(), processModel.getDaoFacade(),
processModel.getBtcWalletService()); processModel.getBtcWalletService());

View file

@ -37,7 +37,7 @@ public class BuyerVerifiesPreparedDelayedPayoutTx extends TradeTask {
try { try {
runInterceptHook(); runInterceptHook();
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
processModel.getPreparedDelayedPayoutTx(), processModel.getPreparedDelayedPayoutTx(),
processModel.getDaoFacade(), processModel.getDaoFacade(),
processModel.getBtcWalletService()); processModel.getBtcWalletService());

View file

@ -82,7 +82,7 @@ public class SigTest {
assertTrue(false); assertTrue(false);
} }
} }
log.trace("took " + (System.currentTimeMillis() - ts) + " ms."); log.trace("took {} ms.", System.currentTimeMillis() - ts);
} }
} }

View file

@ -541,7 +541,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
AtomicReference<String> donationAddressString = new AtomicReference<>(""); AtomicReference<String> donationAddressString = new AtomicReference<>("");
Transaction delayedPayoutTx = trade.getDelayedPayoutTx(); Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
try { try {
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
delayedPayoutTx, delayedPayoutTx,
daoFacade, daoFacade,
btcWalletService, btcWalletService,

View file

@ -80,7 +80,7 @@ public class BuyerStep1View extends TradeStepView {
private void validatePayoutTx() { private void validatePayoutTx() {
try { try {
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
trade.getDelayedPayoutTx(), trade.getDelayedPayoutTx(),
model.dataModel.daoFacade, model.dataModel.daoFacade,
model.dataModel.btcWalletService); model.dataModel.btcWalletService);

View file

@ -624,7 +624,7 @@ public class BuyerStep2View extends TradeStepView {
private void validatePayoutTx() { private void validatePayoutTx() {
try { try {
TradeDataValidation.validatePayoutTx(trade, TradeDataValidation.validateDelayedPayoutTx(trade,
trade.getDelayedPayoutTx(), trade.getDelayedPayoutTx(),
model.dataModel.daoFacade, model.dataModel.daoFacade,
model.dataModel.btcWalletService); model.dataModel.btcWalletService);

View file

@ -28,10 +28,8 @@ import bisq.network.p2p.peers.BanList;
import bisq.network.p2p.peers.getdata.messages.GetDataRequest; import bisq.network.p2p.peers.getdata.messages.GetDataRequest;
import bisq.network.p2p.peers.getdata.messages.GetDataResponse; import bisq.network.p2p.peers.getdata.messages.GetDataResponse;
import bisq.network.p2p.peers.keepalive.messages.KeepAliveMessage; import bisq.network.p2p.peers.keepalive.messages.KeepAliveMessage;
import bisq.network.p2p.peers.keepalive.messages.Ping;
import bisq.network.p2p.storage.messages.AddDataMessage; import bisq.network.p2p.storage.messages.AddDataMessage;
import bisq.network.p2p.storage.messages.AddPersistableNetworkPayloadMessage; import bisq.network.p2p.storage.messages.AddPersistableNetworkPayloadMessage;
import bisq.network.p2p.storage.messages.RefreshOfferMessage;
import bisq.network.p2p.storage.payload.CapabilityRequiringPayload; import bisq.network.p2p.storage.payload.CapabilityRequiringPayload;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload; import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.payload.ProtectedStoragePayload; import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
@ -234,17 +232,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
try { try {
String peersNodeAddress = peersNodeAddressOptional.map(NodeAddress::toString).orElse("null"); String peersNodeAddress = peersNodeAddressOptional.map(NodeAddress::toString).orElse("null");
protobuf.NetworkEnvelope proto = networkEnvelope.toProtoNetworkEnvelope(); if (networkEnvelope instanceof PrefixedSealedAndSignedMessage && peersNodeAddressOptional.isPresent()) {
log.trace("Sending message: {}", Utilities.toTruncatedString(proto.toString(), 10000));
if (networkEnvelope instanceof Ping || networkEnvelope instanceof RefreshOfferMessage) {
// pings and offer refresh msg we don't want to log in production
log.trace("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" +
"Sending direct message to peer" +
"Write object to outputStream to peer: {} (uid={})\ntruncated message={} / size={}" +
"\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",
peersNodeAddress, uid, proto.toString(), proto.getSerializedSize());
} else if (networkEnvelope instanceof PrefixedSealedAndSignedMessage && peersNodeAddressOptional.isPresent()) {
setPeerType(Connection.PeerType.DIRECT_MSG_PEER); setPeerType(Connection.PeerType.DIRECT_MSG_PEER);
log.debug("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" + log.debug("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" +
@ -254,11 +242,6 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
peersNodeAddress, uid, Utilities.toTruncatedString(networkEnvelope), -1); peersNodeAddress, uid, Utilities.toTruncatedString(networkEnvelope), -1);
} else if (networkEnvelope instanceof GetDataResponse && ((GetDataResponse) networkEnvelope).isGetUpdatedDataResponse()) { } else if (networkEnvelope instanceof GetDataResponse && ((GetDataResponse) networkEnvelope).isGetUpdatedDataResponse()) {
setPeerType(Connection.PeerType.PEER); setPeerType(Connection.PeerType.PEER);
} else {
log.debug("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" +
"Write object to outputStream to peer: {} (uid={})\ntruncated message={} / size={}" +
"\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",
peersNodeAddress, uid, Utilities.toTruncatedString(networkEnvelope), proto.getSerializedSize());
} }
// Throttle outbound network_messages // Throttle outbound network_messages
@ -477,7 +460,8 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
} }
public void shutDown(CloseConnectionReason closeConnectionReason, @Nullable Runnable shutDownCompleteHandler) { public void shutDown(CloseConnectionReason closeConnectionReason, @Nullable Runnable shutDownCompleteHandler) {
log.debug("shutDown: nodeAddressOpt={}, closeConnectionReason={}", this.peersNodeAddressOptional.orElse(null), closeConnectionReason); log.debug("shutDown: nodeAddressOpt={}, closeConnectionReason={}",
this.peersNodeAddressOptional.orElse(null), closeConnectionReason);
if (!stopped) { if (!stopped) {
String peersNodeAddress = peersNodeAddressOptional.map(NodeAddress::toString).orElse("null"); String peersNodeAddress = peersNodeAddressOptional.map(NodeAddress::toString).orElse("null");
log.debug("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" + log.debug("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" +
@ -523,7 +507,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
try { try {
socket.close(); socket.close();
} catch (SocketException e) { } catch (SocketException e) {
log.trace("SocketException at shutdown might be expected " + e.getMessage()); log.trace("SocketException at shutdown might be expected {}", e.getMessage());
} catch (IOException e) { } catch (IOException e) {
log.error("Exception at shutdown. " + e.getMessage()); log.error("Exception at shutdown. " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
@ -539,9 +523,10 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
//noinspection UnstableApiUsage //noinspection UnstableApiUsage
MoreExecutors.shutdownAndAwaitTermination(singleThreadExecutor, 500, TimeUnit.MILLISECONDS); MoreExecutors.shutdownAndAwaitTermination(singleThreadExecutor, 500, TimeUnit.MILLISECONDS);
//noinspection UnstableApiUsage
MoreExecutors.shutdownAndAwaitTermination(bundleSender, 500, TimeUnit.MILLISECONDS); MoreExecutors.shutdownAndAwaitTermination(bundleSender, 500, TimeUnit.MILLISECONDS);
log.debug("Connection shutdown complete " + this.toString()); log.debug("Connection shutdown complete {}", this.toString());
// Use UserThread.execute as its not clear if that is called from a non-UserThread // Use UserThread.execute as its not clear if that is called from a non-UserThread
if (shutDownCompleteHandler != null) if (shutDownCompleteHandler != null)
UserThread.execute(shutDownCompleteHandler); UserThread.execute(shutDownCompleteHandler);
@ -827,10 +812,9 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
if (networkEnvelope instanceof CloseConnectionMessage) { if (networkEnvelope instanceof CloseConnectionMessage) {
// If we get a CloseConnectionMessage we shut down // If we get a CloseConnectionMessage we shut down
if (log.isDebugEnabled()) { log.debug("CloseConnectionMessage received. Reason={}\n\t" +
log.debug("CloseConnectionMessage received. Reason={}\n\t" + "connection={}", proto.getCloseConnectionMessage().getReason(), this);
"connection={}", proto.getCloseConnectionMessage().getReason(), this);
}
if (CloseConnectionReason.PEER_BANNED.name().equals(proto.getCloseConnectionMessage().getReason())) { if (CloseConnectionReason.PEER_BANNED.name().equals(proto.getCloseConnectionMessage().getReason())) {
log.warn("We got shut down because we are banned by the other peer. (InputHandler.run CloseConnectionMessage)"); log.warn("We got shut down because we are banned by the other peer. (InputHandler.run CloseConnectionMessage)");
shutDown(CloseConnectionReason.PEER_BANNED); shutDown(CloseConnectionReason.PEER_BANNED);

View file

@ -101,9 +101,9 @@ public abstract class NetworkNode implements MessageListener {
public SettableFuture<Connection> sendMessage(@NotNull NodeAddress peersNodeAddress, public SettableFuture<Connection> sendMessage(@NotNull NodeAddress peersNodeAddress,
NetworkEnvelope networkEnvelope) { NetworkEnvelope networkEnvelope) {
if (log.isDebugEnabled()) { log.debug("Send {} to {}. Message details: {}",
log.debug("sendMessage: peersNodeAddress=" + peersNodeAddress + "\n\tmessage=" + Utilities.toTruncatedString(networkEnvelope)); networkEnvelope.getClass().getSimpleName(), peersNodeAddress, Utilities.toTruncatedString(networkEnvelope));
}
checkNotNull(peersNodeAddress, "peerAddress must not be null"); checkNotNull(peersNodeAddress, "peerAddress must not be null");
Connection connection = getOutboundConnection(peersNodeAddress); Connection connection = getOutboundConnection(peersNodeAddress);
@ -128,9 +128,9 @@ public abstract class NetworkNode implements MessageListener {
try { try {
// can take a while when using tor // can take a while when using tor
long startTs = System.currentTimeMillis(); long startTs = System.currentTimeMillis();
if (log.isDebugEnabled()) {
log.debug("Start create socket to peersNodeAddress {}", peersNodeAddress.getFullAddress()); log.debug("Start create socket to peersNodeAddress {}", peersNodeAddress.getFullAddress());
}
Socket socket = createSocket(peersNodeAddress); Socket socket = createSocket(peersNodeAddress);
long duration = System.currentTimeMillis() - startTs; long duration = System.currentTimeMillis() - startTs;
log.info("Socket creation to peersNodeAddress {} took {} ms", peersNodeAddress.getFullAddress(), log.info("Socket creation to peersNodeAddress {} took {} ms", peersNodeAddress.getFullAddress(),
@ -146,14 +146,12 @@ public abstract class NetworkNode implements MessageListener {
existingConnection = getOutboundConnection(peersNodeAddress); existingConnection = getOutboundConnection(peersNodeAddress);
if (existingConnection != null) { if (existingConnection != null) {
if (log.isDebugEnabled()) { log.debug("We found in the meantime a connection for peersNodeAddress {}, " +
log.debug("We found in the meantime a connection for peersNodeAddress {}, " + "so we use that for sending the message.\n" +
"so we use that for sending the message.\n" + "That can happen if Tor needs long for creating a new outbound connection.\n" +
"That can happen if Tor needs long for creating a new outbound connection.\n" + "We might have got a new inbound or outbound connection.",
"We might have got a new inbound or outbound connection.", peersNodeAddress.getFullAddress());
peersNodeAddress.getFullAddress());
}
try { try {
socket.close(); socket.close();
} catch (Throwable throwable) { } catch (Throwable throwable) {
@ -168,24 +166,23 @@ public abstract class NetworkNode implements MessageListener {
if (!connection.isStopped()) { if (!connection.isStopped()) {
outBoundConnections.add((OutboundConnection) connection); outBoundConnections.add((OutboundConnection) connection);
printOutBoundConnections(); printOutBoundConnections();
connectionListeners.stream().forEach(e -> e.onConnection(connection)); connectionListeners.forEach(e -> e.onConnection(connection));
} }
} }
@Override @Override
public void onDisconnect(CloseConnectionReason closeConnectionReason, public void onDisconnect(CloseConnectionReason closeConnectionReason,
Connection connection) { Connection connection) {
log.trace("onDisconnect connectionListener\n\tconnection={}" + connection);
//noinspection SuspiciousMethodCalls //noinspection SuspiciousMethodCalls
outBoundConnections.remove(connection); outBoundConnections.remove(connection);
printOutBoundConnections(); printOutBoundConnections();
connectionListeners.stream().forEach(e -> e.onDisconnect(closeConnectionReason, connection)); connectionListeners.forEach(e -> e.onDisconnect(closeConnectionReason, connection));
} }
@Override @Override
public void onError(Throwable throwable) { public void onError(Throwable throwable) {
log.error("new OutboundConnection.ConnectionListener.onError " + throwable.getMessage()); log.error("new OutboundConnection.ConnectionListener.onError " + throwable.getMessage());
connectionListeners.stream().forEach(e -> e.onError(throwable)); connectionListeners.forEach(e -> e.onError(throwable));
} }
}; };
outboundConnection = new OutboundConnection(socket, outboundConnection = new OutboundConnection(socket,

View file

@ -36,9 +36,8 @@ import bisq.common.config.Config;
import bisq.common.proto.persistable.PersistedDataHost; import bisq.common.proto.persistable.PersistedDataHost;
import bisq.common.storage.Storage; import bisq.common.storage.Storage;
import javax.inject.Named;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@ -224,8 +223,10 @@ public class PeerManager implements ConnectionListener, PersistedDataHost {
boolean seedNode = isSeedNode(connection); boolean seedNode = isSeedNode(connection);
Optional<NodeAddress> addressOptional = connection.getPeersNodeAddressOptional(); Optional<NodeAddress> addressOptional = connection.getPeersNodeAddressOptional();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
String peer = addressOptional.map(NodeAddress::getFullAddress).orElseGet(() ->
"not known yet (connection id=" + connection.getUid() + ")");
log.debug("onConnection: peer = {}{}", log.debug("onConnection: peer = {}{}",
(addressOptional.isPresent() ? addressOptional.get().getFullAddress() : "not known yet (connection id=" + connection.getUid() + ")"), peer,
seedNode ? " (SeedNode)" : ""); seedNode ? " (SeedNode)" : "");
} }

View file

@ -149,7 +149,7 @@ class RequestDataHandler implements MessageListener {
@Override @Override
public void onSuccess(Connection connection) { public void onSuccess(Connection connection) {
if (!stopped) { if (!stopped) {
log.trace("Send " + getDataRequest + " to " + nodeAddress + " succeeded."); log.trace("Send {} to {} succeeded.", getDataRequest, nodeAddress);
} else { } else {
log.trace("We have stopped already. We ignore that networkNode.sendMessage.onSuccess call." + log.trace("We have stopped already. We ignore that networkNode.sendMessage.onSuccess call." +
"Might be caused by an previous timeout."); "Might be caused by an previous timeout.");

View file

@ -276,7 +276,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener,
peerExchangeHandler.sendGetPeersRequestAfterRandomDelay(nodeAddress); peerExchangeHandler.sendGetPeersRequestAfterRandomDelay(nodeAddress);
} else { } else {
log.trace("We have started already a peerExchangeHandler. " + log.trace("We have started already a peerExchangeHandler. " +
"We ignore that call. nodeAddress=" + nodeAddress); "We ignore that call. nodeAddress={}", nodeAddress);
} }
} else { } else {
log.trace("We have stopped already. We ignore that requestReportedPeers call."); log.trace("We have stopped already. We ignore that requestReportedPeers call.");

View file

@ -865,8 +865,8 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
if (sequenceNumberMap.containsKey(hashOfData)) { if (sequenceNumberMap.containsKey(hashOfData)) {
int storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr; int storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr;
if (newSequenceNumber > storedSequenceNumber) { if (newSequenceNumber > storedSequenceNumber) {
log.trace("Sequence number has increased (>). sequenceNumber = " /*log.trace("Sequence number has increased (>). sequenceNumber = "
+ newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber + " / hashOfData=" + hashOfData.toString()); + newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber + " / hashOfData=" + hashOfData.toString());*/
return true; return true;
} else if (newSequenceNumber == storedSequenceNumber) { } else if (newSequenceNumber == storedSequenceNumber) {
String msg; String msg;