Commit graph

424 commits

Author SHA1 Message Date
Josh Rickmar
a80f9da6c3 Add websocket handlers to the RPC server for wallet connections.
This change adds additional http listeners for websocket connections
on "/wallet".  Websockets are used to provide asynchronous messaging
between wallet daemons (i.e. btcwallet) and btcd as they allow an easy
way for btcd to provide instant notifications (instead of a wallet
polling for updates) and multiple replies to a single request.
Standard RPC commands sent over a websocket connection are handled
just like RPC, returning the same results, the only difference being
that the connection is async.  In cases where the standard RPC
commands fall short of wallet daemons requests, and to request
notifications for addresses and events, extension JSON methods are
used.

Multiple wallets can be connected to the same btcd, and replies to
websocket requests and notifications are properly routed back to the
original requesting wallet.

Due to the nature of turning a synchronous protocol asynchronous, it
is highly recommended to use the JSON id field as a type of sequence
number, so replies from btcd can be routed back to the proper handler
in a wallet daemon.
2013-10-14 13:37:48 -04:00
Dave Collins
44aafcf742 Return on file error in address manager save.
This commit modifies the address manager save code to exit when there is
an error creating the file used to store addresses.  Previously the error
was only logged leaving the invalid file handle to be used later.
2013-10-12 11:49:10 -05:00
John C. Vernaleo
6212a7daff Improve rpcserver.
Add getdifficulty command to rpcserver.

Add missing error check in an old bit of rpcserver.

Add getbestblockhash command.
2013-10-11 17:04:18 -04:00
Dave Collins
2a8122ffde Actually check orphan pool for IsOrphanInPool. 2013-10-11 15:46:24 -05:00
Dave Collins
6368d5b170 Respond to getdata requests for transactions.
This commit adds code to properly respond to getdata requests for
transactions by fetching them from the transaction pool.  Previously, we
advertised newly available transactions, but the code to respond with the
actual transaction was not written yet.

Also, fix a couple of comments and make the pushTxMsg and pushBlockMsg
functions consistent.
2013-10-11 14:14:55 -05:00
Dave Collins
10907027b7 Change failure to talk to DNS seeders to debug.
This is just a temporary failure and shouldn't be a warning.  Also,
remove redundant prefix on profile server log print while here.
2013-10-10 20:30:55 -05:00
Dave Collins
24aba3189e Update DISC subsystem log out for consistency. 2013-10-10 18:33:38 -05:00
Dave Collins
3d62b24fe1 Reformat periodic block height ouput and add time.
Closes #9.
2013-10-10 18:24:23 -05:00
Dave Collins
9772626dd8 Improve logging.
This commit is a first pass at improving the logging.  It changes a number
of things to improve the readability of the output.  The biggest addition
is message summaries for each message type when using the debug logging
level.

There is sitll more to do here such as allowing the level of each
subsystem to be independently specified, syslog support, and allowing the
logging level to be changed run-time.
2013-10-10 17:22:19 -05:00
Dave Collins
54b5cb56e7 Move logger code into its own file.
This cleans up btcd.go a bit and consolidates the logging related
functions.  It also paves the way for upcoming message summaries.
2013-10-10 14:36:05 -05:00
David Hill
55b300b6c2 improve addblock 2013-10-10 14:05:54 -04:00
David Hill
8a2299c1e1 improve dropafter as with showblock 2013-10-10 13:58:11 -04:00
David Hill
2231e04e2b improve showblock by setting default datadir and requiring -s 2013-10-10 13:51:20 -04:00
David Hill
c4d7b2d2c6 Improve showblock options, add --testnet and change default db to leveldb
to match btcd
2013-10-10 13:42:21 -04:00
Josh Rickmar
486907c441 Add -testnet flag to showblock. 2013-10-10 13:22:55 -04:00
Dave Collins
a275687f3f Make peer load message consistent and fix spello. 2013-10-10 10:06:58 -05:00
Dave Collins
e04986528c Add --nocheckpoints option.
This commit provides a new flag, --nocheckpoints, to disable built-in
checkpoints.

Checkpoints are used for a number of things such a ensuring
the block chain being downloaded matches various known good blocks,
allowing quicker verification on old blocks since scripts don't have to be
executed, and preventing forks from old blocks, etc.
2013-10-09 19:34:02 -05:00
Dave Collins
c1f0d9b1ad Make leveldb the default db for findcheckpoint.
This mirrors the change in btcd.
2013-10-08 20:50:15 -05:00
Dave Collins
a0119b056e Move transaction handling into block manager.
The block manager handles inventory messges to know which inventory should
be requested based on what is already known and what is already in flight.
So, this commit adds logic to ask the transaction memory pool if the
transaction is already known before requesting it and tracks pending
requests into an in-flight transaction map owned by the block manager.

