Commit graph

39 commits

Author SHA1 Message Date
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
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
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
Dale Rahn
e10cb732fd Fix. 2013-11-07 18:24:27 -05:00
Dale Rahn
13ef0e2be9 Rework leveldb support for duplicate tx.
This separates fully spent tx from tx containing unspent TxOut
This handles duplicate tx and Ideally should be faster.
2013-11-05 13:44:36 -05:00
Dale Rahn
078fb4d38e Delete obsolete API functions. 2013-11-05 13:44:36 -05:00
Dave Collins
80981b4696 Update to no longer use deprecated TxShas.
The btcutil code was recently changed to provide a new Tx type which
provides hash caching (among other things).  As a result, the notion of
obtaining a transaction hashes via TxShas was deprecated as well.  This
commit updates the tests and backend implementation code accordingly.
2013-11-01 21:17:06 -05:00
David Hill
83b1e74d6c Remove explicit garbage collection. 2013-10-26 20:38:27 -05:00
Dave Collins
19880b177e Optimize InsertBlock with cached tx hashes.
This commit optimizes InsertBlock slightly by using the cached transaction
hashes instead of recomputing them.  Also, while here, use the
ShaHash.IsEqual function to do comparisons for consistency.

This is ongoing work towards conformal/btcd#25.

ok @drahn.
2013-10-26 20:21:30 -05:00
Dave Collins
998682ec83 Remove sqlitedb from the common tests.
The sqlite db backend is now deprecated.
2013-10-22 15:28:32 -05:00
Dave Collins
5eee027f92 Correct leveldb package documenation.
The leveldb package documentation still referred to sqlite from
original copy/paste.
2013-10-22 15:26:44 -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
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
6260dc959d When creating database, set version 1 so the correct options are set. 2013-10-11 09:44:09 -04:00
Dave Collins
e4d3f25991 Update imports for goleveldb to Conformal fork. 2013-10-04 11:41:00 -05:00
Dale Rahn
cda0b10082 Introduce an API change for btcdb
FetchTxBySha changes what it returns, it can now return a TxListReply and
and error if none are found.

FetchTxByShaList is renamed to FetchUnSpentTxByShaList to indicate that
it will (likey/eventually) only return Tx that have some unspent TxOuts.
Tx which are fully spent may not be (reliably) looked up using this API.
2013-10-03 16:51:34 -04:00
Dale Rahn
07d634c76a remove old API function. 2013-10-03 14:08:04 -04:00
Dale Rahn
63f8993163 Delete testing operations from obsolete functions. 2013-10-02 18:10:00 -04:00
Marco Peereboom
e840c8314c catch up with api changes 2013-09-26 10:15:14 -05:00
Dale Rahn
3640f6d37c Version the leveldb (and keep compatibility with pre-versioned uncompressed databases. 2013-09-25 17:23:34 -04:00
Marco Peereboom
0e98349c98 disable compression, don't use cache and limit open files 2013-09-25 17:23:33 -04:00
David Hill
18b3e86179 FetchTxAllBySha needs to return err to the caller.
ok drahn@
2013-09-23 15:39:53 -04:00
Dave Collins
a2946ea14b Don't add "btcd.ldb" directory to provided path. 2013-09-13 17:32:04 -05:00
Dale Rahn
9e27c82a23 Fix error messages (pointed out by go vet) 2013-09-13 11:49:30 -04:00
Dale Rahn
7d679a6228 Adjust Block height indicators properly when database is created. 2013-09-10 14:17:24 -04:00
Dave Collins
9049bcacec Update error message for zero hash change. 2013-09-10 10:47:49 -05:00
Dave Collins
d9404fe880 Correct test for zero hash versus nil on empty db. 2013-09-10 10:45:02 -05:00
Dale Rahn
adc73cbc9d quiet. 2013-09-10 11:25:13 -04:00
Dave Collins
85553133ce gofmt. 2013-09-10 10:09:44 -05:00
Dave Collins
30f2003301 Remove spurious log.Info prints. 2013-09-10 10:09:43 -05:00
Dave Collins
66d6f10d5d Fix NewestSha. 2013-09-10 10:09:42 -05:00
Dale Rahn
96f7305c29 One DB instad of many.
improved error handling

Fix testing, no point in running tests multiple times

Fix error when no blocks in database, reopen would misreport NewstSha() return
2013-09-10 10:05:26 -04:00
Dale Rahn
b66abdf6ba Initial leveldb code.
This code is still prototype at this time.
It appears to function correctly but something
consumes more memory than is considered reasonable
for the dataset comprised of the full bitcoind chain.

Not recommened for use at this time.
2013-08-22 09:34:50 -04:00