Commit graph

530 commits

Author SHA1 Message Date
Dave Collins a39f4a0698 Correct total byte counters for server.
Previously the getnettotals was just looping through all of the currently
connected peers to sum the byte counts and returning that.  However, the
intention of the getnettotals RPC is to get all bytes since the server was
started, so this logic was not correct.

This commit modifies the code to keep an atomic counter on the server for
bytes read/written and has each peer update the server counters as well as
the per-peer counters.
2014-02-05 11:15:41 -06:00
Dave Collins 5d70935b04 Convert getnettotals TimeMillis field to UTC.
This matches the reference implementation.
2014-02-05 09:54:16 -06:00
Dave Collins 6f5f582c42 Implement getnettotals RPC.
Also, change the display handler for getnettotals in btcctl to the JSON
display handler for better display.

Closes #84.
2014-02-05 09:39:03 -06:00
Dave Collins f8c843e2e3 Rename bytesRead/Written to bytesReceived/Sent.
This makes it a little more clear the variables reprsent bytes sent across
the network as opposed to from disk.
2014-02-04 22:37:13 -06:00
Dave Collins 7cfef69f23 Prepare for release 0.6.0. 2014-02-04 17:38:24 -06:00
Dave Collins bcb5a21b37 Add comment to ErrBadAuth to make go lint happy. 2014-02-04 15:37:34 -06:00
Dave Collins 238d942a69 Make go vet happy. 2014-02-04 15:34:44 -06:00
David Hill c1df0bfce6 get rid of redundant &handlerData 2014-02-04 15:49:31 -05:00
David Hill 9f044fb946 use %d for int32 2014-02-04 13:55:23 -05:00
Josh Rickmar 979357c5f1 Add sendtoaddress support to btcctl. 2014-02-04 13:18:58 -05:00
Dave Collins 038c8fb278 Add wiki link to README.md.
T#	util/loadheaders/
2014-02-04 11:06:39 -06:00
Dave Collins 71c35ec521 Update README.md with recent information. 2014-02-04 11:03:35 -06:00
Dave Collins cdbe387545 Add warning on invalid msg type in block manager. 2014-02-04 09:47:12 -06:00
Dave Collins d949072d6d Change new get sync peer bits to a query channel.
Rather than using a dedicated channel for the sync peer request and reply,
use a single query channel that accepts a query type as well as a reply
channel.  This will allow other queries to be added in the future without
the various queries being racy.
2014-02-04 09:47:07 -06:00
Dave Collins aab3a6643c Add getnettotals to btcctl. 2014-02-04 01:27:00 -06:00
Dave Collins ba5e457c38 Finish getpeerinfo RPC syncnode field.
This commit adds code to get the current sync peer from the block manager
for use in the getpeerinfo RPC.
2014-02-04 00:27:10 -06:00
Dave Collins 591b0f431d Switch over to new btcwire Read/WriteMessageN.
This commit adds byte counters to each peer using the new btcwire
ReadMessageN and WriteMessageN functions to obtain the number of bytes
read and written, respectively.  It also returns those byte counters via
the PeerInfo struct which is used to populate the RPC getpeerinfo reply.

Closes #83.
2014-02-04 00:00:13 -06:00
Dave Collins 2a7d725a09 Move websocket endpoint to /ws.
This commit moves the connection endpoint for websockets to /ws instead of
/wallet. First, the former is more standard, and second the latter
presumes how the websocket is to be used.

Closes #80.
2014-02-03 10:46:03 -06:00
Dave Collins 5ec951f6a7 Rework and improve headers-first mode.
This commit improves how the headers-first mode works in several ways.

The previous headers-first code was an initial implementation that did not
have all of the bells and whistles and a few less than ideal
characteristics.  This commit improves the heaers-first code to resolve
the issues discussed next.

- The previous code only used headers-first mode when starting out from
  block height 0 rather than allowing it to work starting at any height
  before the final checkpoint.  This means if you stopped the chain
  download at any point before the final checkpoint and restarted, it
  would not resume and you therefore would not have the benefit of the
  faster processing offered by headers-first mode.
- Previously all headers (even those after the final checkpoint) were
  downloaded and only the final checkpoint was verified.  This resulted in
  the following issues:
  - As the block chain grew, increasingly larger numbers of headers were
    downloaded and kept in memory
  - If the node the node serving up the headers was serving an invalid
    chain, it wouldn't be detected until downloading a large number of
    headers
  - When an invalid checkpoint was detected, no action was taken to
    recover which meant the chain download would essentially be stalled
- The headers were kept in memory even though they didn't need to be as
  merely keeping track of the hashes and heights is enough to provde they
  properly link together and checkpoints match
- There was no logging when headers were being downloaded so it could
  appear like nothing was happening
- Duplicate requests for the same headers weren't being filtered which
  meant is was possible to inadvertently download the same headers twice
  only to throw them away.

This commit resolves these issues with the following changes:

- The current height is now examined at startup and prior each sync peer
  selection to allow it to resume headers-first mode starting from the
  known height to the next checkpoint
- All checkpoints are now verified and the headers are only downloaded
  from the current known block height up to the next checkpoint.  This has
  several desirable properties:
  - The amount of memory required is bounded by the maximum distance
    between to checkpoints rather than the entire length of the chain
  - A node serving up an invalid chain is detected very quickly and with
    little work
  - When an invalid checkpoint is detected, the headers are simply
    discarded and the peer is disconnected for serving an invalid chain
  - When the sync peer disconnets, all current headers are thrown away
    and, due to the new aforementioned resume code, when a new sync peer
    is selected, headers-first mode will continue from the last known good
    block
