Commit graph

755 commits

Author SHA1 Message Date
Dave Collins
1db0eb4fec Update for recent btcjson changes.
This commit updates the types to match the recent changes to the btcjson
result types.
2014-06-29 16:37:21 -05:00
Dave Collins
0c9c005c33 Modify NewBlockTemplate to accept nil pay addr.
There are certain cases such as getblocktemplate which allow external
callers to be repsonsible for creating their own coinbase to replace the
generated one.  By allowing the pay address to be nil in such cases, the
need to specify mining addresses via --miningaddr can be avoided thereby
leaving the payment address management up to the caller.
2014-06-27 14:16:08 -05:00
Dave Collins
d40cff64b0 Expose a close ntfn channel to all RPC handlers.
This commit modifies the RPC server such that all handlers now receive a
channel which will be notified when a client disconnects.  This
notification can then be used to stop long-running operations early when a
client disconnects.

This capability was already present for websocket clients, but this commit
exposes it to standard HTTP clients as well.
2014-06-27 11:58:47 -05:00
Dave Collins
84af0d500f Update for SubmitBlockOptions field name change. 2014-06-27 00:27:32 -05:00
Dave Collins
59731e552b Update addblock for ProcessBlock behavior flags. 2014-06-26 17:42:13 -05:00
Dave Collins
48c6806b24 Update for btcchain ProcessBlock behavior flags.
ok @jrick
2014-06-26 17:18:05 -05:00
Dave Collins
21872ecdaa Update for recent btcchain ProcessBlock API change.
Now that the ProcessBlock function returns whether or not the block was an
orphan, the code which requests the parent blocks from the peer that sent
them has been moved to directly after the call to it.

This makes the handling more obvious and has allowed removal of the
blockPeer map which was kept so the notification handler could identify
which peer to request the blocks from.

ok @jrick
2014-06-25 17:46:11 -05:00
Josh Rickmar
35d555d541 Do not log warning for filtered block inv types.
ok @davecgh
2014-06-24 18:44:28 -05:00
Josh Rickmar
d2d518a8e4 btcctl: Add lockunspent support.
ok @davecgh
2014-06-24 18:36:05 -05:00
Dave Collins
5f444ce000 Wait for conection to peer before mining with CPU. 2014-06-19 09:44:12 -05:00
Josh Rickmar
6dc257b8c8 Notify websocket clients of finished rescans.
ok @davecgh
2014-06-16 14:48:52 -05:00
Dave Collins
289efbdea9 Update for recent btcjson API changes. 2014-06-16 14:44:36 -05:00
John C. Vernaleo
6a69acef21 Fix typo. 2014-06-12 15:41:57 -04:00
John C. Vernaleo
cd3d832551 Switch pingtime and pingwait to float64.
Needed to match bitcoin-core and btcjson.

ok @davec
2014-06-12 15:39:20 -04:00
David Hill
e9211bd01a Fix log message. 2014-06-12 14:04:05 -04:00
Dave Collins
eee338cbe3 Update mining-related RPC handlers for new code.
Now that btcd support CPU mining, update the getgenerate, setgenerate,
gethashespersec, and getmininginfo RPC handlers to return the appropriate
information.

Also, remove the various extra help addenda about btcd not supporting
mining since it is no longer true.
2014-06-12 12:06:26 -05:00
Dave Collins
e25b644d3b Implement a built-in concurrent CPU miner.
This commit implements a built-in concurrent CPU miner that can be enabled
with the combination of the --generate and --miningaddr options.  The
--blockminsize, --blockmaxsize, and --blockprioritysize configuration
options wich already existed prior to this commit control the block
template generation and hence affect blocks mined via the new CPU miner.

The following is a quick overview of the changes and design:

- Starting btcd with --generate and no addresses specified via
  --miningaddr will give an error and exit immediately
- Makes use of multiple worker goroutines which independently create block
  templates, solve them, and submit the solved blocks
- The default number of worker threads are based on the number of
  processor cores in the system and can be dynamically changed at
  run-time
- There is a separate speed monitor goroutine used to collate periodic
  updates from the workers to calculate overall hashing speed
- The current mining state, number of workers, and hashes per second can
  be queried
- Updated sample-btcd.conf file has been updated to include the coin
  generation (mining) settings
