Commit graph

154 commits

Author SHA1 Message Date
Dave Collins
b2186ae5ec Update README.md. 2014-12-22 22:50:17 -06:00
Dave Collins
f1f12a3f2f Update all badges in README.md to SVG.
Also, add a license badge.
2014-12-22 22:46:39 -06:00
Dave Collins
e49bf14993 Update build status badge in README.md to SVG. 2014-12-22 20:23:42 -06:00
Dave Collins
e6fe5877c4 Add test coverage badge to README.md.
Also, remove the test_coverage.txt file since coverage is now reported by
coveralls.io.
2014-12-22 20:14:22 -06:00
Dave Collins
9c8ee93b5c Update TravisCI to goclean script.
Also, correct a couple of issues found by running the script.
2014-12-22 20:05:11 -06:00
Jonathan Gillham
968b6da5db Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change. 2014-10-01 13:52:19 +01:00
Dave Collins
2a688a70b2 Update ldb tests for latest API error changes. 2014-09-20 00:47:20 -05:00
John C. Vernaleo
d6945f94e6 Fix tests. 2014-09-16 15:13:31 -04:00
John C. Vernaleo
a7ac93f5b6 Error improvements for lint.
Rename errors to Err*.
Lowercase error text.

Add golint for top level package

ok @davecgh
2014-09-16 15:07:11 -04:00
John C. Vernaleo
372bbe5c49 Add vet and lint where possible to travis. 2014-09-16 11:31:51 -04:00
John C. Vernaleo
68d10f4dc8 Add some missing comments.
ok @davecgh
2014-09-16 11:23:49 -04:00
Dale Rahn
f373ba3583 Introduce new error to indicate that block is not found vs db error.
ok @davecgh
2014-07-25 13:55:20 -05:00
Dave Collins
d9ee066af6 Example link godoc web don't match local godoc. 2014-07-08 10:05:58 -05:00
Dave Collins
1c877b33ea Use magic syntax for godoc NewestSha example. 2014-07-08 10:04:03 -05:00
Dave Collins
4422b14f63 Categorize NewestSha example under Db interface.
It seems the godoc example extraction does not recognize the same syntax
used for functions with receivers when working with interfaces.

So, instead, categorize the example on the interface.
2014-07-08 09:27:13 -05:00
Dave Collins
05ff5bd8ec Add NewestSha example. 2014-07-08 09:10:14 -05:00
Dave Collins
329c0bf094 Update overview documentation to more recent stats. 2014-07-08 08:54:55 -05:00
Dave Collins
a12b62c24c Add commented imports to the example. 2014-07-08 08:50:12 -05:00
Dave Collins
9ed908f44a Use testable example and update README.md.
This commit moves the example to a test file so it integrates nicely with
Go's example tooling.

This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
It is also nice to have the example in one place rather than repeating it
in doc.go and README.md.

Links and information about the example have been included in README.md in
place of the example.
2014-07-08 08:47:18 -05:00
Dave Collins
7354ecefe8 Add godoc reference badge to README.md. 2014-07-08 08:26:17 -05:00
Dave Collins
16dc2cf2d0 Add errors to all interface methods.
This commit adds error returns to all of the Db interface methods except
for FetchTxByShaList and FetchUnSpentTxByShaList since they expose the
errors on each individual transaction.

It also updates all tests and code for both the leveldb and memdb drivers
for the changes.

Closes #5.

ok @drahn
2014-07-07 12:55:46 -05:00
David Hill
d31183ff19 go fmt 2014-07-07 11:07:30 -04:00
David Hill
879d69d040 use strconv.FormatInt which is much faster than fmt.Sprintf 2014-07-07 11:07:07 -04:00
David Hill
0dd81ad003 Use NewReader instead of NewBuffer.
NewReader is slightly faster than NewBuffer, but more importantly,
ensures the data is read-only.
2014-07-07 11:05:02 -04:00
David Hill
e2628dfc0d convert binary Read/Write to Uint/PutUint and copy 2014-07-07 11:05:00 -04:00
Dave Collins
fbb17fd35a Update TODO section of README.md.
This ability for multiple database backends has been available for a long,
long time.  Looks like this was simply not updated when the interface was
added.
2014-07-07 09:34:41 -05:00
Dave Collins
dd41a4a233 Remove unneeded functions from memdb.
This commit removes some functions from memdb which only existed to satify
the btcdb.Db interface, but have since been removed from the interface.
2014-07-06 21:11:44 -05:00
Dave Collins
efb92fcc99 goimports -w . 2014-07-02 19:47:24 -05:00
David Hill
b40f5a1b24 add missing Lock to FetchTxBySha 2014-05-30 15:03:39 -04:00
Dave Collins
75e199ece8 Use btcnet genesis params for examples and tests. 2014-05-28 01:29:51 -05:00
Dale Rahn
ae25e28d7e Update test to new API. 2014-04-15 10:47:29 -04:00
Dale Rahn
dd41d71a31 If data for tx is not present, return error. 2014-04-15 10:47:25 -04:00
Dale Rahn
4d63076526 All external entry points into the database must be locked. 2014-04-15 10:17:37 -04:00
David Hill
1b51d58e55 In FetchHeightRange, preallocate the hash array.
Change FetchBlockByHeight to do the database lookup itself instead of
calling getBlkByHeight.  This saves an allocation of the entire block,
which it wasn't using.

