Commit graph

435 commits

Author SHA1 Message Date
Dave Collins
7d8bb5ab4c Add --cpuprofile option.
This commit provides a new --cpuprofile flag that can be used to specify a
file path to write CPU profile data into.  The resulting profile can then be
consumed by the 'go tool pprof' command.
2013-10-26 16:13:50 -05:00
Dave Collins
1aa65e6863 Correct and improve SIGINT (Ctrl+C) handling.
Since the main SIGINT handler is running as a goroutine, the main
goroutine must be kept active long enough for it to finish or it will be
nuked when the main goroutine exits.  This commit makes that happen by
slightly modifying how it waits for shutdown.

Rather than having the main goroutine only wait for the server to
shutdown, there is now a shutdown channel that is used to signal the main
goroutine to shutdown for all cases such as a graceful shutdown, a
scheduled shutdown, an RPC stop, or a SIGINT.

While here, also add a few prints to indicate a SIGINT was received and
the shutdown progress.
2013-10-26 16:10:04 -05:00
Dave Collins
36bd4b8994 Revert "Enable memdb support."
This reverts commit 1fadf619c7.
2013-10-26 01:58:50 -05:00
Dave Collins
7b01074f5e Add simple benchmark for MruInventoryMap handling. 2013-10-26 01:57:00 -05:00
Dave Collins
261e61f8ee Vastly optimize the MRU inventory handling.
Profiling showed the MRU inventory handling was taking 5% of the total
block handling time.  Upon inspection this is because the original
implementation was extremely inefficient using iteration to find the
oldest node for eviction.

This commit reworks it to use a map and list in order to achieve close to
O(1) performance for lookups, insertion, and eviction.

The following benchmark results show the difference:

Before: BenchmarkMruInventoryList          100     1069168 ns/op
After:  BenchmarkMruInventoryList     10000000         152 ns/op

Closes #21
2013-10-26 01:39:53 -05:00
Dave Collins
1fadf619c7 Enable memdb support. 2013-10-25 21:41:17 -05:00
Dave Collins
24a5645fce Update for recent btcchain tx script val change.
The ValidateTransactionScripts was recently changed to accept script flags
which pass through to the script engine in order to control its validation
behavior.  This commit modifies the transaction memory pool script
validation code for this change and additionally adds the new flag to
perform canonical signtaure checking.
2013-10-25 15:36:31 -04:00
Josh Rickmar
618b885e9e Notify wallets of mined transactions.
This change allows btcwallet to keep a pool of transactions that have
not yet been mined into a block, notifying wallet when transactions
are mined, as well as introducing a new way to send the
btcd:blockconnected notification with wallet-specific information as
part of the same notification.  When a transaction is sent using the
RPC call 'sendrawtransaction', a notification request will be
automatically registered with the connected wallet (if using
websockets) to notify the wallet when the transaction first appears in
a block.

To perform this notification, and to avoid requiring wallets from
waiting for seperate mined tx notifications (and resend after a
timeout) or from sending an additional tx mined request for every tx
in the pool after each new block, the blockconnected notification is
now created seperately for each wallet.  If the notified wallet has
sent a transaction, an additional JSON field "minedtxs" will include
an array of transaction IDs that the wallet has created and which are
included in the new block.