- Updated doc.go for the new command line options

In addition the old --getworkkey option is now deprecated in favor of the
new --miningaddr option.  This was changed for a few reasons:

- There is no reason to have a separate list of keys for getwork and CPU
  mining
- getwork is deprecated and will be going away in the future so that means
  the --getworkkey flag will also be going away
- Having the work 'key' in the option can be confused with wanting a
  private key while --miningaddr make it a little more clear it is an
  address that is required

Closes #137.

Reviewed by @jrick.
2014-06-12 12:05:32 -05:00
David Hill
8ce9c21148 Add new testnet seed testnet-seed.alexykot.me 2014-06-12 11:55:43 -04:00
Dave Collins
f0c05c76d3 Add getmininginfo to btcctl. 2014-06-11 22:41:22 -05:00
Dave Collins
c379061d6f Correct comment type for newInboundPeer. 2014-06-11 20:14:10 -05:00
David Hill
f67358d4db Add estimatefee and estimatepriority to btcctl. 2014-06-11 11:12:27 -04:00
David Hill
a992b48705 Add missing rpc commands and mark as unimplemented. 2014-06-11 10:46:19 -04:00
Brian Deery
ddc773535a Remove comments interpreted as settings
in go-flags/ini_private.go in function readIni there is no mechanism for
adding inline comments.  Only comments that have a semicolon as the first
non-whitespace character are ignored.

According to Wikipedia http://en.wikipedia.org/wiki/INI_file#Comments
inline comments are not universally supported.

This change adds some white space for readability, but
name := strings.TrimSpace(line[1 : len(line)-1]) removes accidental whitespace
left in later.

Closes #135.
2014-06-09 14:36:07 -05:00
Dave Collins
cc3e49fabb Make loadConfig function name a variable.
The errors in the loadConfig function had the function name hardcoded in
each error.  This commit assigns the function name to a variable instead.
2014-06-07 14:42:54 -05:00
Dave Collins
3266bf6a8d Convert to use gorilla websockets package.
Also, since the new websoscket package allows the message type to be set
independently from the type of the variable, remove the casts between
strings and []byte in the websocket read/write paths.  This avoids extra
copies thereby reducing the garbage generated.

Closes #134.
2014-06-07 01:34:33 -05:00
David Hill
bf48a97b0d Use NewReader instead of NewBuffer.
NewReader is slightly faster, but more importantly, ensures that the
data is read-only.
2014-06-05 14:00:22 -04:00
David Hill
8bce0ef3f8 Convert binary Write()'s to PutUint64()'s.
PutUint64 is faster than a generic binary write, and also removes
the 'bytes' package from the import list.
2014-06-05 14:00:22 -04:00
David Hill
7f825fd9bc Remove unneeded usage of fmt.Sprintf 2014-06-04 20:24:48 -04:00
David Hill
0acd038eb6 Use the correct network block for he.net. 2014-06-04 19:11:47 -04:00
Dave Collins
c673d76979 Fix case where block mgr could hang on shutdown.
This commit resolves an issue where it was possible the block manager
could hang on shutdown due to inventory rebroadcasting.  In particular, it
adds checks to prevent modification of the of rebroadcast inventory during
shutdown and adds a drain on the channel to ensure any outstanding
messages are discarded.

Found by @dajohi who also provided some of the code.
2014-06-02 16:15:24 -05:00
Dave Collins
468f8366cf Make multisig txns with non-null dummy nonstandard.
This commit helps prevent transaction malleability by enforcing that the
extra dummy value on multisig transaction script contains no data for a
transaction .  This syncs with a recent change in Bitcoin Core to remain
compatible.

As part of this change a new constant has been introduced which is used to
specify the script flags which are used for standard transactions.  This
constant is then used in both the memory pool and the mining code to
ensure they remain in sync with one another.

Closes #131.

