Commit graph

20 commits

Author SHA1 Message Date
Dave Collins
8be23c89ae Cleanup a few comments. 2013-10-11 10:24:13 -05:00
Dave Collins
e888372019 Optimize transaction lookups.
This commit modifies the transaction lookup code to use a set instead of a
slice (list).  This allows the lookup to automatically prevent duplicate
requests to the database.

Previously, the code simply added every referenced transaction to a list
without checking for duplicates, which led to multiple requests against
the database for the same transaction.  It also meant the request list
could grow quite large with all of the duplicates using far more memory
than required.

While the end result was accurate, operating that way is not as efficient
as only requesting unique transactions.
2013-10-10 12:23:46 -05:00
Dave Collins
0b334bc841 Correct reading of serialized height in coinbase.
This commit corrects the reading of the serialized height in coinbase
transactions for block height of version 2 or greater.  On mainnet, the
serialized height is always 3 bytes and will continue to be so for
something like  another ~159 years, so there was no issue with mainnet.
However on testnet, there are some version 2 blocks which are low enough
in the chain to only take 2 bytes to serialize.

In addition, this commit adds a full tests for the relavant function
including negative tests and variable length serialized lengths for block
heights.

Closes #1.
2013-10-06 14:27:53 -05:00
Dave Collins
e54fb96d80 Test tx lookup validity in CheckInputTransactions.
This commit modifies CheckInputTransactions to ensure that not only must a
transaction exist in the transaction store, it must also not have any
errors associated with it or be nil.
2013-10-02 10:26:44 -05:00
Dave Collins
3c7511a34b Export the CheckTransactionInputs function. 2013-09-30 16:44:01 -05:00
Dave Collins
e576962cb3 Export the CheckTransactionSanity function. 2013-09-30 16:43:10 -05:00
Dave Collins
6695cd15bb Export the IsCoinbase function. 2013-09-30 16:42:28 -05:00
Dave Collins
4eb135618a Export the IsFinalizedTransaction function. 2013-09-30 16:40:19 -05:00
Dave Collins
fc69776371 Expose a transaction store and related functions.
Several of the functions require a map of contextual transaction data to
use as a source for referenced transactions.  This commit exports the
underlying TxData type and creates a new type TxStore, which is a map of
points to the under TxData.  In addition, this commit exposes a new
function, FetchTransactionStore, which returns a transaction store
(TxStore) containing all of the transactions referenced by the passed
transaction, as well as the existing transaction if it already exists.

This paves the way for subsequent commits which will expose some of the
functions which depend on this transaction store.
2013-09-30 16:37:11 -05:00
Dave Collins
117765ba7c Correct error message in other input tx lookup. 2013-08-28 13:50:47 -05:00
Dave Collins
ffa56b437c Correct error msg for missing input transaction.
The error message for missing input transaction had the referenced and
referencing transactions backwards.
2013-08-28 13:46:17 -05:00
Dave Collins
10a62a37a3 Update for latest btcutil, btcscript, and btcwire.
This commit updates the calls into btcutil, btcscript, and btcwire for the
latest API changes which remove the need for the protocol version for
serialization and deserialization of blocks and transactions.
2013-08-05 18:53:50 -05:00
Dave Collins
cef901ebad Export chain parameters.
This commit exports the chain parameters used depending on the specific
bitcoin network so callers can have access to this information if desired.
2013-07-30 12:38:27 -05:00
Dave Collins
829f187e47 Use network-specific genesis hash.
The test in checkConnectBlock for whether or not the node is the genesis
block needs to account for the genesis block of the specified network.
2013-07-29 20:21:24 -05:00
Dave Collins
04d88d01ec Clarify mismatched merkle root error message. 2013-07-29 19:50:00 -05:00
Dave Collins
077e1ec336 Improve second coinbase error message.
Include the index at which the second coinbase transaction was found.
2013-07-29 17:02:42 -05:00
Dave Collins
6409879e14 Modify count sigops calls for new btcscript API.
The btcscript API for GetSigOpCount and GetPreciseSigOpCount
recently changed to no longer return an error.  This change was necessary
to mirror the behavior of bitcoind signature operations counting.  This
commit modifies the code accordingly to use the new API.
2013-07-29 16:21:33 -05:00
Dave Collins
b282678d9a Spend outputs while checking transaction inputs.
This commit modifies the double spend detection to handle double spends
within the same block as well as side chains when doing the checks before
reorganizing the chain.
2013-07-26 11:51:13 -05:00
Dave Collins
f219ed5baf Add support for params based on active network.
This commit modifies the code to use params based on the active network
which paves the way for supporting the special rules and different genesis
blocks used by the test networks.
2013-07-24 12:26:17 -05:00
Dave Collins
aa5847f3cc Initial implementation. 2013-07-19 08:50:13 -05:00