Remove unnecessary LOCAL_BITCOIN_NODE_PORT constant

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.
This commit is contained in:
Chris Beams 2020-02-27 09:53:40 +01:00
parent c1a99ccc55
commit 57b7041dfe
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
4 changed files with 3 additions and 14 deletions

View File

@ -47,7 +47,6 @@ import bisq.common.proto.persistable.PersistenceProtoResolver;
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 {
@ -78,10 +77,6 @@ public class CoreModule extends AppModule {
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));

View File

@ -82,9 +82,6 @@ public class ModuleForAppWithP2p extends AppModule {
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));

View File

@ -12,7 +12,6 @@ import org.bitcoinj.net.NioClient;
import org.bitcoinj.net.NioClientManager;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import com.google.common.util.concurrent.FutureCallback;
@ -48,8 +47,6 @@ import org.jetbrains.annotations.NotNull;
@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;
@ -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();
}
/**

View File

@ -60,7 +60,7 @@ public class PreferencesTest {
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);