Commit graph

2890 commits

Author SHA1 Message Date
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
Dave Collins
2ec9511891 Go fmt. 2013-10-13 13:04:16 -05:00
Dave Collins
d7e057a020 Make use of new spent vs unspent btcdb APIs.
This commit modifies the code to make use of the new btcd APIs that allow
fetching of transaction lists which either do or do not include fully
spent transactions.  It is more efficient to avoid fetching fully spent
transactions from the database when they aren't needed.
2013-10-13 02:40:02 -05:00
Dave Collins
9a29855c16 Convert inability to find input tx to a RuleError.
This commit modifies the errors that result from missing expected input
transactions to a RuleError.  This allows the caller to detect a block was
rejected due to a rule violation as opposed to an unexpected error.
2013-10-13 02:38:46 -05:00
Dave Collins
e5ba199eed Add example to BlockLocator comments. 2013-10-13 02:06:42 -05:00
Dave Collins
44aafcf742 Return on file error in address manager save.
This commit modifies the address manager save code to exit when there is
an error creating the file used to store addresses.  Previously the error
was only logged leaving the invalid file handle to be used later.
2013-10-12 11:49:10 -05:00
Dave Collins
1f87ee217a Move testdata to root btcd directory.
Rather than duplicating the same data, just put it under testsdata at the
root and access it from the modules from the parent directory.
2013-10-12 01:49:57 -05:00
Dale Rahn
b680d3539f Revive old validate Tx in parallel code, faster...
requested by davec, cleanup/polish in-tree.
2013-10-11 18:31:54 -04:00
John C. Vernaleo
6212a7daff Improve rpcserver.
Add getdifficulty command to rpcserver.

Add missing error check in an old bit of rpcserver.

Add getbestblockhash command.
2013-10-11 17:04:18 -04:00
Dave Collins
2a8122ffde Actually check orphan pool for IsOrphanInPool. 2013-10-11 15:46:24 -05:00
Dave Collins
6368d5b170 Respond to getdata requests for transactions.
This commit adds code to properly respond to getdata requests for
transactions by fetching them from the transaction pool.  Previously, we
advertised newly available transactions, but the code to respond with the
actual transaction was not written yet.

Also, fix a couple of comments and make the pushTxMsg and pushBlockMsg
functions consistent.
2013-10-11 14:14:55 -05:00
John C. Vernaleo
7ad6d73416 Add support for recent commands:
getrawchangeaddress and getbestblockhash.
2013-10-11 15:12:27 -04:00
Dave Collins
8be23c89ae Cleanup a few comments. 2013-10-11 10:24:13 -05:00
Dave Collins
39e7e5c4a1 Add minor optimization to transaction store fetch.
This commit adds a quick check to the transaction store fetch code which
simply returns an empty store if no hashes were requested rather than
bothering the db with an empty list.
2013-10-11 10:22:40 -05:00
Dale Rahn
6260dc959d When creating database, set version 1 so the correct options are set. 2013-10-11 09:44:09 -04:00
Dave Collins
10907027b7 Change failure to talk to DNS seeders to debug.
This is just a temporary failure and shouldn't be a warning.  Also,
remove redundant prefix on profile server log print while here.
2013-10-10 20:30:55 -05:00
Dave Collins
24aba3189e Update DISC subsystem log out for consistency. 2013-10-10 18:33:38 -05:00
Dave Collins
3d62b24fe1 Reformat periodic block height ouput and add time.
Closes #9.
2013-10-10 18:24:23 -05:00
Dave Collins
9772626dd8 Improve logging.
This commit is a first pass at improving the logging.  It changes a number
of things to improve the readability of the output.  The biggest addition
is message summaries for each message type when using the debug logging
level.

