Commit Graph

924 Commits

Author SHA1 Message Date
Chris Beams
8f8866da6a
Introduce io.bitsquare.btc.UserAgent
This makes things generally more explicit and reduces the number of
String arguments in the WalletFacade constructor.
2014-11-11 12:27:18 +01:00
Chris Beams
b10958e790
Introduce explicit dir and prefix params in Persistence
Like the previous commit, this change eliminates the reliance on
"appName" within the Persistence class in favor of explicit and
independently configurable parameters.

Additionally, the FileUtil class has been removed as it is no longer
necessary.
2014-11-11 12:24:58 +01:00
Chris Beams
8f76a1d37b
Introduce explicit wallet and useragent params in WalletFacade
Previously, WalletFacade relied on "appName" to derive all information
related to the location of the bitcoinj wallet, the prefix of that
wallet, and the useragent name that will be used for bitcoin version
messages.

Now explicit parameters have been exposed for each of these, making for
a clearer and more configurable arrangement. The values associated with
each parameter still default to the value of "appName" (usually
"Bitsquare", "Bitsquare-Alice", or similar), however the assignment of
these defaults is now done in BitsquareEnvironment#defaultProperties
PropertySource. This approach allows for overriding any or all of these
parameters in any of the property sources that have higher precedence
than the default set, (e.g. in system environment variables, the
bitsquare.properties file, etc).

As a result of these changes, WalletFacade now has no awareness whatsover
of the Bitsquare "application", which is as it should be. This change
removes a conceptual tangle, and what would have become a code-level
tangle had we tried to replace the use of @Named("appName") with a
reference to BitsquareEnvironment#APP_NAME_KEY.

This begins a series of such changes, in which references to "appName"
will be eliminated in favor of similar explicit parameters.
2014-11-11 11:53:58 +01:00
Chris Beams
fd033faae3
Rename environment "app properties"=>"default properties" 2014-11-11 10:27:21 +01:00
Chris Beams
2b3c22d382
Merge branch 'wip-cbeams'
* wip-cbeams:
  Overhaul property management and main class infrastructure

Conflicts:
	build.gradle
2014-11-11 04:28:14 +01:00
Chris Beams
acf44128b2
Overhaul property management and main class infrastructure
Use of the Spring Environment
-----------------------------

This change replaces the use of the argparse4j library and basic
Properties objects with the Spring Framework's Environment abstraction.
The Environment allows for managing any number of 'property sources' in
a hierarchical fashion, such that a call to
`environment.getProperty("someKey")` iterates through an ordered set of
property sources, returning the first value associated with the given
key.

BitsquareEnvironment, introduced in this commit, eliminates the
functionality previously present in ConfigLoader, modeling the
bitsquare.conf and bitsquare.properties files as Spring Resource
objects, and in turn creating ResourcePropertySources out of them. These
custom property sources are combined with standard property sources
based on system environment variables and Java system properties as well
as a property source based on the command-line arguments passed to a
Bitsquare application to form a unified, one-stop configuration
hierarchy.

For example, let's say a Bitsquare user wishes to customize the port
that his Bitsquare application listens on. The simplest approach
(assuming the user is comfortable with the command line), would be the
following:

    java -jar bitsquare.jar --port=1234

where '1234' is the custom port of choice. This is convenient enough for
one-off experimentation, but if the user wishes to make this a permanent
arrangement, he may want to add a `port=1234` entry to his
{bitsquare_app_dir}/bitsquare.conf file.

Alternatively, the user may wish to specify the port value as an
environment variable, e.g.:

    PORT=1234 java -jar bitsquare.jar

or with a JVM system property, e.g.:

    java -jar -DPORT=1234 bitsquare.jar

With BitsquareEnvironment, and its customized set of PropertySources in
place, the value of the port property may be specified in any of the
ways described above, and it is all handled in a unified way.

Restructuring of *Main classes
------------------------------

