mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Minor requested changes (non-github batch)
This commit is contained in:
parent
6dec780ab4
commit
a92b6ad9dc
@ -492,8 +492,12 @@ public class BisqSetup {
|
||||
// local node is detected, but badly configured.
|
||||
var detectedButMisconfigured = localBitcoinNode.isDetectedButMisconfigured();
|
||||
if (detectedButMisconfigured) {
|
||||
displayLocalNodeMisconfigurationHandler.accept(nextStep);
|
||||
return;
|
||||
if (displayLocalNodeMisconfigurationHandler != null) {
|
||||
displayLocalNodeMisconfigurationHandler.accept(nextStep);
|
||||
return;
|
||||
} else {
|
||||
log.error("displayLocalNodeMisconfigurationHandler undefined", new RuntimeException());
|
||||
}
|
||||
}
|
||||
|
||||
nextStep.run();
|
||||
@ -566,7 +570,8 @@ public class BisqSetup {
|
||||
|
||||
// We only init wallet service here if not using Tor for bitcoinj.
|
||||
// When using Tor, wallet init must be deferred until Tor is ready.
|
||||
if (!preferences.getUseTorForBitcoinJ()) {
|
||||
// TODO encapsulate below conditional inside getUseTorForBitcoinJ
|
||||
if (!preferences.getUseTorForBitcoinJ() || localBitcoinNode.willUse()) {
|
||||
initWallet();
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Detects whether a Bitcoin node is running on localhost and whether it is well
|
||||
* configured (meaning it's not pruning and has bloom filters enabled). The public
|
||||
@ -285,10 +287,7 @@ public class LocalBitcoinNode {
|
||||
|
||||
var localPeerAddress = new PeerAddress(InetAddress.getLocalHost(), port);
|
||||
|
||||
AbstractBlockChain blockchain = null;
|
||||
|
||||
var peer = new Peer(networkParameters, ourVersionMessage, localPeerAddress, blockchain);
|
||||
return peer;
|
||||
return new Peer(networkParameters, ourVersionMessage, localPeerAddress, null);
|
||||
}
|
||||
|
||||
/* Creates an NioClient that is expected to only be used to coerce a VersionMessage
|
||||
@ -300,9 +299,8 @@ public class LocalBitcoinNode {
|
||||
|
||||
// This initiates the handshake procedure, which, if successful, will complete
|
||||
// the peerVersionMessageFuture, or be cancelled, in case of failure.
|
||||
NioClient client = new NioClient(serverAddress, peer, connectionTimeout);
|
||||
|
||||
return client;
|
||||
return new NioClient(serverAddress, peer, connectionTimeout);
|
||||
}
|
||||
|
||||
private static Level silence(Class<?> klass) {
|
||||
@ -338,29 +336,26 @@ public class LocalBitcoinNode {
|
||||
);
|
||||
|
||||
PeerDisconnectedEventListener cancelIfConnectionFails =
|
||||
new PeerDisconnectedEventListener() {
|
||||
public void onPeerDisconnected(Peer peer, int peerCount) {
|
||||
var peerVersionMessageAlreadyReceived =
|
||||
peerVersionMessageFuture.isDone();
|
||||
if (peerVersionMessageAlreadyReceived) {
|
||||
// This method is called whether or not the handshake was
|
||||
// successful. In case it was successful, we don't want to do
|
||||
// anything here.
|
||||
return;
|
||||
}
|
||||
// In some cases Peer will self-disconnect after receiving
|
||||
// node's VersionMessage, but before completing the handshake.
|
||||
// In such a case, we want to retrieve the VersionMessage.
|
||||
var peerVersionMessage = peer.getPeerVersionMessage();
|
||||
if (peerVersionMessage != null) {
|
||||
log.info("Handshake attempt was interrupted;"
|
||||
+ " however, the local node's version message was coerced.");
|
||||
peerVersionMessageFuture.set(peerVersionMessage);
|
||||
} else {
|
||||
log.info("Handshake attempt did not result in a version message exchange.");
|
||||
var mayInterruptWhileRunning = true;
|
||||
peerVersionMessageFuture.cancel(mayInterruptWhileRunning);
|
||||
}
|
||||
(Peer disconnectedPeer, int peerCount) -> {
|
||||
var peerVersionMessageAlreadyReceived =
|
||||
peerVersionMessageFuture.isDone();
|
||||
if (peerVersionMessageAlreadyReceived) {
|
||||
// This method is called whether or not the handshake was
|
||||
// successful. In case it was successful, we don't want to do
|
||||
// anything here.
|
||||
return;
|
||||
}
|
||||
// In some cases Peer will self-disconnect after receiving
|
||||
// node's VersionMessage, but before completing the handshake.
|
||||
// In such a case, we want to retrieve the VersionMessage.
|
||||
var peerVersionMessage = disconnectedPeer.getPeerVersionMessage();
|
||||
if (peerVersionMessage != null) {
|
||||
log.info("Handshake attempt was interrupted;"
|
||||
+ " however, the local node's version message was coerced.");
|
||||
peerVersionMessageFuture.set(peerVersionMessage);
|
||||
} else {
|
||||
log.info("Handshake attempt did not result in a version message exchange.");
|
||||
peerVersionMessageFuture.cancel(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user