This new unique blockconnected notification can also be used for
additional notifications that may happen each new block in the future,
and to cut down on existing notification handlers in btcwallet, such
as for transactions to a watched address.
2013-10-23 18:13:03 -04:00
Dave Collins
2bb8c5d5cc Bring back default redirect for profiling.
Now that the RPC server uses its own mux, bring back the code which does
the automatic 303 redirect for the root of the profile server.
2013-10-23 10:48:17 -05:00
Dave Collins
5a4772bdc6 Change the RPC server to use it's own Muxer.
Rather than relying on the http package's DefaultServeMux for the RPC
server, create a unique mux specifically for the RPC server.  This ensures
things, such as the http profiling handlers, do not commingle.
2013-10-23 10:45:43 -05:00
Dave Collins
8970d4bf99 Revert "Add default redirect for profiling when enabled."
This reverts commit cc6cfdad9e.
2013-10-23 10:25:09 -05:00
Dave Collins
cc6cfdad9e Add default redirect for profiling when enabled.
This commit adds a simple 303 redirect for the root of profile server so
launching it without a path automatically goes to the debug profiling
page.
2013-10-23 09:39:02 -05:00
Dave Collins
7846b2f4e2 Update README.md TODO to remove 32-bit MSI.
32-bit MSIs will now be available for all future releases.
2013-10-22 17:05:43 -05:00
Dave Collins
1e93cdad6e Add 0.3.2 deps to deps.txt. 2013-10-22 16:45:19 -05:00
Dave Collins
3b025b2352 Prepare for release 0.3.2. 2013-10-22 16:40:51 -05:00
Dave Collins
8f75a09479 Remove sqlite as an available db type. 2013-10-22 15:01:51 -05:00
John C. Vernaleo
1420eccf73 Use rpc errors defined in btcjson. 2013-10-22 12:28:00 -04:00
Dave Collins
9ded3fa2cf Generate usage from handler data in btcctl.
Rather than having to keep the usage in sync with the supported commands,
simply include the usage as a field in the command handlers map and
dynamically generate the usage from there.
2013-10-22 10:56:56 -05:00
Dave Collins
d4f980c71f Show usage on no params to btcctl. 2013-10-22 10:15:46 -05:00
Dave Collins
c55152ef7e Always return non-zero code from btcctl on error. 2013-10-22 10:01:13 -05:00
Dave Collins
629168b7ae Perform display handler check before issues RPC.
This commit modifies the command handler in btcctl to check the existence
of a display handler before issues an RPC command.  This prevents a round
trip to the server if there is no display handler.

Also, fix a couple of comments while here.
2013-10-22 00:40:17 -05:00
Dave Collins
4e5cd1a326 Allow nil conversion handlers in btcctl. 2013-10-21 23:03:11 -05:00
Dave Collins
2ea4239f5e Improve btcctl.
This commit significantly reworks btcctl to use a map based approach to
command handling.  This reduces the number of lines of code needed,
simplifies adding new commands, improves the error handling, and removes
several cases where unexpected data was not handled properly (it could
panic).

This commit also adds the ability to specify the optional parameter on
getrawtransaction.

