Commit graph

3509 commits

Author SHA1 Message Date
Josh Rickmar
b57628ea9f Initial commit. 2013-11-06 11:11:04 -05:00
Dave Collins
48c350f379 Update test coverage report. 2013-11-06 07:44:51 -06:00
Dave Collins
73f4ee623b Optimize readOutPoint.
Before: BenchmarkReadOutPoint     500000              2946 ns/op
After:  BenchmarkReadOutPoint    5000000               582 ns/op

This is part ef the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-11-06 07:37:34 -06:00
Dave Collins
d63e0dd455 Add benchmarks for readOutPoint.
This commit adds a benchmark for the readOutPoint function.
2013-11-06 07:33:37 -06:00
Dave Collins
f54b010e4b Optimize writeOutPoint.
Before: BenchmarkWriteOutPoint    500000              2664 ns/op
After:  BenchmarkWriteOutPoint  10000000               151 ns/op

This is part ef the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-11-06 00:47:57 -06:00
Dave Collins
547b648702 Add benchmarks for writeOutPoint.
This commit adds a benchmark for the writeOutPoint function.
2013-11-06 00:45:30 -06:00
Dave Collins
8a1828a2d6 Optimize writeVarString.
Before:

BenchmarkWriteVarStr4    1000000              1114 ns/op
BenchmarkWriteVarStr10   1000000              1352 ns/op

After:

BenchmarkWriteVarStr4    5000000               291 ns/op
BenchmarkWriteVarStr10  10000000               248 ns/op

This is part ef the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-11-05 23:59:40 -06:00
Dave Collins
fa8f666e8c Add benchmarks for writeVarString.
This commit adds a couple of benchmarks for the writeVarString function.
2013-11-05 23:49:34 -06:00
Dave Collins
4002051a22 Optimize readVarString.
Before:

BenchmarkReadVarStr4     1000000              1698 ns/op
BenchmarkReadVarStr10    1000000              1812 ns/op

After:

BenchmarkReadVarStr4     2000000               853 ns/op
BenchmarkReadVarStr10    5000000               712 ns/op

This is part ef the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-11-05 23:33:21 -06:00
Dave Collins
b830e2ddf3 Add benchmarks for readVarString.
This commit adds a few benchmarks for the readVarString function.
2013-11-05 23:09:44 -06:00
Dave Collins
052c2ca8d3 Correct benchmark comments. 2013-11-05 23:03:54 -06:00
Dave Collins
6263efcc71 Slightly optimize readVarInt.
This commit slightly optimizes the readVarInt function in the case of
multiple-byte variable length integers.  It also reduces the amount of
memory garbage it generates.

Before:

BenchmarkReadVarInt1     5000000               386 ns/op
BenchmarkReadVarInt3     5000000               693 ns/op
BenchmarkReadVarInt5     2000000               793 ns/op
BenchmarkReadVarInt9     5000000               709 ns/op

After:

BenchmarkReadVarInt1     5000000               387 ns/op
BenchmarkReadVarInt3     5000000               471 ns/op
BenchmarkReadVarInt5     5000000               575 ns/op
BenchmarkReadVarInt9     5000000               473 ns/op

This is part ef the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-11-05 22:09:03 -06:00
Dave Collins
87ce23d679 Add benchmarks for readVarInt.
This commit adds a few benchmarks for the readVarInt function.
2013-11-05 21:35:28 -06:00
Dave Collins
50c10faf4e Optimize writeVarInt.
Before:

BenchmarkWriteVarInt1   10000000               173 ns/op
BenchmarkWriteVarInt3    2000000               965 ns/op
BenchmarkWriteVarInt5    2000000               966 ns/op
BenchmarkWriteVarInt9    2000000               968 ns/op

After:

BenchmarkWriteVarInt1   20000000               101 ns/op
BenchmarkWriteVarInt3   20000000               136 ns/op
BenchmarkWriteVarInt5   10000000               142 ns/op
BenchmarkWriteVarInt9   10000000               156 ns/op