ok @jrick, @dajohi
2014-05-31 11:56:58 -05:00
Dave Collins
0d2c5a8ffb Add --simnet option to btcctl.
This flag works similar to the existing --testnet flag does.  That is to
say it selects the default simulation test network RPC port for either
btcd or btcwallet depending on whether or not the --wallet flag is also
present.
2014-05-30 19:05:06 -05:00
Dave Collins
605eb7f4b4 Add a simulation test network via --simnet param.
This commit, along with recent commits to btcnet and btcwire, expose a new
network that is intended to provide a private network useful for
simulation testing.  To that end, it has the special property that it has
no DNS seeds and will actively ignore all addr and getaddr messages.  It
will also not try to connect to any nodes other than those specified via
--connect.  This allows the network to remain private to the specific
nodes involved in the testing and not simply become another public
testnet.

The network difficulty is also set extremely low like the regression test
network so blocks can be created extremely quickly without requiring a lot
of hashing power.
2014-05-29 15:10:12 -05:00
Dave Collins
252c022644 Convert to default net ports provided by btcnet.
ok @jrick
2014-05-29 12:47:08 -05:00
Josh Rickmar
74303966c0 Updates for btcutil and btcscript's btcnet conversion.
ok @davecgh
2014-05-27 17:44:55 -05:00
Dave Collins
4328461f36 Update for recent btcchain and btcnet API changes. 2014-05-27 10:12:59 -05:00
Dave Collins
009c4bcd76 Update findcheckpoint utility to use btcnet. 2014-05-27 00:56:54 -05:00
Dave Collins
dd8265c22c Convert addblock utility to use btcnet. 2014-05-27 00:48:00 -05:00
Dave Collins
7b0116dfd0 Prepare for release 0.8.0. 2014-05-25 15:52:47 -05:00
Dave Collins
aa1d722dd6 Update pre-release and README.me to beta.
This is part of the changes for #130.
2014-05-23 15:51:45 -05:00
Dave Collins
6d8b873923 Raise maxStandardSigScriptSize to 1650.
This commit raises the maximum allowed size for a standard signature
script to cover a 15-of-15 multi-signature pay-to-script-hash with
compressed pubkeys.

This mirrors a recent change to remain compatible with Bitcoin Core.

ok @owinga who also helped verify and correct the script math.

Closes #128.
2014-05-23 12:23:36 -05:00
Josh Rickmar
bcc78565fd Initial pass at updating to btcnet.
This change modifies the params struct to embed a *btcnet.Params,
removing the old parameter fields that are handled by the btcnet
package.

Hardcoded network checks have also been removed in favor of modifying
behavior based on the current active net's parameters.

Not all library packages, notable btcutil and btcchain, have been
updated to use btcnet yet, but with this change, each package can be
updated one at a time since the active net's btcnet.Params are
available at each callsite.

ok @davecgh
2014-05-23 01:02:14 -05:00
Dave Collins
342d0a536f Correct error message in handleGetWorkSubmission.
Found by go vet.
2014-05-22 23:48:02 -05:00
Dave Collins
b6af0a7a53 Remove extra return statement found by go vet.
The return statement was unreachable and thus this change has no
effect on functionality.
2014-05-22 23:46:41 -05:00
David Hill
225f6d3d06 Add setgenerate to btcctl 2014-05-16 12:06:09 -04:00
Dave Collins
d6f7adeba8 Improve btcctl handling of empty RPC data returns.
There are several RPCs which do not return any data on success.  btcctl
was improperly treating this as an error condition.
2014-05-13 15:25:36 -05:00
David Hill
ce142e8ca2 add getblockchaininfo to btcctl 2014-05-13 11:35:59 -04:00
Dave Collins
5b376b3b5e Expose getcurrentnet and getbestblock to HTTP POST.
This commit makes the getcurrentnet and getbestblock RPCs available to
clients making HTTP POST requests.

Closes #127.
2014-05-11 02:21:27 -05:00
Dave Collins
6a325f4c6a Improve getwork interaction with regtest mode.
Ordinarily, getwork will return an error if btcd is not connected to any
other peers.  This commit relaxes that requirement when running in
regression test mode since it is useful for development purposes.

While here, also improve check which returns an error from getwork is not
current to exclude the check when the best chain height is zero since the
code never believes it is current when at height 0.
2014-05-08 19:47:50 -05:00
Dave Collins
47e65634a7 Use btcd pver instead of wire pver in RPC encoding.
Along the same lines as the previous commit, the RPCs that return
serialized data structures should use the max protocol version btcd
supports as opposed to the maximum protocol version etcwire supports.
2014-05-07 11:33:32 -05:00