Commit graph

3328 commits

Author SHA1 Message Date
Owain G. Ainsworth
163b32887b Add blockmanager.current with extra checks for whether we are up to date.
This uses peer state to confirm if we are up to date, as well as what
chain thinks.
2013-10-17 17:05:18 +01:00
Josh Rickmar
bbcfdcf5aa Clean up notification contexts and goroutines after ws disconnect.
This refactors the wallet notification code to reverse the order of
how notification contexts are stored.  Before, watched addresses and
outpoints were used as keys, with a special reply channel as the
value.  This channel was read from and replies were marshalled and
sent to the main wallet notification chan, but the goroutine handling
this marshalling never exited because the reply channel was never
closed (and couldn't have been, because there was no way to tell it
was handling notifications for any particular wallet).

Notification contexts are now primarily mapped by wallet notification
channels, and code to send the notifications send directly to the
wallet channel, with the previous goroutine reading the reply chan
properly closing.

The RPC code is also refactored with this change as well, to separate
it more from websocket code.  Websocket JSON extensions are no longer
available to RPC clients.

While here, unbreak RPC.  Previously, replies were never sent back.
This broke when I merged in my websocket code, as sends for the reply
channel in jsonRead blocked before a reader for the channel was
opened.  A 3 liner could have fixed this, but doing a proper fix
(changing jsonRead so it did not use the reply channel as it is
unneeded for the standard RPC API) is preferred.
2013-10-17 09:11:55 -04:00
David Hill
90fbae1781 give btcctl some options instead of using hardcoded values 2013-10-16 19:19:26 -04:00
mischief
f346c36a0d add setLimits stub for plan 9 2013-10-16 15:19:21 -05:00
Dave Collins
ae5810bc50 Change default RPC port to 8334 (18334 testnet).
This change paves the way for running btcwallet on the same system without
having to change any settings.  The well-known ports used by the
reference implementation (8332 mainnet, 18332 testnet) will be exposed by
the separate wallet process, which will in turn forward unknown requests
to btcd via websockets (on 8334/18334).  This allows the wallet process to
ultimately provide a unified interface that exposes the same RPC-JSON API
as the reference implementation will maintaining wallet and chain
separation.
2013-10-16 15:01:43 -05:00
Dave Collins
ccfcbebbdc Add config file information to command doc. 2013-10-16 10:16:11 -05:00
Dave Collins
dd6b71300f Add basic btcd command documentation.
This will be expanded upon in future commits.
2013-10-16 10:04:12 -05:00
Dave Collins
f10d2c9449 Add sample relnotes format release script expects. 2013-10-15 18:16:18 -05:00
Dave Collins
b03817c0d8 Add script to help prepare releases. 2013-10-15 18:05:24 -05:00
Dave Collins
f40181615e Unix line endings on CHANGES file. 2013-10-15 17:53:16 -05:00
Dave Collins
5a71ba04a9 Add CHANGES file. 2013-10-15 17:11:43 -05:00
Dave Collins
7eb9deee35 Show the version on server startup. 2013-10-15 15:54:00 -05:00
Dave Collins
b4cbbb1f8b Add 0.3.1 deps to deps.txt. 2013-10-15 12:03:09 -05:00
Dave Collins
8f4a34e4f1 Bump version to 0.3.1. 2013-10-15 12:02:14 -05:00
David Hill
d402cb4196 combine two log statements into one 2013-10-15 12:17:23 -04:00
David Hill
d6adef91f8 Announce our mailing lists 2013-10-15 12:16:17 -04:00
Dave Collins
14f81aa479 Add handler for notfound messages.
For now, these are ignored, but ultimately they should be used to
re-request the missing inventory from another peer.
2013-10-15 10:35:42 -05:00
Dave Collins
3b56ccaff7 Add interface test for NewestSha. 2013-10-15 10:22:46 -05:00
Dave Collins
b7b9823f6c Fix potential issue with dependent orphans.
This commit modifies the main processing loop for orphan dependencies
(orphans that are processed due to their parents showing up) to use an
index based for loop over range.  Since the Go range statement does not
reevaluate on every iteration, it was previously possible under certain
circumstances for the slice to be changed out from under the range
statement while processing the orphan blocks.
2013-10-15 09:50:51 -05:00
Dave Collins
0c8a15a9d5 Add tests to verify integrity after clearing cache.
This commit adds the infrastructure needed to re-run the integrity tests
after calling the InvalidBlockCache, InvalidateTxCache, and
InvalidateCache functions.  The tests intentially randomize the order the
invalidate functions are called in to increase the likelyhood of finding
in issues realted to ordering of the calls.
2013-10-14 20:37:58 -05:00
Dave Collins
54ad820133 Combine two test functions used to fetch tx lists.
The two functions are nearly identical, so rather than repeating the
test code, refactor it into a separate function that takes a flag.
2013-10-14 19:26:23 -05:00
Dave Collins
a9d719f0c4 Separate interface integrity tests.
This paves the way for executing the integrity tests multiple times.
2013-10-14 18:31:01 -05:00
Dave Collins
9ec86518ac Improve interface test error messages.
This commit changes the interface test errors to all report the block
height and hash prior to the failure.  Test failures that transactions
also now report the transaction number and hash.  The makes it much
easier to track down where a test failure occurs.
2013-10-14 18:27:12 -05:00
Jonathan Gillham
fa1d343430 Removed extra local variable assignment from DoubleSha256. 2013-10-14 23:55:18 +01:00
Owain G. Ainsworth
0536e3104c Don't send messages before handshake.
If we haven't handshaken with a peer don't send messages that are not
the handshake. Additionally don't queue up invs for sending, they'll
find out soon enough when they ask us what we know.
2013-10-14 22:27:48 +01:00
Owain G. Ainsworth
36c429c302 Bump maxpeers to 125 like bitcoind.
It helps a lot if our max peers doesn't equal the max we'll try and open
outbound.
2013-10-14 22:27:39 +01:00
Owain G. Ainsworth
3afdc43e69 Fix reference counting when expiring peers. 2013-10-14 22:27:21 +01:00
Dave Collins
c99416c121 Include db type in interface tests loading message. 2013-10-14 14:35:10 -05:00
Dave Collins
01af05c8ac Add interface tests for FetchUnSpentTxByShaList. 2013-10-14 13:56:21 -05:00
Dave Collins
2ab3e0a382 Add interface tests for FetchTxByShaList. 2013-10-14 13:49:52 -05:00
Josh Rickmar
340e8b999e Switch a log.Error to Debug 2013-10-14 14:04:36 -04:00
Josh Rickmar
a80f9da6c3 Add websocket handlers to the RPC server for wallet connections.
This change adds additional http listeners for websocket connections
on "/wallet".  Websockets are used to provide asynchronous messaging
between wallet daemons (i.e. btcwallet) and btcd as they allow an easy
way for btcd to provide instant notifications (instead of a wallet
polling for updates) and multiple replies to a single request.
Standard RPC commands sent over a websocket connection are handled
just like RPC, returning the same results, the only difference being
that the connection is async.  In cases where the standard RPC
commands fall short of wallet daemons requests, and to request
notifications for addresses and events, extension JSON methods are
used.