There is sitll more to do here such as allowing the level of each
subsystem to be independently specified, syslog support, and allowing the
logging level to be changed run-time.
2013-10-10 17:22:19 -05:00
Dave Collins
54b5cb56e7 Move logger code into its own file.
This cleans up btcd.go a bit and consolidates the logging related
functions.  It also paves the way for upcoming message summaries.
2013-10-10 14:36:05 -05:00
David Hill
55b300b6c2 improve addblock 2013-10-10 14:05:54 -04:00
David Hill
8a2299c1e1 improve dropafter as with showblock 2013-10-10 13:58:11 -04:00
David Hill
2231e04e2b improve showblock by setting default datadir and requiring -s 2013-10-10 13:51:20 -04:00
David Hill
c4d7b2d2c6 Improve showblock options, add --testnet and change default db to leveldb
to match btcd
2013-10-10 13:42:21 -04:00
Dave Collins
e888372019 Optimize transaction lookups.
This commit modifies the transaction lookup code to use a set instead of a
slice (list).  This allows the lookup to automatically prevent duplicate
requests to the database.

Previously, the code simply added every referenced transaction to a list
without checking for duplicates, which led to multiple requests against
the database for the same transaction.  It also meant the request list
could grow quite large with all of the duplicates using far more memory
than required.

While the end result was accurate, operating that way is not as efficient
as only requesting unique transactions.
2013-10-10 12:23:46 -05:00
Josh Rickmar
486907c441 Add -testnet flag to showblock. 2013-10-10 13:22:55 -04:00
Dave Collins
a275687f3f Make peer load message consistent and fix spello. 2013-10-10 10:06:58 -05:00
Dave Collins
e04986528c Add --nocheckpoints option.
This commit provides a new flag, --nocheckpoints, to disable built-in
checkpoints.

Checkpoints are used for a number of things such a ensuring
the block chain being downloaded matches various known good blocks,
allowing quicker verification on old blocks since scripts don't have to be
executed, and preventing forks from old blocks, etc.
2013-10-09 19:34:02 -05:00
Dave Collins
32790d52d8 Add tests for HaveBlock.
This commit adds tests to ensure HaveBlock works properly with blocks on
the main chain, a side chain, orphans, and missing blocks.
2013-10-09 18:43:22 -05:00
Dale Rahn
003a41f66f Slightly cleaner fix. 2013-10-10 00:33:09 +01:00
Dave Collins
6d078d8115 Implement chain setup infrastructure in the tests.
This commit implents a basic infrastructure to be used throughout the
tests for creating a new chain instance that is ready to have tests run
against it.  It also returns a teardown function the caller can use to
clean up after it is done testing.  This paves the way for adding more
tests.
2013-10-09 18:29:53 -05:00
Owain G. Ainsworth
53ca29efad fix multi-byte bug in previous.
Use the right offset when working out if we should mask off the sign bit.
Add more tests that would have caught this case.
2013-10-10 00:20:14 +01:00
Owain G. Ainsworth
4e608c115f Prevent asInt() from modifying stack data.
The stack data is normally sliced from the actual script and btcscript is not
supposed to ever change the tx passed into it.

Add a test (and fix the other leading zeros tests) to stop this happening again.
2013-10-09 23:59:23 +01:00
Owain G. Ainsworth
cdc3002c85 Fix previous. We care if we have the block OR it is an orphan, not both. 2013-10-09 16:35:33 +01:00
Dave Collins
c1f0d9b1ad Make leveldb the default db for findcheckpoint.
This mirrors the change in btcd.
2013-10-08 20:50:15 -05:00
Dave Collins
a0119b056e Move transaction handling into block manager.
The block manager handles inventory messges to know which inventory should
be requested based on what is already known and what is already in flight.
So, this commit adds logic to ask the transaction memory pool if the
transaction is already known before requesting it and tracks pending
requests into an in-flight transaction map owned by the block manager.

It also moves the transaction processing into the block manager so the
in-flight map can be properly cleaned.
2013-10-08 20:46:59 -05:00
David Hill
e8d73d83ef Add btcctl; currently a barebones utility to send commands
to btcd.
2013-10-08 21:18:49 -04:00
Owain G. Ainsworth
093ddbe193 *sigh*, accidentally commited a wrong chunk as well as the right chunk.
Fix length check back to what it should be.
2013-10-09 01:27:19 +01:00
Dave Collins
cd68e3060f Remove extra msg in log message. 2013-10-08 17:45:05 -05:00