Skip to content

Commit

Permalink
Remove unnecessary LOCAL_BITCOIN_NODE_PORT constant
Browse files Browse the repository at this point in the history
This was originally added with the intention that the local Bitcoin node
port could be customized, but in fact it never could be, because Guice
configuration always hard-wired the value to the default port for the
CurrentBaseNetwork's Parameters (eg. 8333 for BTC_MAINNET).

This change removes the constant, removes any Guice wiring and injection
and localizes the hard-coded assignment to the LocalBitcoinNode
constructor to simplify and make things explicit.

If it is desired to allow users to specify a custom port for their local
Bitcoin node, a proper option shoud be added to Config. In the meantime,
users may work around this by using `--btcNodes=localhost:4242` where
4242 is the custom port. Note however, that the pruning and bloom filter
checks will not occur in this case as the provided node address will not
being treated as a LocalBitcoinNode.
  • Loading branch information
cbeams committed Feb 27, 2020
1 parent c1a99cc commit 57b7041
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
5 changes: 0 additions & 5 deletions core/src/main/java/bisq/core/app/CoreModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.io.File;

import static bisq.common.config.Config.*;
import static bisq.core.btc.nodes.LocalBitcoinNode.LOCAL_BITCOIN_NODE_PORT;
import static com.google.inject.name.Names.named;

public class CoreModule extends AppModule {
Expand Down Expand Up @@ -78,10 +77,6 @@ protected void configure() {
bindConstant().annotatedWith(named(USE_DEV_MODE)).to(config.useDevMode);
bindConstant().annotatedWith(named(REFERRAL_ID)).to(config.referralId);

bindConstant().annotatedWith(named(LOCAL_BITCOIN_NODE_PORT))
.to(config.baseCurrencyNetworkParameters.getPort());


// ordering is used for shut down sequence
install(new TradeModule(config));
install(new EncryptionServiceModule(config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ protected void configure() {
bindConstant().annotatedWith(named(USE_DEV_MODE)).to(config.useDevMode);
bindConstant().annotatedWith(named(REFERRAL_ID)).to(config.referralId);

bindConstant().annotatedWith(named(LOCAL_BITCOIN_NODE_PORT))
.to(config.baseCurrencyNetworkParameters.getPort());

// ordering is used for shut down sequence
install(new TradeModule(config));
install(new EncryptionServiceModule(config));
Expand Down
7 changes: 2 additions & 5 deletions core/src/main/java/bisq/core/btc/nodes/LocalBitcoinNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.bitcoinj.net.NioClientManager;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import com.google.common.util.concurrent.FutureCallback;
Expand Down Expand Up @@ -48,8 +47,6 @@
@Singleton
public class LocalBitcoinNode {

public static final String LOCAL_BITCOIN_NODE_PORT = "localBitcoinNodePort";

private static final Logger log = LoggerFactory.getLogger(LocalBitcoinNode.class);
private static final int CONNECTION_TIMEOUT = 5000;

Expand All @@ -60,9 +57,9 @@ public class LocalBitcoinNode {
private Boolean wellConfigured;

@Inject
public LocalBitcoinNode(Config config, @Named(LOCAL_BITCOIN_NODE_PORT) int port) {
public LocalBitcoinNode(Config config) {
this.config = config;
this.port = port;
this.port = config.baseCurrencyNetworkParameters.getPort();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/java/bisq/core/user/PreferencesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setUp() {

storage = mock(Storage.class);
Config config = new Config();
LocalBitcoinNode localBitcoinNode = new LocalBitcoinNode(config, config.baseCurrencyNetworkParameters.getPort());
LocalBitcoinNode localBitcoinNode = new LocalBitcoinNode(config);
preferences = new Preferences(
storage, config, localBitcoinNode, null, null, Config.DEFAULT_FULL_DAO_NODE,
null, null, Config.UNSPECIFIED_PORT);
Expand Down

0 comments on commit 57b7041

Please sign in to comment.