Multiple wallets can be connected to the same btcd, and replies to
websocket requests and notifications are properly routed back to the
original requesting wallet.

Due to the nature of turning a synchronous protocol asynchronous, it
is highly recommended to use the JSON id field as a type of sequence
number, so replies from btcd can be routed back to the proper handler
in a wallet daemon.
2013-10-14 13:37:48 -04:00
Dave Collins
fb5f9c0b5a Separate interface tests and add test context.
Rather than having one mammoth interface test function, create a test
context and several helper functions that accept the context.
2013-10-14 12:26:43 -05:00
Dave Collins
06cb2ec817 Add interface test for FetchTxBySha.
This commit adds an interface test for FetchTxBySha to ensure it returns
the same MsgTx that was part of an inserted block.
2013-10-14 12:26:43 -05:00
Dave Collins
6a3824b8aa Add interface test for ExistsTxSha.
This commit adds an interface test for ExistsTxSha to ensure all
transactions inserted as a part of a block are available.
2013-10-14 12:26:42 -05:00
Dave Collins
f37fabb855 Add negative tests for FetchBlockShaByHeight.
This commit adds tests to ensure FetchBlockShaByHeight returns expected
errors when invalid heights are specified.
2013-10-14 12:26:41 -05:00
Dave Collins
06d6e5fce8 Add db type to test error outputs. 2013-10-14 12:26:40 -05:00
Dave Collins
6eebf02183 Add interface test for FetchBlockShaByHeight.
This commit adds an interface test for FetchBlockShaByHeight to ensure it
returns the same expected hash for each block inserted block height.
2013-10-14 12:26:40 -05:00
Dave Collins
670d83a74e Improve error message for FetchBlockBySha test.wq 2013-10-14 12:26:39 -05:00
Dave Collins
396d1b056d Add interface test for FetchBlockBySha.
This commit adds an interface test for FetchBlockBySha to ensure it
returns the same MsgBlock and raw bytes that were inserted.
2013-10-14 12:26:38 -05:00
Dave Collins
2d84623493 Move non-interface specific tests into db_test.go.
The idea here is that interface_test.go will be directly usable in each
implementation to increase test coverage there as well, but also works at
the  top-most level to test arbitrary backends.
2013-10-14 12:26:37 -05:00
Dave Collins
ff429203c4 Start interface tests that require state. 2013-10-14 12:26:37 -05:00
Dave Collins
82d1898b12 Add interface test for unsupported dbtype failures.
This commit adds an interface test to ensure that the interface returns
the expected error when trying to open or create an unsupported database
type.
2013-10-14 12:26:36 -05:00
Dave Collins
d4c1214496 Add interface test for create and open failures.
This commit adds an interface test to ensure that failures which occur
while creating or opening a database are properly handled.
2013-10-14 12:26:35 -05:00
Dave Collins
53ea2cf0ba Add interface test for adding a duplicate driver.
This commit adds an interface test to ensure that attempting to add a
duplicate driver for a given database type does not overwrite an existing
one.
2013-10-14 12:26:34 -05:00
Dave Collins
562294f938 Add loadBlocks infrastructure to interface tests. 2013-10-14 12:26:34 -05:00
Dave Collins
a27c37793b Add basic infrastructure for interface tests.
This is simply at start at providing generic interface tests.  The only
thing is tests so far is the empty database conditions on NewestSha, but
it adds infrastructure for creating and opening databases with special
type handling based on the database and necessary logic to teardown so
multiple backends can be tested simultaneously.

This and the next series of commits all discussed with drahn@.
2013-10-14 12:26:12 -05:00
Josh Rickmar
31489c15b3 Remove the embedded error and satisify the builtin error interface
This also adds tests to verify that the created error string follows
the expected format of "code: message" and tests to verify that Error
can be used as an error.  Additionally, the idiom

var _, _ error = Error{}, &Error{}

was added so the build will fail if the builtin error interface is
never satisified in the future.
2013-10-14 13:16:37 -04:00
Dave Collins
c88338d227 Slightly optimize GenerateInitialIndex.
Rather than fetching the hash of each block individually 2k+ times, make
use of the FetchHeightRange function so all of the most recent hashes can
be fetched at once.
2013-10-13 16:07:54 -05:00
Dale Rahn
75896b63ec Add Api to fetch potentially fully spent tx (most recent only)
Using FetchUnSpentTxByShaList only API required unexpected contortions
in btcchain.
2013-10-13 14:58:32 -04:00