Commit graph

15 commits

Author SHA1 Message Date
Josh Rickmar
85af882c13 Implement lockunspent and listlockunspent.
Closes #50.

Closes #55.
2014-06-23 16:59:57 -05:00
Josh Rickmar
938dfa1517 Only log rollbacks for detached txstore blocks.
Instead of logging whenever there is a chain fork + reorg, only log if
a detached block affects the wallet in some manner.
2014-06-20 08:36:28 -05:00
Josh Rickmar
ad72d3a400 Add basic transaction store logging.
The info log level (default) will produce output about confirmed and
unconfirmed transactions being inserted into the store, as well as
unconfirmed transactions which have been mined into blocks.  By
enabling the debug log level (-d TXST=debug), additional information
about transaction inputs and outputs is logged.  This includes the
total amount of previously-unspent outputs which have been marked
spent by the inserted transaction, and the output indexes and amounts
for each spendable output.  Additionally, the debug log level will log
whenever transactions are removed due to being a double spend of
another inserted transaction.
2014-06-19 18:16:13 -05:00
Josh Rickmar
3b436402e0 Search unconfirmed txs when finding prev credits.
If a transaction is added that debits from previous transaction
outputs, and those outputs are still unconfirmed, it is possible that
if the credits were not already known (as is the case with
transactions notified after a sendrawtransaction), only mined unspent
transaction outputs would be searched and the unconfirmed unspent
credits would be missed.  This results in spent outputs still being
marked unspent.

This change fixes the above by also searching through unconfirmed
transactions when the previous credits must be lookup up, rather than
being pass from an AddDebits call.

Fixes issue #91.
2014-06-19 11:49:52 -05:00
Josh Rickmar
632148ed55 Fix various issues found by profiling.
This commit is the result of inspecting the results of both cpu and
memory profiling, to improve areas where wallet can be more efficient
on transaction inserts.

One problem that's very evident by profiling is how much waiting there
is for file (txstore, wallet) writes.  This commit does not attempt to
fix this yet, but focuses on the easier-to-fix memory allocation
issues which can slow down the rest of wallet due to excessive garbage
collection scanning.

While here, fix a race where a closure run as a goroutine was closing
over a range iterator.
2014-06-18 17:08:02 -05:00
Josh Rickmar
a87f827fb9 Remove unneeded check of closed channel. 2014-06-18 09:16:14 -05:00
Josh Rickmar
6a72a0ad4d Pass txstore.Credit/Debits directly, not pointers.
The Credit and Debits structures are simple wrappers around an
embedded *txstore.TxRecord, as well as an output index in the case of
Credit.  This means that a Credit is at most two words, while a Debits
struct is just one.  To avoid the unnecessary garbage of creating
Credit and Debits structures on the heap (where the underlying
TxRecord likely already is), simply pass around everywhere as
non-pointer types, and modify the receivers for all Credit and Debits
methods to non-pointer receivers since none of them ever modify the
value.
2014-06-18 00:16:08 -05:00
Josh Rickmar
9153a342e4 Improve txstore unspent output bookkeeping.
This change "reverses" the mapping used by the transaction store to
reference and lookup unspent credits.  Rather than mapping slice
indexes of a block, and then another block map for slice indexes of
transactions with unspent credits, and requiring a lookup through each
credit for whether it is spent or unspent, keep a simple map of
outpoints to a lookup key to find the transaction in a block.

This has a positive effect on performance when searching for previous
transaction outputs that have been spent by a newly-inserted
transaction.  Rather than iterating through every block with an
unspent credit, and then every transaction with unspent credits, a
simple map lookup can be done to check whether a transaction input's
previous outpoint is marked as unspent by wallet, and then access the
transaction record itself by the lookup key.  While transactions
created by wallet with the sendfrom/many RPCs may mark debits with the
previous credits already known, the previous outputs may still not be
known if a debiting transaction was added by rescan, or notified as a
result of a create+sendrawtransaction.
2014-06-17 22:50:34 -05:00
Josh Rickmar
0f808dc00f Remove unnecessary uint32 type conversions. 2014-06-16 16:25:04 -05:00
Josh Rickmar
23dca5edfd Fix bug returning unconfirmed txstore records.
The incorrect slice was being appended to, causing some unconfirmedg
records to be dropped from the return result.
2014-06-13 16:17:17 -05:00
Josh Rickmar
4495a523d8 Updates for btcutil and btcscript's btcnet conversion. 2014-05-27 17:49:36 -05:00
Josh Rickmar
1c0701bb59 Return listunspent results sorted.
Fixes #88.
2014-05-23 10:31:05 -05:00
Josh Rickmar
c3224f4fbc Begin update to use btcnet.Params.
This is an intial pass at converting the btcwallet and deps codebases
to pass a network by their parameters, rather than by a magic number
to identify the network.  The parameters in params.go have been
updated to embed a *btcnet.Params, and all previous uses of cfg.Net()
have been replaced with activeNet.{Params,Net} (where activeNet is
the global var for the active network).

Although dependancy packages have not yet been updated from using
btcwire.BitcoinNet to btcnet.Params, the parameters are now accessible
at all callsites, and individual packages can be updated to use btcnet
without requiring updates in each external btc* package at once.

While here, the exported API for btcwallet internal library packages
(txstore and wallet) have been updated to pass full network parameters
rather than the btcwire definition of a network.
2014-05-22 21:24:08 -05:00
Josh Rickmar
8795534408 Typo. 2014-05-08 21:21:31 -05:00
Josh Rickmar
f36a83b3cc Rename tx package to txstore.
Prodded by @davecgh, and I had this change in the back of my head for
a while now anyways.
2014-05-08 14:51:33 -05:00
Renamed from tx/tx.go (Browse further)