It also moves the transaction processing into the block manager so the
in-flight map can be properly cleaned.
2013-10-08 20:46:59 -05:00
David Hill
e8d73d83ef Add btcctl; currently a barebones utility to send commands
to btcd.
2013-10-08 21:18:49 -04:00
Dave Collins
cd68e3060f Remove extra msg in log message. 2013-10-08 17:45:05 -05:00
Dave Collins
f4dac3abf0 Update to use latest btcwire invtype constants. 2013-10-08 15:55:07 -05:00
Dave Collins
c8160a57aa Switch to leveldb by default.
Also, add a warning if multiple block databases are detected.
2013-10-08 15:00:34 -05:00
Dave Collins
67838afb20 Go fmt and comments. 2013-10-08 13:34:04 -05:00
Dave Collins
2ad0d34d27 Add updating instruction to README.md. 2013-10-08 13:31:01 -05:00
Josh Rickmar
21a2158eca Fixes for btcutil and btcscript api changes 2013-10-08 12:37:06 -04:00
Dave Collins
697532bd68 Add handling for mempool command. 2013-10-08 00:04:51 -05:00
Dave Collins
d4e006e515 Update findcheckpoint to support testnet and dbtype. 2013-10-07 20:53:25 -05:00
Dave Collins
1d2c48555b Misc cleanup. 2013-10-07 19:24:44 -05:00
Dave Collins
19d28f90e6 Log transactions rejected from mempool as debug.
Most users won't care if a freestanding transaction is rejected from due
to a rule violation, but the information should still be available to
debug.
2013-10-07 18:45:53 -05:00
Dave Collins
849c830cf8 Move DNS seed consts to same file that uses them.
Also, use multi constant define for the result.
2013-10-07 17:58:16 -05:00
Dave Collins
c03f2b757b Move initial DNS seeding to own func. 2013-10-07 17:38:45 -05:00
Dave Collins
4b728df738 Update some comments and code consistency. 2013-10-07 17:27:59 -05:00
Dave Collins
ca5c734e05 Add warning if there are no sync peers.
This is to help track down stalls that are being seen.
2013-10-07 17:09:33 -05:00
Marco Peereboom
8e7d900201 Up some limits on !windows.
This is needed on OSX and possibly others.

ok davec
2013-10-07 16:44:46 -05:00
Dave Collins
995d8da491 Handle another removal case missed in prev commit.
Also, the loops which only remove a single element and break or return
don't need the extra logic for iteration since they don't continue
iteration after removal.
2013-10-07 10:10:22 -05:00
Dave Collins
219a6131f4 Correct all list/container loops that remove items.
It is not safe to remove an item from a container/list while iterating the
list without first saving the next pointer since removing the item nils
the internal list element's next pointer.
2013-10-07 09:06:29 -05:00
John C. Vernaleo
ff2c88e3b4 Fix an import path. 2013-10-07 10:06:15 -04:00
Dave Collins
8e12234c56 Fix a couple of comments. 2013-10-05 17:40:54 -05:00
Dave Collins
c28c6e7636 Correct blog link in README.md. 2013-10-05 02:51:12 -05:00
Dave Collins
19a238825b Fix typo in README.md 2013-10-05 02:48:03 -05:00
Dave Collins
4864298884 Update README. 2013-10-04 23:02:00 -05:00
Dave Collins
9197342df0 Add deps.txt to track all deps used per release. 2013-10-04 16:03:50 -05:00
Dave Collins
168ff0e129 Bump version to 0.3.0. 2013-10-04 14:29:37 -05:00
Dave Collins
bba9fed133 Accepted transactions should log at debug level. 2013-10-04 14:16:57 -05:00
Dave Collins
efb54784c8 Log rejected blocks and transactions as info.
Rather than logging these as warnings which implies something is wrong
that might require user action, log them as info.
2013-10-04 13:35:28 -05:00
Dave Collins
223d146a10 Improve logging of rejected transactions.
Rather than showing all errors from ProcessTransaction as a failure, 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-04 13:33:54 -05:00
Dave Collins
83ac359c51 Convert transaction pool errors to their own type.
This allows the caller to distinguish if the error is because of a rule
violation or due to something actually going wrong.
2013-10-04 13:30:50 -05:00
Dave Collins
78b555fcf9 Improve logging of rejected blocks.
Rather than showing all errors from ProcessBlock as a failure, check if
the error is a RuleError meaning the block was rejected as opposed to
something actually going wrong and log it accordingly.
2013-10-04 13:13:16 -05:00
Dave Collins
c3a17de326 Comment Connected function in peer.
While here, also rearrange the functions slightly to logically group them.
2013-10-04 10:45:21 -05:00