Commit graph

14 commits

Author SHA1 Message Date
Dave Collins
79bb334b9a Remove old regression test db in regtest mode.
The regression test mode is special in that the 'official' block test
suite requires an empty database to work properly.  Rather than having to
manual go delete it before each test, add code to automatically delete the
old regression test database when in regression test mode.
2013-09-15 16:58:02 -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
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
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
e4577ab5f4 Syncrhonize access to the blockPeer map. 2013-09-12 12:10:48 -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
afddca6870 Use log.Errorf for error messages with params. 2013-09-09 10:59:31 -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
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
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
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
8574846e87 Move btcd to root directory.
This allows easier go get paths.
2013-08-07 12:47:51 -05:00
Renamed from btcd/blockmanager.go (Browse further)