Commit graph

36 commits

Author SHA1 Message Date
Dave Collins
97f3917fcf Update goleveldb import paths to new location.
Also update for changes due to the upstream sync.
2015-01-15 03:16:32 -06:00
Jonathan Gillham
968b6da5db Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change. 2014-10-01 13:52:19 +01: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
68d10f4dc8 Add some missing comments.
ok @davecgh
2014-09-16 11:23:49 -04: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
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
efb92fcc99 goimports -w . 2014-07-02 19:47:24 -05: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
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
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
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
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
2ec9511891 Go fmt. 2013-10-13 13:04:16 -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
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
Dave Collins
a2946ea14b Don't add "btcd.ldb" directory to provided path. 2013-09-13 17:32:04 -05:00
Dale Rahn
7d679a6228 Adjust Block height indicators properly when database is created. 2013-09-10 14:17:24 -04: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
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