Commit graph

53 commits

Author SHA1 Message Date
Dave Collins f3cd8174bb Use the new btcdb.SupportedDBs for known db types. 2013-09-15 15:21:46 -05:00
Dave Collins 629a1c9d06 Rework the data path and db type handling.
This commit modifies the way the data paths are handled.  Since there will
ultimately be more data associated with each network than just the block
database, the data path has been modified to be "namespaced" based on the
network.  This allows all data associated with a specific network to
simply use the data path without having to worry about conflicts with data
from other networks.

In addition, this commit renames the block database to "blocks" plus a
suffix which denotes the database type.  This prevents issues that would
otherwise arise if the user decides to use a different database type and
a file/folder with the same name already eixsts but is of the old database
type.  For most users this won't matter, but it does provide nice
properties for testing and development as well since it makes it easy to
go back and forth between database types.

This commit also includes code to upgrade the old database paths to the
new ones so the change is seamless for the user.

Finally, bump the version to 0.2.0.
2013-09-15 14:25:32 -05:00
Dave Collins 252ecf8b00 Add basic infrastructure for upgrading btcd.
This commit adds a basic infrastructure to allow upgrades to happen to
btcd as needed.  This paves the way for the upcoming data path changes to
be automatically updated for the user as needed and also ensures any
future changes that might require upgrades already have an established
way of performing the needed upgrades.
2013-09-15 13:40:26 -05:00
Dave Collins 1c9a7095b3 Change --dbdir flag to --datadir.
This change paves the way for saving more than just the block database to
the filesystem (such as address manager data, index data, etc) where the
name "dbdir" no longer makes sense.
2013-09-13 18:02:10 -05:00
Dave Collins be3dc1837c Gofmt latest dbtype config additions. 2013-09-13 14:52:34 -05:00
Dale Rahn af7aa39624 Allow config file and command line to select between sqlite and levdldb 2013-09-13 10:08:19 -04:00
Dave Collins 33b65f943f Increment waitgroups before goroutines are started.
This commit changes the code so that all calls to .Add on waitgroups
happen before the associated goroutines are launched.   Doing this after
the goroutine could technically cause a race where the goroutine started
and finished before the main goroutine has a chance to increment the
counter.  In our particular case none of the goroutines exit quickly
enough for this to be an issue, but nevertheless the correct way should be
used.
2013-09-12 17:24:37 -05:00
Dave Collins 69efe46eb5 Fix a comment typo and comment outputBufferSize. 2013-09-12 12:11:46 -05:00
Dave Collins e4577ab5f4 Syncrhonize access to the blockPeer map. 2013-09-12 12:10:48 -05:00
Dave Collins f5c03696f7 Remove relay log message and update comment. 2013-09-12 09:29:42 -05:00
Dave Collins b58787f87a Remove block relay from TODO list. 2013-09-12 09:15:38 -05:00
Dave Collins 121f7a47d4 Add block inventory relay.
This commit adds support for relaying blocks between peers.  It keeps
track of inventory that has either already been advertised to remote peers
or advertised by remote peers using a size-limited most recently used
cache.  This helps avoid relaying inventory the peer already knows as
much as possible while not allowing rogue peers to eat up arbitrary
amounts of memory with bogus inventory.
2013-09-11 20:14:13 -05:00
Dave Collins adf7149838 Update for recent btcchain orphan notify change. 2013-09-09 19:58:38 -05:00
Dave Collins 3525552140 Update TODO list in README.md. 2013-09-09 11:01:05 -05:00
Dave Collins afddca6870 Use log.Errorf for error messages with params. 2013-09-09 10:59:31 -05:00
Dave Collins cf7438a646 Rework getblocks handling.
This commit reworks the getblocks handling a bit to clean it up and match
the reference implementation handling.  In particular, it adds monitoring
for when peers request the final block advertised from a previous
getblocks message and automatically avertises the latest known block
inventory to trigger the peer to send another getblocks message.
2013-09-05 01:25:52 -05:00
Dave Collins 83a9bbd4dd Update getheaders unknown block locator handling.
When no blocks in the block locator are found, start with the block after
the genesis block.  This means the client will start over with the genesis
block if unknown block locators are provided.  This mirrors the behavior
in the reference implementation.
2013-09-04 20:46:44 -05:00
Dave Collins f07d427837 Rework and correct getheaders handling.
This commit reworks the getheaders handling a bit to clean it up and match
the reference implementation handling.  In particular, in addition to the
normal handling where headers starting after the block locator up to the
stop hash are served, when no locator hashes are provided, the stop hash
acts as a way to specifically request that header.  Next, an empty headers
message is sent when no hashes provided by the block locator can be
found.  Finally, there was a bug that was limiting the number of headers
that could requested at once to 500 instead of the expected 2000.
2013-09-04 18:17:42 -05:00
Dave Collins cbfee93b74 Modify syncing code to support multiple peers.
Previously the code was only designed to work with a single peer.  This
commit modifies the syncing code to deal with multiple peers.
2013-09-04 10:10:00 -05:00
Dave Collins a69ba92006 Set services to remote peer services for all peers.
Rather than only setting the services field for inbound peers, set it for
all peers.  This field referes to the remote peer's services regardless of
inbound or outbound.
2013-09-03 13:34:27 -05:00
Dave Collins 83407ade61 Rework block fetching code.
This commit significantly reworks the fetching code to interop better with
bitcoind.  In particular, when an inventory message is sent, and the
remote peer requests the final block, the remote peer sends the current
end of the main chain to signal that there are more blocks to get.