This is part of the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-11-05 20:33:14 -06:00
Dave Collins
900db0b444 Add benchmarks for writeVarInt.
This commit adds a few benchmarks for the writeVarInt function.
2013-11-05 19:56:12 -06:00
Owain G. Ainsworth
e8321441af add a stringer for ScriptClass 2013-11-06 00:11:14 +00:00
Owain G. Ainsworth
56a62309ae Add some error messages to be used by btcd.
ok jcv
2013-11-05 22:35:06 +00: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
Dale Rahn
078fb4d38e Delete obsolete API functions. 2013-11-05 13:44:36 -05:00
Dale Rahn
b406ca7ae7 If ExistsTx fails try looking up the tx, it may be fully spent. 2013-11-05 13:44:35 -05:00
John C. Vernaleo
b72f0c6474 Make peerinfo output match bitcoind a bit better.
Add long option for username in btcctl.
2013-11-04 16:25:13 -05:00
David Hill
a97fd5fe2c add test for testing IsOnCurve 2013-11-04 14:42:21 -05:00
Josh Rickmar
1f087adf15 Separate ws command handlers into separate funcs. 2013-11-04 14:15:05 -05:00
Josh Rickmar
53e1c2d6bd Stringify the address hash for txRequests map.
This change allows map lookups using address hashes (which are
returned as []byte) instead of either copying the hash into an array,
or doing a bytes.Equal().

A stupid range over a map until the right key is found was also just
changed to a single map lookup.
2013-11-04 14:11:39 -05:00
Josh Rickmar
506c3eacac Add padding for pubkey numbers.
This change pads serialized (big endian) pubkey numbers to a length of
32 bytes.  Previously, because serialized pubkey numbers are read
MSB-first, if a number could be serialized in less than 31 bytes, the
deserialized number would be incorrect.
2013-11-04 10:11:11 -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
John C. Vernaleo
815a0b0a84 Improve test coverage. 2013-11-01 15:27:17 -04:00
Josh Rickmar
2511fee152 Complete rescan extension.
This adds to the initial rescan implementation, but switches it to
rescan based on a group of addresses, rather than just one.  Due to
how expensive database lookups are during a rescan, wallets should
take advantage of this to rescan once for all needed addresses for all
accounts.
2013-11-01 09:35:52 -04:00
John C. Vernaleo
3f33e419a9 Improve test coverage and fix bug found by tests.
Spell receive the same way all the time so things work.
2013-10-31 14:51:35 -04:00
Dave Collins
5a46de5103 Add support for min required fees in tx mempool.
This commit adds checks to the memory pool to restrict allowed
transactions based on minimum required fees.
2013-10-31 12:24:28 -05:00
Dave Collins
a4794798d4 Make use of new btcwire SerializeSize API.
This commit changes the various cases that were serializing transactions
into a buffer and taking the length to use the new faster SerializeSize
API.  It also completes a TODO since the serialized size of a transaction
output is now available.
2013-10-31 00:28:37 -05:00
Dave Collins
b7b700fd5a Add tests for the new SerializeSize functions.
This commit adds tests for the new SerializeSize functions for variable
length integers and transactions (and indirectly transaction inputs and
outputs).
2013-10-31 00:20:41 -05:00
Dave Collins
26cb71d805 Expose new SerializeSize API for transactions.
This commit adds a new function named SerializeSize to the public API for
MsgTx, TxOut, and TxIn which can be used to determine how many bytes the
serialized data would take without having to actually serialize it.

The following benchmark shows the difference between using the new
function to get the serialize size for a typical transaction and
serializing into a temporary buffer and taking the length of it:

Bufffer: BenchmarkTxSerializeSizeBuffer     200000           7050 ns/op
New:     BenchmarkTxSerializeSizeNew     100000000             18 ns/op

This is part of the ongoing effort to optimize serialization as noted in
conformal/btcd#27.
2013-10-31 00:20:14 -05:00
Dave Collins
cbf648a02f Slightly optimize writeVarInt for the normal case.
Most variable length integers are smaller numbers, so this commit reverses
the order of the if checks in the writeVarInt to assume smaller numbers
are more common.