- In addition to reduced memory usage from only keeping information about
  headers between two checkpoints, the only information now kept in memory
  about the headers is the hash and height rather than the entire header
- There is now logging information about what is happening with headers
- Duplicate header requests are now filtered
2014-02-01 16:33:00 -06:00
Dave Collins c6d865f3b5 Cleanup and slightly optimize the progress logging.
Previously the logging function which reports on progress was called for
every block, regardless of whether it was an orphan or not.  This could be
confusing since it could show a different number of blocks processed as
compared to the old versus new heights reported (orphans do not add to the
block height since they aren't extending the main chain).  Further, the
database had to be consulted for the latest block since the block we just
processed might not be the latest one if it was an orphan.  This is quite
a bit more time conusming than it should've been for progress reporting.

This commit modifies that to only include non-orphan blocks.  As a result,
the latest height shown will match the number of blocks processed (even
when there are orphans) and the additional block lookup from the database
is avoided.
2014-01-30 12:40:37 -06:00
David Hill 79ff9b76ee add verifymessage to btcctl 2014-01-30 13:26:15 -05:00
David Hill bd0c799e2f add validateaddress to btcctl 2014-01-30 13:14:28 -05:00
David Hill 9c2abd1fa1 add listreceivedbyaccount and listreceivedbyaddress to btcctl 2014-01-30 13:10:43 -05:00
David Hill 1a64f33fca add listunspent to btcctl 2014-01-30 12:59:26 -05:00
David Hill ed4ffc44a1 add listlockunspent to btcctl 2014-01-30 12:31:56 -05:00
David Hill 0951ffa1c7 add listaddressgroupings to btcctl 2014-01-30 12:29:21 -05:00
David Hill ea689489d3 add gettxoutsetinfo to btcctl 2014-01-30 12:23:38 -05:00
David Hill 46709bda08 add getrawchangeaddress to btcctl 2014-01-30 12:19:04 -05:00
David Hill 8749cde081 add getreceivedbyaccount and getreceivedbyaddress to btcctl 2014-01-30 12:08:50 -05:00
David Hill 2b9f5b8932 in getrawmempool verbose mode, initialize depends to an empty array.
this matches bitcoind.

from jrick
ok davec
2014-01-29 22:22:07 -05:00
David Hill b532860477 sync with btcjson changes to getrawtransaction.
ok oga@
2014-01-29 21:21:58 -05:00
Owain G. Ainsworth 82fca37eae implement the getinfo rpc command.
This contains some wallet inforamtion, but bitcoind if wallet is
disabled returns just the non wallet information. we do the same.
2014-01-29 18:31:33 +00:00
Owain G. Ainsworth 042d9206a1 change some more code over to using newer btcdb apis. 2014-01-29 18:31:33 +00:00
Owain G. Ainsworth 8d930ceed1 convert getdifficulty to getBlockHeaderBySha to save some cycles. 2014-01-29 18:31:33 +00:00
Dave Collins 970c0cdb30 Misc cleanup.
This commit contains various code cleanup such as comment fixes and
function ordering consistency.
2014-01-28 18:57:07 -06:00
David Hill 112525bd7a cleanup sendfrom and sendmany 2014-01-27 21:31:33 -05:00
David Hill 6c9a206709 add keypoolrefill to btcctl 2014-01-27 21:11:59 -05:00
David Hill 34849a181c add listaccounts to btcctl 2014-01-27 21:05:27 -05:00
Owain G. Ainsworth 5cef5bc05c add support for listsinceblock to btcctl 2014-01-27 23:22:09 +00:00
David Hill 2697a0a9ea add settxfee to btcctl 2014-01-27 16:31:48 -05:00
David Hill c0d6180685 add sendmany to btcctl 2014-01-27 15:57:44 -05:00
David Hill b354015426 add sendfrom to btcctl 2014-01-27 15:19:39 -05:00
Dave Collins 72afc787e6 Move getinfo RPC method to askwallet list.
The getinfo RPC method requires access to information only available in
the wallet.  Therefore, it has been moved to the list of methods which
return an error information the caller to send the request to the wallet
instead.
2014-01-27 13:52:59 -06:00
David Hill a5e5903caf add walletlock to btcctl 2014-01-27 13:44:31 -05:00
Josh Rickmar 36e5aa8e92 Add walletpassphrasechange support to btcctl. 2014-01-27 13:39:01 -05:00
David Hill ffe767c679 add getaddressesbyaccount to btcctl 2014-01-27 13:32:36 -05:00
David Hill 82552e4465 add walletpassphrase to btcctl 2014-01-27 12:49:54 -05:00
David Hill 221352586b add getnewaddress to btcctl 2014-01-27 12:35:20 -05:00
Dave Collins b9a641ab79 Move getnewaddress RPC method to askwallet list.
The getnewaddress RPC method deals with wallet-related functionality and
therefore has been moved to the list of methods which return an error
information the caller to send the request to the wallet instead.
2014-01-27 10:58:24 -06:00
Dave Collins 0bf4e0e097 Move getblocktemplate/getwork to askwallet list.
Both of these RPC methods require access to information ony available in
the wallet.  Therefore they have been moved to the list of methods which
return an error information the caller to send the request to the wallet
instead.
2014-01-25 22:58:38 -06:00