Discussed with dhill@.
2013-10-21 22:58:47 -05:00
Dave Collins
102fc5f513 Rework the mempool locking code.
It was previously possible for the unprotected iteration of the mempool
orphans to lead to undefined results.  This commit remedies that by
reworking the locking code a bit.  It also embeds the mutex directly into
the mempool struct rather than having a separate field for it so the
syntax is a slightly cleaner.
2013-10-21 18:22:59 -05:00
David Hill
27abb0eb3e add "addnode" to btcctl 2013-10-21 14:09:05 -04:00
David Hill
e1a02d71b3 add getpeerinfo to btcctl 2013-10-21 13:26:40 -04:00
David Hill
a975b60a0a add getconnectioncount skeleton to rpc 2013-10-21 13:00:13 -04:00
David Hill
3130659cdf add getconnectioncount to btcctl 2013-10-21 12:59:07 -04:00
Josh Rickmar
5bfc9c7eed Remove possible nil pointer dereferences.
Results from FetchTxByShaList must each be checked for a nil Err and a
non-nil Tx.  Fix this issue in two places where these conditions were
not being checked.
2013-10-20 13:02:34 -04:00
Dave Collins
d44d253dff Make quit channel with RPC server.
The latest websockets code added a quit channel to the RPC server, but did
not initialize it.  This commit corrects that so shutdown works properly
again.
2013-10-20 11:06:36 -05:00
David Hill
0abfdcc88b fix reversed variables in a warning message. 2013-10-17 16:58:57 -04:00
Dave Collins
e5620d6387 Correct reply for getrawmempool RPC command.
The RPC command needs to return a slice of hash strings, not the
underlying *btcwire.ShaHash bytes.
2013-10-17 12:11:04 -05:00
David Hill
ff20c420a2 add decoderawtransaction, getbestblockhash, getdifficulty, and
getrawmempool to btcctl.
2013-10-17 12:35:27 -04:00
David Hill
4c50ff541f fix getbestblockhash 2013-10-17 12:33:46 -04:00
David Hill
ffed6599ce add getrawmempool to rpcserver 2013-10-17 12:23:53 -04:00
Owain G. Ainsworth
5a9cc91e62 Add an idle timer for peers.
If we don't hear from a peer for 5 minutes, we disconnect them. To keep
traffic flowing we send a ping every 2 minutes if we have not send any
other message that should get a reply.
2013-10-17 17:06:47 +01:00
Owain G. Ainsworth
bc89dedf9a Remove prevGetBlocksMutex.
This is only ever accessed from one place (blockmanager) which is single
threaded.
2013-10-17 17:06:47 +01:00
Owain G. Ainsworth
a41c874837 Remove stale comment. 2013-10-17 17:06:47 +01:00
Owain G. Ainsworth
2231456c23 Make it possible to get a notification when a message has been sent.
If a channel is passed in then true will be sent on the provided channel
after the message has successfully sent.
2013-10-17 17:06:41 +01:00
Owain G. Ainsworth
178d9dc7b0 Peer: use QueueMessage instead of directly using the channel. 2013-10-17 17:05:21 +01:00
Owain G. Ainsworth
163b32887b Add blockmanager.current with extra checks for whether we are up to date.
This uses peer state to confirm if we are up to date, as well as what
chain thinks.
2013-10-17 17:05:18 +01:00
Josh Rickmar
bbcfdcf5aa Clean up notification contexts and goroutines after ws disconnect.
This refactors the wallet notification code to reverse the order of
how notification contexts are stored.  Before, watched addresses and
outpoints were used as keys, with a special reply channel as the
value.  This channel was read from and replies were marshalled and
sent to the main wallet notification chan, but the goroutine handling
this marshalling never exited because the reply channel was never
closed (and couldn't have been, because there was no way to tell it
was handling notifications for any particular wallet).

Notification contexts are now primarily mapped by wallet notification
channels, and code to send the notifications send directly to the
wallet channel, with the previous goroutine reading the reply chan
properly closing.

The RPC code is also refactored with this change as well, to separate
it more from websocket code.  Websocket JSON extensions are no longer
available to RPC clients.

While here, unbreak RPC.  Previously, replies were never sent back.
This broke when I merged in my websocket code, as sends for the reply
channel in jsonRead blocked before a reader for the channel was
opened.  A 3 liner could have fixed this, but doing a proper fix
(changing jsonRead so it did not use the reply channel as it is
unneeded for the standard RPC API) is preferred.
2013-10-17 09:11:55 -04:00
David Hill
90fbae1781 give btcctl some options instead of using hardcoded values 2013-10-16 19:19:26 -04:00
mischief
f346c36a0d add setLimits stub for plan 9 2013-10-16 15:19:21 -05:00
Dave Collins
ae5810bc50 Change default RPC port to 8334 (18334 testnet).
This change paves the way for running btcwallet on the same system without
having to change any settings.  The well-known ports used by the
reference implementation (8332 mainnet, 18332 testnet) will be exposed by
the separate wallet process, which will in turn forward unknown requests
to btcd via websockets (on 8334/18334).  This allows the wallet process to
ultimately provide a unified interface that exposes the same RPC-JSON API
as the reference implementation will maintaining wallet and chain
separation.
2013-10-16 15:01:43 -05:00
Dave Collins
ccfcbebbdc Add config file information to command doc. 2013-10-16 10:16:11 -05:00
Dave Collins
dd6b71300f Add basic btcd command documentation.
This will be expanded upon in future commits.
2013-10-16 10:04:12 -05:00
Dave Collins
f10d2c9449 Add sample relnotes format release script expects. 2013-10-15 18:16:18 -05:00
Dave Collins
b03817c0d8 Add script to help prepare releases. 2013-10-15 18:05:24 -05:00
Dave Collins
f40181615e Unix line endings on CHANGES file. 2013-10-15 17:53:16 -05:00