Commit graph

3491 commits

Author SHA1 Message Date
Dave Collins
23ff70d682 Add gethashespersec command to btcctl. 2013-12-25 19:13:14 -06:00
Dave Collins
195ada0979 Add newline to previous print change. 2013-12-25 17:47:56 -06:00
Dave Collins
6be128a843 Display float values with btcctl with %f.
This commit modifies btcctl to show float values with %f instead of the
default %v.  This means the values will show similar to 1180923195.260000
instead of 1.18092319526e+09 (scientific notation).
2013-12-25 17:47:12 -06:00
Dave Collins
dc200d002e Correct getrawmempool verbose fee field.
The fee field of the getrawmempool RPC JSON response should be in Bitcoins
instead of Satoshi.  This commit corrects that issue.

Also, add a couple of comments and fix a comment typo while here.
2013-12-25 12:33:12 -06:00
Dave Collins
edf8f2f224 Use curHeight in mempool transaction add.
Since there is already a variable for the current block height in addition
to the next block height, use the existing curHeight variable instead
doing nextBlockHeight-1 in mempool add.
2013-12-25 12:15:59 -06:00
Dave Collins
4c184ead54 Use consistent wrapping for externalip config opt. 2013-12-24 17:01:32 -06:00
Dave Collins
17a9b41bef Cleanup peer.go.
This commit does some housekeeping on peer.go to make the code more
consistent, correct a few comments, and add new comments to explain the
peer data flow.  A couple of examples are variables not using the standard
Go style (camelCase) and comments that don't match the style of other
comments.
2013-12-24 14:05:28 -06:00
Owain G. Ainsworth
d3a7f15a87 Alter the way peers queue outbound messages somewhat.
Instead of one thread that queues and writes, we move to a two queue
model. The queueHandler muxes all the sources of outgoung packets and
drips them to the actual sender. This is done so that a large send
doesnt' allow the channels to fillup and cause blockmanager and server
to block, which delays other peers.

Most messages we handle as is. However, for getdata we do some manual
limiting and pipelining, we queue up three and then we load the next
into memory, not sending it until the otherp ackets have been sent. We
may want to change this later to queue the packet *then* wait so that we
don't completely drain the pipe.

A few misc tweaks to avoid deadlocking by ensuring the all channels will
always drain. mostly this relates to ensuring that we know no more data
will be coming before we drain the channel, and not queueing after we
are marked to disconnect.

Discussed heavily with drahn@ and davec@.
2013-12-23 23:51:52 +00:00
Dave Collins
ab14c30fe1 Add benchmark for signature verifies. 2013-12-23 17:24:01 -06:00
Dave Collins
cd9694e9ad Add benchmarks for ScalarBaseMult and ScalarMult. 2013-12-23 16:59:47 -06:00
Dave Collins
627aeb5e9c Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-23 11:43:10 -06:00
Dave Collins
4f4afedf39 Use the new btcec Signature.Serialize API.
This commit modifies the code to use the new btcec Signature.Serialize API
instead of the internal sigDER which has now been removed.  This closes #3.

ok @owainga
2013-12-23 11:35:14 -06:00
Dave Collins
bb6b277706 Add tests for new Signature.Serialize function.
This is part of the resolution for issue btcscript/#3.
2013-12-23 11:31:26 -06:00
Dave Collins
2067215193 Expose a new Serialize function on Signature type.
This commit exposes a new function named Serialize on the Signature type
which can be used to obtain a DER encoded signature.  Previously this
function was named sigDer and was part of btcscript, but as @donovanhide
pointed out in issue btcscript/#3, it really should have been part of this
package.

ok @owainga
2013-12-23 11:31:08 -06:00
Dave Collins
85ac6b06f7 Make NewFieldVal only avilable to the test package.
Since the function was only exported for use by the test package (and was
commented as such), just move it into the internal_test.go file so it is
only available when the tests run.
2013-12-20 19:19:02 -06:00
Dave Collins
ac7e4de201 Add field and point addition/multiplicaiton tests.
This commit adds 100% test coverage for the new code.  This brings the
overall btcec coverage up to 99.76%.
2013-12-20 15:09:58 -06:00
Dave Collins
9be5c5cbd9 Significantly optimize signature verification.
This commit essentially rewrites all of the primitives needed to perform
the arithmetic for ECDSA signature verification of secp256k1 signatures to
significantly speed it up.  Benchmarking has shown signature verification
is roughly 10 times faster with this commit over the previous.

