Commit graph

224 commits

Author SHA1 Message Date
Dave Collins
8e97f32e68 Add funcs to Block API for wrapped transactions.
This commit adds two new functions to the Block API for working with the
recently added Tx type from the Block.

These new functions are named Tx and Transactions.  Tx returns a
transactions for the specified index as a Tx and also memoizes it so
subsequent calls are more efficient.  Transactions returns a slice of all
transactions in the Block wrapped in a Tx.

This is part of the ongoing transaction hash optimization effort
noted in conformal/btcd#25.
2013-10-28 10:34:27 -05:00
Dave Collins
29f1bf4ae1 Add tests for new Tx type.
This commit adds both positive and negative tests for the new Tx type to
bring its coverage to 100%.

This is part of the ongoing transaction hash optimization effort noted
in conformal/btcd#25.
2013-10-27 14:00:39 -05:00
Dave Collins
e402c62673 Add new Tx wrapper for btcwire.MsgTx.
Currently, transaction hash caching is provided via Block directly, but a
transaction is not always part of a block and there are several cases
where only the transaction needs to be dealt with without wanting to pass
the entire block and transaction index around to be able to get at the
cached hash.

So, this commit adds a new type named Tx which is a wrapper that provides
easier and more efficient manipulation of raw wire protocol transactions.
It memoizes the hash for the transaction on its first access so subsequent
accesses don't have to repeat the relatively expensive hashing operations.
The idea is the callers can pass around pointers to these Tx types instead
of raw btcwire.MsgTx pointers.

For now, the Block API has not been changed, but the plan is to change it
to provide access to these wrapped transactions rather than having it do
the transaction hash caching directly.

This is only the first part of a series of changes working towards
optimizations noted in conformal/btcd#25.
2013-10-27 13:55:51 -05:00
Josh Rickmar
f72ab9cfce Update test coverage file 2013-10-08 13:14:04 -04:00
Josh Rickmar
e433a02e4b Encode and decode addresses with a btcwire.BitcoinNet, not a byte.
While here, fix a couple of append() leaks.
2013-10-08 13:00:41 -04:00
Josh Rickmar
867149f470 Add missing license header and remove extra space. 2013-09-12 11:32:47 -04:00
Josh Rickmar
e4925b4abe Add functions to encode and decode payment addresses. 2013-09-12 11:20:34 -04:00
Dave Collins
8b2fdd9808 Update comments to use proper form. 2013-08-06 12:40:08 -05:00
Dave Collins
ad7e3894c7 Allow var def to infer type from right-hand side.
Found by golint.
2013-08-06 12:37:20 -05:00
Dave Collins
43095c66bc Remove dependency on protocol version.
This commit unfortunately changes the public API of Block which I
ordinarily don't like to do, but in this case, I felt it was necessary.

The blocks used throughout the database and elsewhere should be indepedent
of the protocol version which is used to encode the block to wire format.
Each block has its own Version field which should be the deciding factor
for the serialization and deserialization of blocks.  In practice, they
are currently the same encoding, but that may not always be the case, and
it's important the blocks are stable depending on their own version
regardless of the protocol version.

This makes use of the new Serialize and Deserialize functions on MsgBlock
which are intended for long-term storage as opposed to wire encoding.
2013-08-05 16:28:55 -05:00
John C. Vernaleo
761970e639 Fixed license statment on base58 files. 2013-06-13 13:09:51 -04:00
John C. Vernaleo
5eda8b95af Add Base58Encode and Base58Decode functions. ok davec@ 2013-06-13 13:01:46 -04:00
Dave Collins
7ad8b4787b Update README.md test coverage.
Now that the test coverage is comprehensive. update the README
accordingly.
2013-05-30 12:52:51 -05:00
Dave Collins
05d31cdc7a Add negative test for TxLoc. 2013-05-30 11:50:58 -05:00
Dave Collins
b8843a0fb6 Make TxLoc comment consistent with others. 2013-05-30 11:39:43 -05:00
Dave Collins
e98dc50b69 Convert TxLoc to use normal returns. 2013-05-30 11:31:22 -05:00
Dave Collins
969fbd1500 Cleanup TxLoc function variable names. 2013-05-30 11:13:08 -05:00
Dave Collins
3ffe28e364 Add test for OutOfRangeError. 2013-05-30 11:12:29 -05:00
Dave Collins
a5bb254ac6 Add negative tests for TxSha. 2013-05-30 11:06:09 -05:00
Dave Collins
f8fc23a541 Add negative test for NewBlockFromBytes. 2013-05-30 10:45:38 -05:00
Dave Collins
b90727cc8a Add tests for TxLoc. 2013-05-30 10:30:04 -05:00
Dave Collins
af89ed1c2e Correct documentation of the Block.TxLoc function. 2013-05-28 18:43:13 -05:00
Dave Collins
ef6c01960f Initial implementation. 2013-05-28 18:21:26 -05:00
Dave Collins
727d687cf3 Initial commit. 2013-05-28 17:20:28 -05:00