This is part of the ongoing effort to optimize serialization as noted in
conformal/btcd#27
2013-10-30 21:11:10 -05:00
Dave Collins
470ef8c58e Use correct calls to tx.Sha() in RPC server. 2013-10-30 18:40:55 -05:00
John C. Vernaleo
e1dd773e7c Improve test coverage and fix some bugs found by tests.
Fix move need to convert amount to btc from satoshi

Fix settxfee need to convert amount to btc from satoshi

Fix for optional arg off by one in move.

Fix for gettxout in optional args along with typo in error message.

And lots of new tests.
2013-10-30 17:22:56 -04:00
Dave Collins
70094fcee8 Minor cleanup.
Fix a couple of comments and call tx.Sha directly in a couple of places.
2013-10-30 14:13:29 -05:00
Dave Collins
b866e9f14c Improve RPC server log of rejected transactions.
Rather than showing all errors from ProcessTransaction as an error, check
if the error is a TxRuleError meaning the transaction was rejected as
opposed to something actually going wrong and log it accordingly.
2013-10-30 14:11:45 -05:00
Dave Collins
e76fada2d2 Optimize NotifyNewTxListener.
Looking up transactions from the database is an expensive operation.
This commit modifies the NotifyNewTxListener code to simply iterate the
transactions in the block instead of looking them up from the db.

Currently the wallet code needs a spent flag which ultimately shouldn't be
required.  For now, the spent data is simply created on the fly which is
still significantly faster than doing database transaction lookups.

Closes #24.
2013-10-30 10:54:03 -05:00
John C. Vernaleo
07de6ea013 Add additional tests for jsoncmd code.
Test stop, signrawtransaction, setaccount, sendtoaddress, and a few
others.

Fix off by one error in the optional arguments for sendtoaddress.

Rename occurances of Minconf to MinConf for constitancy.
2013-10-30 08:29:59 -04:00
Josh Rickmar
d7d2385fb0 Return JSON id with errors when possible.
This change unbreaks the case where an unknown command is sent to the
RPC server.  Instead of replying back with a nil JSON id, if the
initial unmarshal was successful (and thus, the message was valid
JSON-RPC), the unmarshaled id will be used in the error reply.
2013-10-29 23:23:22 -04:00
Josh Rickmar
334a1c1f20 Return basic Cmd from ParseMarshaledCmd when possible.
This changes the behavior of ParseMarshaledCmd to always return a
non-nil Cmd whenever unmarshaling a valid JSON-RPC message succeeds.
This is needed for RPC server code to reply back with detailed errors
to clients using the Method and Id methods of the Cmd interface.
2013-10-29 23:22:16 -04:00
Dave Collins
9442d96929 Convert errors in RPC server to new btcjson consts. 2013-10-29 19:42:21 -05:00
Owain G. Ainsworth
231efa35f5 Provide useragent in getpeerinfo now we know it. 2013-10-29 23:00:23 +00:00
Owain G. Ainsworth
c4be414921 Make ParseMarshaledCmd return a known error if the type isn't known. 2013-10-29 22:33:44 +00:00
David Hill
4f25d45e77 Grab the remote peer's user agent. 2013-10-29 21:45:45 +00:00
Owain G. Ainsworth
59e2b204a3 Add doc comments. 2013-10-29 20:30:16 +00:00
Owain G. Ainsworth
da2901a4fd Add support for the addnode command
Currently this acts on the list of all peers, and not just the list of
permanent peers. this will be changed shortly.
2013-10-29 20:30:07 +00:00
David Hill
36941cc427 Remove the satoshi consts and use them from btcutil instead. 2013-10-29 16:08:12 -04:00
David Hill
8271a11808 add SatoshiPerBitcent constant and export SatoshiPerBitcoin and
MaxSatoshi
2013-10-29 14:57:31 -04:00