mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Merge pull request #4573 from chimp1984/remove-debug-logs
Cleanup debug logs
This commit is contained in:
commit
8b751d095c
34 changed files with 87 additions and 198 deletions
|
@ -35,7 +35,7 @@ public class MasterTimer {
|
|||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserThread.execute(() -> listeners.stream().forEach(Runnable::run));
|
||||
UserThread.execute(() -> listeners.forEach(Runnable::run));
|
||||
}
|
||||
}, FRAME_INTERVAL_MS, FRAME_INTERVAL_MS);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class Capabilities {
|
|||
|
||||
// Defines which most recent capability any node need to support.
|
||||
// This helps to clean network from very old inactive but still running nodes.
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final Capability MANDATORY_CAPABILITY = Capability.DAO_STATE;
|
||||
|
||||
protected final Set<Capability> capabilities = new HashSet<>();
|
||||
|
|
|
@ -39,7 +39,7 @@ public enum BaseCurrencyNetwork {
|
|||
@Getter
|
||||
private final String network;
|
||||
@Getter
|
||||
private String currencyName;
|
||||
private final String currencyName;
|
||||
|
||||
BaseCurrencyNetwork(NetworkParameters parameters, String currencyCode, String network, String currencyName) {
|
||||
this.parameters = parameters;
|
||||
|
|
|
@ -110,7 +110,7 @@ public class BisqHelpFormatter implements HelpFormatter {
|
|||
// without any spaces (e.g. a URL) are allowed to overflow the 80-char margin.
|
||||
while (remainder.length() > 72) {
|
||||
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);
|
||||
int idxLastSpace = chunk.lastIndexOf(' ');
|
||||
int idxBreak = idxLastSpace > 0 ? idxLastSpace : chunk.length();
|
||||
|
|
|
@ -722,7 +722,7 @@ public class Config {
|
|||
this.providers = options.valuesOf(providersOpt);
|
||||
this.seedNodes = options.valuesOf(seedNodesOpt);
|
||||
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.socks5ProxyBtcAddress = options.valueOf(socks5ProxyBtcAddressOpt);
|
||||
this.socks5ProxyHttpAddress = options.valueOf(socks5ProxyHttpAddressOpt);
|
||||
|
@ -815,6 +815,7 @@ public class Config {
|
|||
private static String randomAppName() {
|
||||
try {
|
||||
File file = Files.createTempFile("Bisq", "Temp").toFile();
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.delete();
|
||||
return file.toPath().getFileName().toString();
|
||||
} catch (IOException ex) {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package bisq.common.crypto;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
import bisq.common.util.Hex;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
|
@ -65,9 +65,7 @@ public class Encryption {
|
|||
try {
|
||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO);
|
||||
keyPairGenerator.initialize(2048);
|
||||
KeyPair keyPair = keyPairGenerator.genKeyPair();
|
||||
log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts);
|
||||
return keyPair;
|
||||
return keyPairGenerator.genKeyPair();
|
||||
} catch (Throwable e) {
|
||||
log.error("Could not create key.", e);
|
||||
throw new RuntimeException("Could not create key.");
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.google.inject.Provider;
|
|||
|
||||
public class PubKeyRingProvider implements Provider<PubKeyRing> {
|
||||
|
||||
private PubKeyRing pubKeyRing;
|
||||
private final PubKeyRing pubKeyRing;
|
||||
|
||||
@Inject
|
||||
public PubKeyRingProvider(KeyRing keyRing) {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package bisq.common.crypto;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
import bisq.common.util.Base64;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
|
@ -60,9 +60,7 @@ public class Sig {
|
|||
try {
|
||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO);
|
||||
keyPairGenerator.initialize(1024);
|
||||
KeyPair keyPair = keyPairGenerator.genKeyPair();
|
||||
log.trace("Generate msgSignatureKeyPair needed {} ms", System.currentTimeMillis() - ts);
|
||||
return keyPair;
|
||||
return keyPairGenerator.genKeyPair();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
log.error("Could not create key.", e);
|
||||
throw new RuntimeException("Could not create key.");
|
||||
|
|
|
@ -39,7 +39,6 @@ public interface UserThreadMappedPersistableEnvelope extends PersistableEnvelope
|
|||
default Message toPersistableMessage() {
|
||||
FutureTask<Message> toProtoOnUserThread = new FutureTask<>(this::toProtoMessage);
|
||||
UserThread.execute(toProtoOnUserThread);
|
||||
//noinspection UnstableApiUsage
|
||||
return Futures.getUnchecked(toProtoOnUserThread);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
@Singleton
|
||||
public class CorruptedDatabaseFilesHandler {
|
||||
private List<String> corruptedDatabaseFiles = new ArrayList<>();
|
||||
private final List<String> corruptedDatabaseFiles = new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
public CorruptedDatabaseFilesHandler() {
|
||||
|
|
|
@ -239,7 +239,6 @@ public class FileManager<T extends PersistableEnvelope> {
|
|||
try {
|
||||
if (fileOutputStream != null)
|
||||
fileOutputStream.close();
|
||||
//noinspection ConstantConditions,ConstantConditions
|
||||
if (printWriter != null)
|
||||
printWriter.close();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -110,14 +110,14 @@ public class FileUtil {
|
|||
File[] files = file.listFiles();
|
||||
if (files != null)
|
||||
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;
|
||||
if (!excludeFileFoundLocal)
|
||||
deleteDirectory(f, exclude, ignoreLockedFiles);
|
||||
}
|
||||
}
|
||||
// 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 {
|
||||
deleteFileIfExists(file, ignoreLockedFiles);
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -62,7 +62,7 @@ class DesktopUtil {
|
|||
}
|
||||
|
||||
if (os.isWindows()) {
|
||||
if (runCommand("explorer", "%s", what)) return true;
|
||||
return runCommand("explorer", "%s", what);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -156,11 +156,10 @@ class DesktopUtil {
|
|||
int value = p.exitValue();
|
||||
if (value == 0) {
|
||||
logErr("Process ended immediately.");
|
||||
return false;
|
||||
} else {
|
||||
logErr("Process crashed.");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
} catch (IllegalThreadStateException e) {
|
||||
logErr("Process is running.");
|
||||
return true;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -72,7 +72,7 @@ public class MathUtils {
|
|||
}
|
||||
|
||||
public static long doubleToLong(double value) {
|
||||
return new Double(value).longValue();
|
||||
return Double.valueOf(value).longValue();
|
||||
}
|
||||
|
||||
public static double scaleUpByPowerOf10(double value, int exponent) {
|
||||
|
@ -115,10 +115,10 @@ public class MathUtils {
|
|||
}
|
||||
|
||||
public static class MovingAverage {
|
||||
Deque<Long> window;
|
||||
private int size;
|
||||
final Deque<Long> window;
|
||||
private final int size;
|
||||
private long sum;
|
||||
private double outlier;
|
||||
private final double outlier;
|
||||
|
||||
// Outlier as ratio
|
||||
public MovingAverage(int size, double outlier) {
|
||||
|
|
|
@ -425,13 +425,13 @@ public class Utilities {
|
|||
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)
|
||||
return "null";
|
||||
|
||||
|
||||
String result = StringUtils.abbreviate(message.toString(), maxLength);
|
||||
if (removeLinebreaks)
|
||||
if (removeLineBreaks)
|
||||
return result.replace("\n", "");
|
||||
|
||||
return result;
|
||||
|
|
|
@ -336,7 +336,6 @@ public class LiteNodeNetworkService implements MessageListener, ConnectionListen
|
|||
retryCounter++;
|
||||
if (retryCounter <= MAX_RETRY) {
|
||||
retryTimer = UserThread.runAfter(() -> {
|
||||
log.trace("retryTimer called");
|
||||
stopped = false;
|
||||
|
||||
stopRetryTimer();
|
||||
|
|
|
@ -379,7 +379,7 @@ public abstract class DisputeManager<T extends DisputeList<? extends DisputeList
|
|||
|
||||
Trade trade = optionalTrade.get();
|
||||
try {
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
trade.getDelayedPayoutTx(),
|
||||
dispute,
|
||||
daoFacade,
|
||||
|
|
|
@ -66,7 +66,7 @@ public abstract class DisputeAgentService<T extends DisputeAgent> {
|
|||
!Utilities.encodeToHex(disputeAgent.getRegistrationPubKey()).equals(DevEnv.DEV_PRIVILEGE_PUB_KEY)) {
|
||||
boolean result = p2PService.addProtectedStorageEntry(disputeAgent);
|
||||
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();
|
||||
} else {
|
||||
errorMessageHandler.handleErrorMessage("Add disputeAgent failed");
|
||||
|
@ -82,7 +82,7 @@ public abstract class DisputeAgentService<T extends DisputeAgent> {
|
|||
ErrorMessageHandler errorMessageHandler) {
|
||||
log.debug("removeDisputeAgent disputeAgent.hashCode() " + disputeAgent.hashCode());
|
||||
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();
|
||||
} else {
|
||||
errorMessageHandler.handleErrorMessage("Remove disputeAgent failed");
|
||||
|
|
|
@ -382,7 +382,7 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
|
|||
private void sendPeerPublishedPayoutTxMessage(Transaction transaction, Dispute dispute, Contract contract) {
|
||||
PubKeyRing peersPubKeyRing = dispute.isDisputeOpenerIsBuyer() ? contract.getSellerPubKeyRing() : contract.getBuyerPubKeyRing();
|
||||
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(),
|
||||
dispute.getTradeId(),
|
||||
p2PService.getAddress(),
|
||||
|
|
|
@ -183,13 +183,13 @@ public class TradeDataValidation {
|
|||
}
|
||||
}
|
||||
|
||||
public static void validatePayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService)
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService)
|
||||
throws AddressException, MissingTxException,
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
validatePayoutTx(trade,
|
||||
validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
null,
|
||||
daoFacade,
|
||||
|
@ -197,14 +197,14 @@ public class TradeDataValidation {
|
|||
null);
|
||||
}
|
||||
|
||||
public static void validatePayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
@Nullable Dispute dispute,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService)
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
@Nullable Dispute dispute,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService)
|
||||
throws AddressException, MissingTxException,
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
validatePayoutTx(trade,
|
||||
validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
dispute,
|
||||
daoFacade,
|
||||
|
@ -212,14 +212,14 @@ public class TradeDataValidation {
|
|||
null);
|
||||
}
|
||||
|
||||
public static void validatePayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService,
|
||||
@Nullable Consumer<String> addressConsumer)
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService,
|
||||
@Nullable Consumer<String> addressConsumer)
|
||||
throws AddressException, MissingTxException,
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
validatePayoutTx(trade,
|
||||
validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
null,
|
||||
daoFacade,
|
||||
|
@ -227,12 +227,12 @@ public class TradeDataValidation {
|
|||
addressConsumer);
|
||||
}
|
||||
|
||||
public static void validatePayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
@Nullable Dispute dispute,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService,
|
||||
@Nullable Consumer<String> addressConsumer)
|
||||
public static void validateDelayedPayoutTx(Trade trade,
|
||||
Transaction delayedPayoutTx,
|
||||
@Nullable Dispute dispute,
|
||||
DaoFacade daoFacade,
|
||||
BtcWalletService btcWalletService,
|
||||
@Nullable Consumer<String> addressConsumer)
|
||||
throws AddressException, MissingTxException,
|
||||
InvalidTxException, InvalidLockTimeException, InvalidAmountException {
|
||||
String errorMsg;
|
||||
|
|
|
@ -306,7 +306,7 @@ public class TradeManager implements PersistedDataHost {
|
|||
}
|
||||
|
||||
try {
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
trade.getDelayedPayoutTx(),
|
||||
daoFacade,
|
||||
btcWalletService);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask {
|
|||
Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
|
||||
checkNotNull(delayedPayoutTx, "trade.getDelayedPayoutTx() must not be null");
|
||||
// Check again tx
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
processModel.getDaoFacade(),
|
||||
processModel.getBtcWalletService());
|
||||
|
|
|
@ -37,7 +37,7 @@ public class BuyerVerifiesPreparedDelayedPayoutTx extends TradeTask {
|
|||
try {
|
||||
runInterceptHook();
|
||||
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
processModel.getPreparedDelayedPayoutTx(),
|
||||
processModel.getDaoFacade(),
|
||||
processModel.getBtcWalletService());
|
||||
|
|
|
@ -82,7 +82,7 @@ public class SigTest {
|
|||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
log.trace("took " + (System.currentTimeMillis() - ts) + " ms.");
|
||||
log.trace("took {} ms.", System.currentTimeMillis() - ts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -541,7 +541,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
AtomicReference<String> donationAddressString = new AtomicReference<>("");
|
||||
Transaction delayedPayoutTx = trade.getDelayedPayoutTx();
|
||||
try {
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
delayedPayoutTx,
|
||||
daoFacade,
|
||||
btcWalletService,
|
||||
|
|
|
@ -80,7 +80,7 @@ public class BuyerStep1View extends TradeStepView {
|
|||
|
||||
private void validatePayoutTx() {
|
||||
try {
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
trade.getDelayedPayoutTx(),
|
||||
model.dataModel.daoFacade,
|
||||
model.dataModel.btcWalletService);
|
||||
|
|
|
@ -624,7 +624,7 @@ public class BuyerStep2View extends TradeStepView {
|
|||
|
||||
private void validatePayoutTx() {
|
||||
try {
|
||||
TradeDataValidation.validatePayoutTx(trade,
|
||||
TradeDataValidation.validateDelayedPayoutTx(trade,
|
||||
trade.getDelayedPayoutTx(),
|
||||
model.dataModel.daoFacade,
|
||||
model.dataModel.btcWalletService);
|
||||
|
|
|
@ -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.GetDataResponse;
|
||||
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.AddPersistableNetworkPayloadMessage;
|
||||
import bisq.network.p2p.storage.messages.RefreshOfferMessage;
|
||||
import bisq.network.p2p.storage.payload.CapabilityRequiringPayload;
|
||||
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
|
||||
|
@ -234,17 +232,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
try {
|
||||
String peersNodeAddress = peersNodeAddressOptional.map(NodeAddress::toString).orElse("null");
|
||||
|
||||
protobuf.NetworkEnvelope proto = networkEnvelope.toProtoNetworkEnvelope();
|
||||
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()) {
|
||||
if (networkEnvelope instanceof PrefixedSealedAndSignedMessage && peersNodeAddressOptional.isPresent()) {
|
||||
setPeerType(Connection.PeerType.DIRECT_MSG_PEER);
|
||||
|
||||
log.debug("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" +
|
||||
|
@ -254,11 +242,6 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
peersNodeAddress, uid, Utilities.toTruncatedString(networkEnvelope), -1);
|
||||
} else if (networkEnvelope instanceof GetDataResponse && ((GetDataResponse) networkEnvelope).isGetUpdatedDataResponse()) {
|
||||
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
|
||||
|
@ -477,7 +460,8 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
}
|
||||
|
||||
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) {
|
||||
String peersNodeAddress = peersNodeAddressOptional.map(NodeAddress::toString).orElse("null");
|
||||
log.debug("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" +
|
||||
|
@ -523,7 +507,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
try {
|
||||
socket.close();
|
||||
} 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) {
|
||||
log.error("Exception at shutdown. " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -539,9 +523,10 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
|
||||
//noinspection UnstableApiUsage
|
||||
MoreExecutors.shutdownAndAwaitTermination(singleThreadExecutor, 500, TimeUnit.MILLISECONDS);
|
||||
//noinspection UnstableApiUsage
|
||||
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
|
||||
if (shutDownCompleteHandler != null)
|
||||
UserThread.execute(shutDownCompleteHandler);
|
||||
|
@ -827,10 +812,9 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||
|
||||
if (networkEnvelope instanceof CloseConnectionMessage) {
|
||||
// If we get a CloseConnectionMessage we shut down
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("CloseConnectionMessage received. Reason={}\n\t" +
|
||||
"connection={}", proto.getCloseConnectionMessage().getReason(), this);
|
||||
}
|
||||
log.debug("CloseConnectionMessage received. Reason={}\n\t" +
|
||||
"connection={}", proto.getCloseConnectionMessage().getReason(), this);
|
||||
|
||||
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)");
|
||||
shutDown(CloseConnectionReason.PEER_BANNED);
|
||||
|
|
|
@ -101,9 +101,9 @@ public abstract class NetworkNode implements MessageListener {
|
|||
|
||||
public SettableFuture<Connection> sendMessage(@NotNull NodeAddress peersNodeAddress,
|
||||
NetworkEnvelope networkEnvelope) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("sendMessage: peersNodeAddress=" + peersNodeAddress + "\n\tmessage=" + Utilities.toTruncatedString(networkEnvelope));
|
||||
}
|
||||
log.debug("Send {} to {}. Message details: {}",
|
||||
networkEnvelope.getClass().getSimpleName(), peersNodeAddress, Utilities.toTruncatedString(networkEnvelope));
|
||||
|
||||
checkNotNull(peersNodeAddress, "peerAddress must not be null");
|
||||
|
||||
Connection connection = getOutboundConnection(peersNodeAddress);
|
||||
|
@ -128,9 +128,9 @@ public abstract class NetworkNode implements MessageListener {
|
|||
try {
|
||||
// can take a while when using tor
|
||||
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);
|
||||
long duration = System.currentTimeMillis() - startTs;
|
||||
log.info("Socket creation to peersNodeAddress {} took {} ms", peersNodeAddress.getFullAddress(),
|
||||
|
@ -146,14 +146,12 @@ public abstract class NetworkNode implements MessageListener {
|
|||
existingConnection = getOutboundConnection(peersNodeAddress);
|
||||
|
||||
if (existingConnection != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("We found in the meantime a connection for peersNodeAddress {}, " +
|
||||
"so we use that for sending the message.\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.",
|
||||
peersNodeAddress.getFullAddress());
|
||||
log.debug("We found in the meantime a connection for peersNodeAddress {}, " +
|
||||
"so we use that for sending the message.\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.",
|
||||
peersNodeAddress.getFullAddress());
|
||||
|
||||
}
|
||||
try {
|
||||
socket.close();
|
||||
} catch (Throwable throwable) {
|
||||
|
@ -168,24 +166,23 @@ public abstract class NetworkNode implements MessageListener {
|
|||
if (!connection.isStopped()) {
|
||||
outBoundConnections.add((OutboundConnection) connection);
|
||||
printOutBoundConnections();
|
||||
connectionListeners.stream().forEach(e -> e.onConnection(connection));
|
||||
connectionListeners.forEach(e -> e.onConnection(connection));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect(CloseConnectionReason closeConnectionReason,
|
||||
Connection connection) {
|
||||
log.trace("onDisconnect connectionListener\n\tconnection={}" + connection);
|
||||
//noinspection SuspiciousMethodCalls
|
||||
outBoundConnections.remove(connection);
|
||||
printOutBoundConnections();
|
||||
connectionListeners.stream().forEach(e -> e.onDisconnect(closeConnectionReason, connection));
|
||||
connectionListeners.forEach(e -> e.onDisconnect(closeConnectionReason, connection));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
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,
|
||||
|
|
|
@ -36,9 +36,8 @@ import bisq.common.config.Config;
|
|||
import bisq.common.proto.persistable.PersistedDataHost;
|
||||
import bisq.common.storage.Storage;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
|
@ -224,8 +223,10 @@ public class PeerManager implements ConnectionListener, PersistedDataHost {
|
|||
boolean seedNode = isSeedNode(connection);
|
||||
Optional<NodeAddress> addressOptional = connection.getPeersNodeAddressOptional();
|
||||
if (log.isDebugEnabled()) {
|
||||
String peer = addressOptional.map(NodeAddress::getFullAddress).orElseGet(() ->
|
||||
"not known yet (connection id=" + connection.getUid() + ")");
|
||||
log.debug("onConnection: peer = {}{}",
|
||||
(addressOptional.isPresent() ? addressOptional.get().getFullAddress() : "not known yet (connection id=" + connection.getUid() + ")"),
|
||||
peer,
|
||||
seedNode ? " (SeedNode)" : "");
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ class RequestDataHandler implements MessageListener {
|
|||
@Override
|
||||
public void onSuccess(Connection connection) {
|
||||
if (!stopped) {
|
||||
log.trace("Send " + getDataRequest + " to " + nodeAddress + " succeeded.");
|
||||
log.trace("Send {} to {} succeeded.", getDataRequest, nodeAddress);
|
||||
} else {
|
||||
log.trace("We have stopped already. We ignore that networkNode.sendMessage.onSuccess call." +
|
||||
"Might be caused by an previous timeout.");
|
||||
|
|
|
@ -276,7 +276,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener,
|
|||
peerExchangeHandler.sendGetPeersRequestAfterRandomDelay(nodeAddress);
|
||||
} else {
|
||||
log.trace("We have started already a peerExchangeHandler. " +
|
||||
"We ignore that call. nodeAddress=" + nodeAddress);
|
||||
"We ignore that call. nodeAddress={}", nodeAddress);
|
||||
}
|
||||
} else {
|
||||
log.trace("We have stopped already. We ignore that requestReportedPeers call.");
|
||||
|
|
|
@ -865,8 +865,8 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
if (sequenceNumberMap.containsKey(hashOfData)) {
|
||||
int storedSequenceNumber = sequenceNumberMap.get(hashOfData).sequenceNr;
|
||||
if (newSequenceNumber > storedSequenceNumber) {
|
||||
log.trace("Sequence number has increased (>). sequenceNumber = "
|
||||
+ newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber + " / hashOfData=" + hashOfData.toString());
|
||||
/*log.trace("Sequence number has increased (>). sequenceNumber = "
|
||||
+ newSequenceNumber + " / storedSequenceNumber=" + storedSequenceNumber + " / hashOfData=" + hashOfData.toString());*/
|
||||
return true;
|
||||
} else if (newSequenceNumber == storedSequenceNumber) {
|
||||
String msg;
|
||||
|
|
Loading…
Add table
Reference in a new issue