Previously this code was automatically requesting more blocks when the
number of in-flight blocks was under a certain threshold.  The original
approach does help alleviate delays in the "request final, wait for
orphan, request more" round trip, but due to the aforementioned mechanism,
it leads to double requests and other subtle issues.
2013-08-30 13:04:50 -05:00
Dave Collins f7387f217a Remove current directory config autoload override.
This was a holder from before there was home directory based config.  The
user can use -C ./btcd.conf if that is the intended goal.
2013-08-19 14:48:46 -05:00
Dave Collins 6acd51f4b4 Only advertise local addr to peers when listenting.
Do not advertise the local address to outbound peers when we aren't
listening and therefore able to accept connections.
2013-08-17 15:26:51 -05:00
Dave Collins 627959adff Ignore config file addpeer entries with --regtest.
When running in regression test mode, it is unlikely the user wants to
connect to permanent peers they have configured in their config file.
This commit modifies the code to ignore the config file entry when in
regression test mode.  The user can still provide -a (or --addpeer) on the
command line to override this if they really want to connect out to a
specific peer during regression test mode.
2013-08-17 14:44:43 -05:00
Dave Collins 60779ea8df Add message blocking semantics to block processing.
This commit modifies the input message handler so that when a remote peer
sends a block, no further messages from that peer are accepted until the
block has been fully processed and therefore known good or bad.  This
helps prevent a malicious peer from queueing up a bunch of bad blocks
before disconnecting (or being disconnected) and wasting memory.

Additionally, this behavior is depended on by at least the block
acceptance test tool as the reference implementation processes blocks in
the same thread and therefore blocks further messages until the block has
been fully processed as well.
2013-08-16 13:40:05 -05:00
Dave Collins 2570ecd2ac Move log closure code into its own file. 2013-08-10 20:07:37 -05:00
Dave Collins f269ad2ff4 Comment the logClosure code. 2013-08-09 16:02:47 -05:00
Dave Collins 8634a2fa01 Refactor peer disconnect code into single func. 2013-08-09 15:57:13 -05:00
John C. Vernaleo 00cd730c3f Add stop command to rpcserver. 2013-08-09 16:20:06 -04:00
Dave Collins a3531957f4 Rework server startup and shutdown sequence.
The commit reworks the server statup and shutdown sequence to ensure the
server can always shutdown cleanly.  The peer code depends on being able
to send messages to the address and block managers, so they need to have
their lifecycle tied to the peer handler to prevent issues with
asynchronous shutdown order.
2013-08-09 14:43:30 -05:00
Dave Collins f80bc8c8f9 Misc comment and doco cleanup. 2013-08-08 12:47:15 -05:00
David Hill 52416ec28f new option --tor (requires --proxy)
Although not required if the proxy set is indeed Tor, setting this option
does the following:
   - Sends DNS queries over the Tor network (during dns seed lookup).  This
     stops your IP from being leaked via DNS.
   - Does not disable the listening port.  This allows the hidden services
     feature of Tor to be used.
2013-08-08 12:11:39 -04:00
Dave Collins 41910c0944 Import needed package. 2013-08-08 10:11:03 -05:00
Dave Collins 1fecbec3df Move userAgent to peer where it's used. 2013-08-08 09:26:18 -05:00
Dave Collins 48d3c5f585 Make user agent use the app version constants. 2013-08-08 09:12:40 -05:00
Dave Collins eab9c1f0c1 Insert genesis block if needed on db load.
Previously, the genesis block was only inserted when the database was
created, but it's possible due to rollback that the database is created
and the genesis block insert gets rolled back if the app is existed too
quickly.  This commit modifies the logic to test the need for the genesis
block any time the database is loaded and insert it if necessary.
2013-08-08 00:47:48 -05:00
Dave Collins aad69df74b Include proxy address in connection messages. 2013-08-08 00:35:45 -05:00
Dave Collins 5ca605dadc Remove duplicate proxy setting from config. 2013-08-08 00:22:10 -05:00
Dave Collins f0a0b06f29 Move sample proxy config near top of net settings. 2013-08-08 00:17:13 -05:00
David Hill 3f782928fd initial proxy code 2013-08-08 00:13:47 -05:00
Dave Collins 9a9f41a2f3 Modify code to use proxy aware NetAddresses.
This paves the way for support with proxied connections.
2013-08-07 23:53:19 -05:00
Dave Collins 0d7bff2444 Remove some unused code. 2013-08-07 23:44:04 -05:00
Dave Collins b759bafa60 Add version information and -V/--version flags. 2013-08-07 18:53:01 -05:00
Dave Collins f168694ecf Convert .gitignore line endings to unix. 2013-08-07 15:00:20 -05:00
Dave Collins 8574846e87 Move btcd to root directory.
This allows easier go get paths.
2013-08-07 12:47:51 -05:00
Dave Collins c9502f0932 Add option to disable listen for incoming conns.
This commit provide support for a new nolisten option which disables
listening for incoming connections.  It also disable listening when the
--connect option is used.
2013-08-07 12:37:46 -05:00
Dave Collins 58055a0b5c Reorder some of the config options. 2013-08-07 12:29:45 -05:00
Dave Collins 3195020fee Improve sample-btcd.conf.
This commit improves the sample-btcd.conf file by including some
explanatory text and adding a few more available options.
2013-08-07 12:12:46 -05:00
Dave Collins a9662d3169 Disable RPC server if no user/pass is provided.
This commit disables the RPC server by default if no RPC username of
password is specified (either via the command line or through the config
file).

Closes #2.
2013-08-07 11:02:31 -05:00
Dave Collins ca8496e66d Make IPv4 and IPv6 listen on different sockets.
This commit implements support for listening on multiple sockets and
changes the default listen code to use one socket per address family (IPv4
and IPv6).

In addition, it changes the default listen binding for the RPC server to
localhost so only local clients can connect to it.

There need to be several options added to allow customization of these
settings and those will be in future commits.

Fixes #3.
2013-08-07 10:39:23 -05:00