In OpenDB, use fetchBlockShaByHeight instead of getBlkByHeight since it
only needs the sha.  This saves memory on startup.

ok drahn@
2014-03-20 16:10:52 -04:00
Dave Collins
c570830104 Update README.md example to use leveldb.
SQLite is now fully deprecated and has been removed.  Spotted and reported
by @jolan.

Closes #3.
2014-03-17 12:58:22 -05:00
Dave Collins
0a86df4a16 Correct test print found by go vet. 2014-01-19 21:41:52 -06:00
Dave Collins
2aca924514 Allow the Open/CreateDB funcs to take any params.
The specific parameters required by a backend is better left up to the
backend itself.  For example memdb has no need for a database path, while
ldb does.  This commit modifies the OpenDB and CreateDB functions to take
a arbitrary arguments which are passed along to the driver.  The driver is
expected to verify the correct type and number of arguments and error
accordingly.

The existing backends have been updated accordingly.
2014-01-19 20:13:21 -06:00
Dave Collins
2eea55ae1d Prune the btcddb.Db interface.
This commit prunes several unused functions from the Db interface and the
underlying implementations.  For the most part these are holdovers from
the original sqlite implementation.  It also removes the types associated
with those functions since they are no longer needed.  The following
functions and types have been removed:

- InvalidateCache
- InvalidateBlockCache
- InvalidateTxCache
- SetDBInsertMode
  - InsertMode type and associated constants
- NewIterateBlocks
  - BlockIterator interface

The reasons for removing these are broken out below.

- Neither of two current implementations implement these functions nor
  does any of the fully functional code using the interface invoke them.
- After contemplating and testing caching of blocks and transactions at
  this layer, it doesn't seem to provide any real benefit unless very
  specific assumptions about the use case are made.  Making those
  assumptions can make other use cases worse.  For example, assuming a
  large cache is harmful to memory-constrained use cases.  Leaving it up
  to the caller to choose when to cache block and transactions allows much
  greater flexibility.
- The DB insert mode was an artifact of the original sqlite implementation
  and probably should have only been exposed specifically on the
  implementation as opposed through generic interface.  If a specific
  implementation wishes to provide functionality such as special modes,
  that should be done through type assertions.
2014-01-19 18:01:05 -06:00
Dave Collins
8c34084e24 Add interface tests for new Fetch functions. 2014-01-19 02:55:07 -06:00
Dave Collins
d6c2492c7f Add FetchBlockHeightBySha/FetchBlockHeaderBySha.
This commit introduces two new functions to the btcdb.Db interface named
FetchBlockHeightBySha and FetchBlockHeaderBySha.

The FetchBlockHeightBySha function is useful since previously it was only
possible to get the height of block by fetching the entire block with
FetchBlockBySha and pulling the height out of the returned btcutil.Block.

The FetchBlockHeaderBySha function will ultimately make it much more
efficient to fetch block headers.  Currently, due to the database design
in the ldb backend, the entire block has to be loaded anyways, so the only
current benefit is to avoid the deserialize on all of the transactions.
However, ultimately btcdb will gain a more efficient backend which can
also avoid reading all of the extra transaction data altogether.
2014-01-19 02:54:47 -06:00
Dave Collins
845aedf103 Remove deprecated sqlite3.
The sqlite3 backend has been deprecated for quite some time.  As a result,
it has not been updated with many of the more recent changes which means
the behavior no longer conforms to the interface contract.
2014-01-19 02:36:54 -06:00
Dave Collins
27bc18ba2e Switch test coverage tool to new 'go tool cover'.
Also, make the coverage report test ldb and memdb instead of just sqlite3.
2014-01-19 02:35:41 -06:00
Dave Collins
0696c757fa Update ldb/dbtest to latest goleveldb API. 2014-01-18 21:06:10 -06:00
Marco Peereboom
6578e7345f catch up to new goleveldb 2014-01-09 13:11:37 -06:00
Dave Collins
6b18796af7 Add 2014 to copyright dates. 2014-01-08 23:54:52 -06:00
Dave Collins
472c998c0d Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 19:17:59 -06:00
David Hill
01b6ad7196 Reset batch on error 2013-11-26 16:42:55 -05:00
David Hill
ca502abbf2 Two fixes
fix returning error on insertTx and doSpend.
clear the batch on failures as well.
2013-11-26 15:58:13 -05:00
Dave Collins
fc11da9ca0 Gofmt. 2013-11-21 09:48:57 -06:00
Dave Collins
3bc401fed1 Use btclog for logging. 2013-11-21 09:48:16 -06:00