Skip to content

Commit

Permalink
Merge pull request #2513 from HenrikJannsen/small-fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
djing-chan authored Jul 29, 2024
2 parents 08a7fd1 + 783bf23 commit 024c6d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Node implements Connection.Handler {
@Setter
public static int preferredVersion = 1;
public static int preferredVersion = 0;

public enum State {
NEW,
Expand Down Expand Up @@ -231,6 +231,7 @@ private void doInitialize() {
break;
}
case STARTING: {
// TODO Maybe we should add a sleep here and return once the node is running?
throw new IllegalStateException("Already starting. NetworkId=" + networkId + "; transportType=" + transportType);
}
case RUNNING: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ public CompletableFuture<Boolean> initialize() {

// We write the key to the tor directory. This is used only for the default key, as that is the
// only supported use case (seed nodes, oracle nodes,...)
TorKeyUtils.writePrivateKey(keyBundle.getTorKeyPair(), storagePath, tag);

if (writeDefaultTorPrivateKeyToFile) {
TorKeyUtils.writePrivateKey(keyBundle.getTorKeyPair(), storagePath, tag);
}
return keyBundle;
})
.thenApply(Objects::nonNull);
Expand Down
4 changes: 2 additions & 2 deletions security/src/main/java/bisq/security/keys/TorKeyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.bouncycastle.util.encoders.Base32;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;

Expand All @@ -22,6 +21,7 @@ public static void writePrivateKey(TorKeyPair torKeyPair, Path storageDir, Strin
Path targetPath = Path.of(storageDir.toString(), tag);
File torPrivateKeyDir = targetPath.toFile();
try {
log.info("Store the torPrivateKey into {}", torPrivateKeyDir);
FileUtils.makeDirs(torPrivateKeyDir);
String dir = torPrivateKeyDir.getAbsolutePath();

Expand All @@ -30,7 +30,7 @@ public static void writePrivateKey(TorKeyPair torKeyPair, Path storageDir, Strin

log.info("We persisted the tor private key in hex encoding for onionAddress {} for tag {} to {}.",
torKeyPair.getOnionAddress(), tag, dir);
} catch (IOException e) {
} catch (Exception e) {
log.error("Could not persist torIdentity", e);
}
}
Expand Down

0 comments on commit 024c6d5

Please sign in to comment.