Commit graph

1714 commits

Author SHA1 Message Date
Dave Collins
48c6806b24 Update for btcchain ProcessBlock behavior flags.
ok @jrick
2014-06-26 17:18:05 -05:00
Dave Collins
67394ec45d Modify ProcessBlock to accept behavior flags.
This commit change the ProcessBlock function to accept a new type named
BehaviorFlags in place of the current fastAdd parameter.

This has been done to pave the way for adding more control over the checks
that are performed such as avoiding the proof of work checks which will be
in an upcoming commit.  A bitmask was chosen because it will allow the
ProcessBlock API to remain a little more stable since new flag additions
that change the behavior are only likely to be used by new code because
adding flags does not change the existing behavior.

ok @jrick
2014-06-26 17:17:32 -05:00
Dave Collins
7d84d801d7 Make golint happy. 2014-06-26 16:10:10 -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
Dave Collins
415ac4596a Make orphan ntfns to a return val on ProcessBlock.
This commit changes the way that orphan blocks are identified by adding a
new boolean return value on ProcessBlock and removing the notification for
NTOrphanBlock.

This allows the calling code to identify orphan blocks immediately instead
of having to setup a seperate callback handler and implementing some type
of state tracking.  This, in turn, allows cleaner code for handling them.

In addition, the tests have been updated for the new function signature
and also now check that each block is or is not an orphan as expected
which makes the tests more robust.

ok @jrick
2014-06-25 17:46:00 -05:00
Dave Collins
0550bbbdc5 Add tests for new RuleError and ErrorCode types. 2014-06-24 19:14:30 -05:00
Dave Collins
6e0aab52df Improve the RuleError type to include error codes.
This commit changes the RuleError type to a struct which consists of an
error code and human-readable description.

From a usage perspective, existing code should not break since type
asserting an error to a RuleError still works in the same manner.  The
difference is the caller can now take that type asserted RuleError and
access the .ErrorCode field on it to programmatically identify the
specific rule that was violated.

ok @jrick
2014-06-24 19:14:24 -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
David Hill
7d228846bd sync tx_valid.json test data. 2014-06-13 11:34:47 -04:00
Josh Rickmar
6d79aa5ff1 Test panic for converting invalid sha strings.
ok @davecgh
2014-06-13 09:49:08 -05:00
Josh Rickmar
4bbcede9e0 Add tests for network registration.
While here, fix a bug found through testing.  Register will now return
ErrDuplicateNet if the caller attempts to register any of the standard
network parameters provided by this package.

ok @davecgh
2014-06-13 09:49:02 -05:00
Dave Collins
41dce5796d Update to coveralls.io for test coverage reporting.
Also add a test coverage badge to the README.md.
2014-06-12 18:44:34 -05:00
Dave Collins
acda2044a0 Add godoc reference badge to README.md. 2014-06-12 18:40:44 -05:00
Dave Collins
3cbba55822 Add support for TravisCI.
Also add TravisCI build status badge to README.md.
2014-06-12 18:37:35 -05:00
Dave Collins
0f23236f43 Make subsidy halving interval for simnet 210000.
This value matches testnet and mainnet and makes more sense because it
allows way more coins to be generated which is useful during simulation
testing.

NOTE: this will invalidate existing simnet chains, but since they
are only intended to be short lived for the duration of a simulation test,
this is a non-issue.
2014-06-12 18:20:51 -05:00
Dave Collins
c71988f668 Add comments for prefixes the encoding IDs map to. 2014-06-12 18:14:46 -05:00
GeertJohan
a3091847b3 Fix adding wrong HashAddrID to pubKeyHashAddrIDs 2014-06-13 01:00:59 +02: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
Josh Rickmar
7dcb68275f Make MaxMessagePayload an exported constant.
ok @davecgh
2014-06-06 22:33:39 -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
Dave Collins
ee46a0b108 Use bytes.NewReader for deserialize when possible.
Rather than using bytes.NewBuffer, which is a read/write entity
(io.ReadWriter), use bytes.NewReader which is only a read entitiy
(io.Reader) in all cases where it is possible.  Benchmarking shows it's
slightly faster and it's also technically more accurate since it ensures
the data is read-only.

There are a few cases where bytes.NewBuffer must still be used since a
buffer with a known length is required for those instances.
2014-06-04 23:39:03 -05: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
2054fa7581 Update doc.go to reflect reality.
This commit updates doc.go to include the new simulation test network
magic constant as well as remove the information about BIP0037 not being
supported since that is no longer true.
2014-06-02 12:35:00 -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
David Hill
b40f5a1b24 add missing Lock to FetchTxBySha 2014-05-30 15:03:39 -04:00
Dave Collins
dc967b7cc8 Add params for new simulation testing network.
ok @jrick
2014-05-29 15:22:00 -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
31ee545aa9 Add bitcoin network type for simulation testing. 2014-05-29 12:50:17 -05:00
Dave Collins
252c022644 Convert to default net ports provided by btcnet.
ok @jrick
2014-05-29 12:47:08 -05:00
Dave Collins
218f8df5ba Add a default net port parameter to each network.
ok @jrick
2014-05-29 12:45:44 -05:00