In particular, it introduces a new field value which is used to perform the
modular field arithmetic using fixed-precision operations specifically
tailored for the secp256k1 prime.  The field also takes advantage of
special properties of the prime for significantly faster modular reduction
than is available through generic methods.

In addition, the curve point addition and doubling have been optimized
minimize the number of field multiplications in favor field squarings
since they are quite a bit faster.  They routines also now look for
certain assumptions such as z values of 1 or equivalent z values which
can be used to further reduce the number of multiplicaitons needed when
possible.

Note there are still quite a few more optimizations that could be done
such as using precomputation for ScalarBaseMult, making use of the
secp256k1 endomorphism, and using windowed NAF, however this work already
offers significant performance improvements.

For example, testing 10000 random signature verifications resulted in:
New btcec took 15.9821565s
Old btcec took 2m34.1016716s

Closes conformal/btcd#26.
2013-12-20 15:07:15 -06:00
Dave Collins
cc9aadf041 Don't use headers first when checkpoints disabled.
Headers first relies on having valid checkpoints, so if checkpoints are
disabled, it needs to be disabled as well.
2013-12-20 14:01:25 -06:00
Owain G. Ainsworth
2c81f61616 Also drain the inv channel as well as the message channel on peer quit.
Shold prevent a deadlock where we exit but server/blockmaanger is
waiting on our inv channel.

Closes #62
2013-12-17 15:51:37 +00:00
Owain G. Ainsworth
d72255bce3 gofmt 2013-12-17 14:02:35 +00:00
Owain G. Ainsworth
8310661c29 Parse out ports from externalip strings if present.
If not, continue to use the default. Should fix a problem reported by
Justus Ranvier on github.

