This commit adds a new backend driver which conforms to the btcdb
interface to provide a memory only database. This is primarily useful for
testing purposes as normal operations require a persistent block storage
mechanism.
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.
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.
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.
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.
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.
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@.
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.