This commit also introduces significant changes to the structure of
executable Bitsquare applications. For example, prior to this change,
the io.bitsquare.app.gui.Main class was responsible for being both a
JavaFX Application and a standard Java main class.

Now, however, these concerns have been renamed and separated.
BitsquareApp is the JavaFX Application, and BitsquareAppMain is the Java
main class. Likewise, BootstrapNode has been broken out into
BootstrapNode and BootstrapNodeMain.

A common base class for the *Main classes has been extracted, named
BitsquareExecutable, which creates a template for option parsing,
environment creation, and ultimately application execution that applies
both to the BootstrapNode and BitsquareApp cases.

Improved help text
------------------

With the removal of argparse4j and the introduction of JOpt for argument
parsing, the application's help text has been improved. Use --help to
display this text, where you'll see information about default values,
etc. To do this easily from the Gradle build, run any of the following
commands:

    # Display help text
    ./gradlew run -Pargs="--help"

    # Qualify the application name as "Bitsquare-Alice"
    ./gradlew run -Pargs="--appName=Alice"

    # Customize the port
    ./gradlew run -Pargs="--port=7377"

Renaming of FatalException
--------------------------

Finally, the exception formerly known as io.bitsquare.gui.FatalException
has been moved up a package and generalized to
io.bitsquare.BitsquareException, as it is now used more widely.
2014-11-11 04:20:48 +01:00
Manfred Karrer
28edc0bf60 Deactivate success check for GetPeerAddress, User baseFuture.isSuccess() 2014-11-11 02:56:28 +01:00
Manfred Karrer
4a765cd27a Fix wrong else clause 2014-11-11 02:41:47 +01:00
Manfred Karrer
475be0d676 Add testAddGetWithReconnect test 2014-11-11 02:31:39 +01:00
Manfred Karrer
a3abd2fd69 Remove test classes 2014-11-11 02:17:48 +01:00
Manfred Karrer
0f65441700 Set prefHeight for HBoxes to prevent layout jumping 2014-11-11 02:10:31 +01:00
Manfred Karrer
d92ab1d310 Deactivate notifications on windows (#268) 2014-11-11 02:07:45 +01:00
Manfred Karrer
78a09d874d Update TomP2P aa0c736 2014-11-11 00:01:53 +01:00
Manfred Karrer
882b7c2842 Remove storage 2014-11-10 16:02:33 +01:00
Chris Beams
efe6c1bec9
Merge branch 'wip-cbeams'
* wip-cbeams: (24 commits)
  Allow configurability of bitcoin network with --bitcoin.network
  Eliminate BootstrapNodes#DIGITAL_OCEAN_1_DEV
  Move comments regarding default ports to Node#DEFAULT_PORT
  Rename BootstrapNodes#{DEFAULT_BOOTSTRAP_NODE=>DEFAULT}
  Rename app.cli.{SeedNode => BootstrapNode}
  Remove dead code from UtilsDHT2.java
  Remove commented code from SeedNode
  Remove obsolete SeedNodeForTesting class
  Rename networkInterface => interface
  Eliminate the option to use TomP2P disk storage (for now)
  Expose --port command-line option
  Rename Node#{id => name}
  Allow command-line configuration of local node id and port
  Polish whitespace
  Qualify id, ip and port options with 'bootstrap.node.*'
  Extract clientPort constant
  Introduce NETWORK_INTERFACE_UNSPECIFIED contstant
  Move {MessageModule=>TomP2PMessageModule}#NETWORK_INTERFACE_KEY
  Use extracted NETWORK_INTERFACE_KEY consistently
  Polish TomP2PMessageModule#doConfigure
  ...

Conflicts:
	src/test/java/io/bitsquare/msg/TomP2PTests.java
2014-11-10 15:43:46 +01:00
Chris Beams
8c9557c891
Allow configurability of bitcoin network with --bitcoin.network
This commit changes the previous option value of 'networkType' to
'bitcoin.network' and exposes it through the ArgumentParser.
2014-11-10 15:42:16 +01:00
Manfred Karrer
bdcd60d1fe Add connection icons, handleError cases in one method 2014-11-10 15:15:49 +01:00
Chris Beams
adfd8b2ac4
Eliminate BootstrapNodes#DIGITAL_OCEAN_1_DEV
Instead of including testing-related bootstrap nodes in the
BootstrapNodes class, this change introduces a Node#withPort method that
allows for obtaining a copy of an existing bootstrap node (e.g.
DIGITAL_OCEAN_1) with a modified port value.

This approach to `with*` methods allows for convenient customization of
value types without sacrificing immutability. See [1] for details.

[1]: http://blog.joda.org/2014/03/valjos-value-java-objects.html
2014-11-10 15:04:43 +01:00
Chris Beams
5ab837658b
Move comments regarding default ports to Node#DEFAULT_PORT 2014-11-10 15:04:43 +01:00
Chris Beams
50e27014fb
Rename BootstrapNodes#{DEFAULT_BOOTSTRAP_NODE=>DEFAULT}
Also, reorganize and comment other Node fields exposed by
BootstrapNodes.
2014-11-10 15:04:43 +01:00
Chris Beams
56409c0177
Rename app.cli.{SeedNode => BootstrapNode}
With this commit we're now using the naming "bootstrap node" everywhere
as opposed to the more fuzzy notion of "seed node" (which was originally
borrowed from Bitcoin Core, but doesn't really describe what we're up to
very well.

As it turns out, Kademlia also uses the terminology "bootstrap node" [1], so
we're in good company with this change.

[1]: https://en.wikipedia.org/wiki/Kademlia#Joining_the_network
2014-11-10 15:04:42 +01:00
Chris Beams
117b4ce5dc
Remove dead code from UtilsDHT2.java 2014-11-10 15:04:42 +01:00
Chris Beams
519cfb8957
Remove commented code from SeedNode 2014-11-10 15:04:41 +01:00
Chris Beams
879ff57789
Remove obsolete SeedNodeForTesting class 2014-11-10 15:04:41 +01:00
Chris Beams
a56ac8e454
Rename networkInterface => interface
i.e., pass `--interface` vs. `--networkInterface` at the command line.
2014-11-10 15:04:41 +01:00
Chris Beams
396fd089ca
Eliminate the option to use TomP2P disk storage (for now)
In practice we always use TomP2P's in-memory storage. Eliminate the
useDiskStorage option for now, in order to simplify the ongoing
refactoring efforts.
2014-11-10 15:04:40 +01:00
Chris Beams
737d1855d1
Expose --port command-line option 2014-11-10 15:04:26 +01:00
Chris Beams
3398a97311
Rename Node#{id => name}
Refer to the "name" of a node rather than its "id". This is reflected in
the command line options as well. Instead of `--id`, now pass `--name`.
Instead of `--bootstrap.node.id`, now pass `--bootstrap.node.id`.
2014-11-10 14:34:30 +01:00
Manfred Karrer
7ccfd98fb9 Allow shutting down the app with window close/quit 2014-11-10 13:51:10 +01:00
Manfred Karrer
865fe73bfb Remove random ports and static ID 2014-11-10 13:17:06 +01:00
Chris Beams
2ae5949448
Allow command-line configuration of local node id and port
This change does away with the notion of "clientPort" and replaces it,
simply, with "port". There are only two ports we care about in
Bitsquare:

 1. The port that the local node (i.e. a Bitsquare UI running on
    your laptop) listens on. This value is now specified with `--port`

 2. The port of the bootstrap node that the local node will connect to on
    its first run. This value is specified with `--bootstrap.node.port`

So, for example, the following is a valid commandline invocation:

    java -jar bitsquare.jar --port 1234 --bootstrap.node.port=9876

Both of these values default to Node.DEFAULT_PORT (currently 7366)

This commit also introduces the --id flag for configuring the ID of the
local node.
2014-11-10 13:05:14 +01:00
Chris Beams
cb0e214a28
Polish whitespace 2014-11-10 13:04:55 +01:00
Chris Beams
9ddf075366
Qualify id, ip and port options with 'bootstrap.node.*'
This change clarifies the relationship between the Bitsquare node that
is being run (the local node) and the Bitsquare node that the local node
is being bootstrapped against (the bootstrap node).

Prior to this change, customizing bootstrap node looked like this:

    java -jar bitsquare.jar --ip=203.0.113.3

Now it looks like this:

    java -jar bitsquare.jar --bootstrap.node.ip=203.0.113.3

This change also removes entirely the short option strings (-d, -s, -p,
-i) for simplicity and clarity while these values are undergoing change.

By qualifying bootstrap node options explicitly in this fashion, we make
way for customizing the the same values against the local node. These
changes will come with subsequent commits.
2014-11-10 13:04:55 +01:00
Chris Beams
bad88f1612
Extract clientPort constant 2014-11-10 13:04:52 +01:00
Chris Beams
85f5f02378
Introduce NETWORK_INTERFACE_UNSPECIFIED contstant
Use an explicit value of "<unspecified>" vs. empty string ("") for
clarity when the user has not specified a network interface to use.
2014-11-10 13:04:04 +01:00
Chris Beams
ed76f73897
Move {MessageModule=>TomP2PMessageModule}#NETWORK_INTERFACE_KEY
This change moves the NETWORK_INTERFACE_KEY into
BootstrappedPeerFactory, where it is actually used, but because
BootstrappedPeerFactory is package-private and has no other reason to be
public, NETWORK_INTERFACE_KEY is re-exposed publicly through
TomP2PMessageModule, where it can be used by types in the
io.bitsquare.app* packages.
2014-11-10 13:03:40 +01:00
Chris Beams
9e00c3d85e
Use extracted NETWORK_INTERFACE_KEY consistently 2014-11-10 08:49:50 +01:00
Chris Beams
7e3c53ac24
Polish TomP2PMessageModule#doConfigure 2014-11-10 08:49:46 +01:00
Chris Beams
8723e9ef0d
Move {MessageModule=>TomP2PMessageModule}#BOOTSTRAP_NODE_*_KEY 2014-11-10 08:26:56 +01:00
Chris Beams
9bdb4b4249
Move {MessageModule=>BootstrappedPeerFactory}#BOOTSTRAP_NODE_KEY 2014-11-10 08:20:15 +01:00
Chris Beams
426ee28b93
Extract TomP2PNode#USE_DISK_STORAGE_KEY constant 2014-11-10 08:09:28 +01:00
Chris Beams
9f2e9de94f
Extract MessageModule.BOOTSTRAP_NODE_KEY constant 2014-11-10 08:09:18 +01:00
Manfred Karrer
05a86f251f Add interface argument 2014-11-10 02:08:54 +01:00
Manfred Karrer
775a391be3 Add ChannelClientConfiguration 2014-11-10 01:51:25 +01:00
Manfred Karrer
954fb7727c Add bootstrap 2014-11-10 01:48:20 +01:00
Manfred Karrer
501a3ccbc2 Merge remote-tracking branch 'origin/master' 2014-11-10 01:35:17 +01:00
Manfred Karrer
2ec1fe1c59 Sync with Thomas changes, add bootstrap call 2014-11-10 01:35:08 +01:00
Manfred Karrer
c1a645500f Remove caching as it has some side effects for failing tests 2014-11-10 01:10:45 +01:00
Chris Beams
ccc369307c
Use explicit "appName" vs. "name" property
i.e. when running the app, pass

    java -jar bitsquare.jar --appName Alice

vs.

    java -jar bitsquare.jar --name Alice
2014-11-10 01:08:34 +01:00
Chris Beams
e8986aa7a2
Rename NAME_FLAG => APP_NAME_KEY and move to AppModule 2014-11-10 00:50:59 +01:00