Closes #38 (again)
2013-12-16 20:48:23 +00:00
Owain G. Ainsworth
7b304515d6 fix getrawtransaction verbose to be bool. 2013-12-16 18:14:51 +00:00
Owain G. Ainsworth
8aaad1e97b Add support for verbose in getrawmempool.
Closes #55.
2013-12-16 18:14:50 +00:00
Owain G. Ainsworth
4cb318ac02 Handle optional verbose parameter to getrawmempool.
This does remove the `nicer' type handle for getrawmempool for now since
it is no longer so simple.

ok jcv.
2013-12-16 18:01:45 +00:00
Josh Rickmar
e4fa45ff08 Better logging for rescans. 2013-12-16 09:09:28 -05:00
Josh Rickmar
2be94151a3 Add positive tests for commands.
Fixes #3.
2013-12-13 12:30:23 -05:00
Josh Rickmar
2731634dda Implement notifications that actually follow the JSON-RPC spec.
This changes notifications to JSON-RPC Requests, rather than
Responses, that also satisify the btcjson.Cmd interface and are
registered with btcjson's parser.  This prevents issues where JSON-RPC
Response IDs clash due to a client using the same ID as what an old
notification used.

As this changes the API, and thus, requires notification handlers to
be modified, the remaining missing notifications used by btcwallet
have been implemented.  Applications parsing these notifications, such
as btcgui, can now use a common handler function signature for all
notifications.

Test coverage for all notifications has been added (excluding testing
for badly-marshaled notifications with wrong numbers of parameters, or
wrong types).

Fixes #2.
2013-12-13 10:59:09 -05:00
Dave Collins
011025dc0d Fix regtest mode with new headers-first approach.
The regression test does not work properly with the new headers-first
download approach, so force the old inv-based block download for
regression test mode.
2013-12-12 18:10:06 -06:00
Dale Rahn
7b406dcb0f Implement a fast path for the Initial Block Download.
It is not necessary to do all of the transaction validation on
blocks if they have been confirmed to be in the block chain leading
up to the final checkpoint in a given blockschain.

This algorithm fetches block headers from the peer, then once it has
established the full blockchain connection, it requests blocks.
Any blocks before the final checkpoint pass true for fastAdd on
btcchain operation, which causes it to do less valiation on the block.
2013-12-12 17:24:05 -05:00
Dave Collins
c34ab6a95e Remove sqlite3 import from addblock.
The sqlite3 db backend is deprecated, so this is no longer needed.  Also,
since sqlite3 is a cgo binding it doesn't cross compile nicely.
2013-12-12 13:37:46 -06:00
Dave Collins
bbc3c1cf7e Prepare for release 0.4.0. 2013-12-12 13:27:06 -06:00
Dale Rahn
992d11830c Implement a fast path for the Initial Block Download.
It is not necessary to do all of the transaction validation on
blocks if they have been confirmed to be in the block chain leading
up to the final checkpoint in a given blockschain.

This algorithm fetches block headers from the peer, then once it has
established the full blockchain connection, it requests blocks.
Any blocks before the final checkpoint pass true for fastAdd on
btcchain operation, which causes it to do less valiation on the block.
2013-12-12 07:54:48 -05:00
John C. Vernaleo
1f52db626d Update test coverage. 2013-12-11 13:43:18 -05:00
John C. Vernaleo
4d0cbb776b Make id omitemtpy to match spec better. 2013-12-11 13:42:29 -05:00
Josh Rickmar
630d38b1b9 Add README. 2013-12-11 12:16:04 -05:00
Dave Collins
472c998c0d Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 19:17:59 -06:00
Dave Collins
b23acb632a Add support for TravisCI. 2013-12-10 19:10:53 -06:00
Owain G. Ainsworth
95563691cd go fmt. 2013-12-11 00:41:03 +00:00
Dave Collins
c0c167cc15 Remove logging bits from script_test.go.
The allows the tests to run without showing warning for malformed bits
(which are intentionally malformed for testing purposes).  Also, the
tests would not compile since the new btclog backend was switched out.
This commit resolves that.
2013-12-10 18:31:21 -06:00
Dave Collins
18576ab105 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 18:01:11 -06:00
Dave Collins
621f9006bf Correct tests for recent getblock updates. 2013-12-10 17:13:42 -06:00
Owain G. Ainsworth
7df65008be Run interrupt handlers in lifo order. 2013-12-10 22:40:26 +00:00
Owain G. Ainsworth
2a554c43b0 Shutdown server fully on ctrl-c
since we don't wait for peers, this largely just waits for the server procs
themselves to die. Unless the entire server is wedged (which is what kill -9 is
for) this should always shut down fairly swiftly.

This should mean we sync addrmanager and disestablish upnp correctly on
interrupt.

Discussed with davec.
2013-12-10 22:40:17 +00:00
Owain G. Ainsworth
f8e88df237 Add basic support for UPnP.
This code borrows and fixes up a chunk of code to handle upnp from
Taipei-Torrent (https://github.com/jackpal/Taipei-Torrent), under
current versions of go none of the xml parsing was working correctly.
This fixes that and also refactors the SOAP code to be a little nicer by
stripping off the soap containers. It is still rather rough but seems to
correctly redirect ports and advertise the correct address.

Upnp is not run by default. --upnp will enable it, but it will still not
run if we are not listening or if --externalip is in use.

Closes #51
2013-12-10 22:39:54 +00:00
Dave Collins
8a132ffde8 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2013-12-10 16:30:47 -06:00
Dave Collins
e5a09bdfaa Configure TravisCI to pull pkgs needed for tests. 2013-12-10 16:13:08 -06:00
Dave Collins
55331de532 Configure TravisCI to pull pkgs needed for tests. 2013-12-10 16:10:14 -06:00
Josh Rickmar
dda0cce06f Add getaddressbalance extension. 2013-12-10 16:14:35 -05:00
Owain G. Ainsworth
1145fb57ed handle .onion addresses in deserialising addrmanager.
Use the generic function that already handles this.
2013-12-10 19:39:48 +00:00
Owain G. Ainsworth
8968f7dd74 Add support for --externalip.
Closes #38
2013-12-10 19:39:47 +00:00