Commit graph

2167 commits

Author SHA1 Message Date
Dave Collins
000691dc9e Implement BIP0061 reject handling (pver 70002).
This commit implements reject handling as defined by BIP0061 and bumps the
maximum supported protocol version to 70002 accordingly.

As a part of supporting this a new error type named RuleError has been
introduced which encapsulates and underlying error which could be one of
the existing TxRuleError or btcchain.RuleError types.

This allows a single high level type assertion to be used to determine if
the block or transaction was rejected due to a rule error or due to an
unexpected error.  Meanwhile, an appropriate reject error can be created
from the error by pulling the underlying error out and using it.

Also, a check for minimum protocol version of 209 has been added.

Closes #133.
2014-07-14 12:25:11 -05:00
Dave Collins
4deb922c9d Export command constants.
Although it is possible to get the command name for each msg type by
creating an instances of the type and calling the Command method against
it, it's slightly more efficient to simply allows callers to have direct
access to the exported constants.

This is currently really useful for the reject message since callers need
to be able to examine the command type to determine whether or not the
hash field needs to be included.
2014-07-14 10:38:29 -05:00
David Hill
2f0cab1a48 Log accepted blocks via submitblock.
ok @davecgh
2014-07-14 11:08:07 -04:00
Dave Collins
7ee3a2220b Use a more specific license adjective. 2014-07-13 12:15:50 -05:00
Dave Collins
dd70618cc1 Export CommandSize constant.
This commit exports the CommandSize constant to provide callers with the
ability to know the size of the command field in a bitcoin message header.
2014-07-12 17:35:14 -05:00
Josh Rickmar
e495dcbc2f Fix off-by-one making rescanfinished notification.
Fixes #150.

ok @davecgh
2014-07-12 09:43:53 -05:00
Dave Collins
be7923a4ed Update to account for recent btcchain API changes. 2014-07-11 09:57:03 -05:00
Dave Collins
ff4d01765f Split time too old error into two distinct errors.
This commit splits the two rule validation errors related to the timestamp
being too old into two distince errors rather than grouping them under the
same one.  Thus there is now a new ErrCheckpointTimeTooNew in addition to
the existing ErrTimeTooNew error.

This allows the caller to detect the when a block is rejected due to a
time-related checkpoint failure whereas before the combined error did not.
2014-07-11 09:48:36 -05:00
Dave Collins
a261436e1b Use chan struct{} for throttling related chans.
The done and wait channels used to throttle outgoing data are being used
as semaphores.  As mentioned in the previous commit, it's more efficient
to use a 0-byte type and allow compiler optimizations for the specific use
case.
2014-07-10 22:42:27 -05:00
Dave Collins
83cffc5d27 Use chan struct{} for tx/blockProcessed chans.
These channels are being used as semaphores, so it's more efficient to use
a 0-byte type and allow compiler optimizations for the specific use case.
2014-07-10 22:29:07 -05:00
Dave Collins
1483b92dcf Remove outdated comment. 2014-07-10 22:20:10 -05:00
Dave Collins
c7a6645ebe Correct pushGetMerkleBlock throttling.
This commit corrects the check which sends in the done channel when
pushing merkle blocks that have no transactions to go with them.
2014-07-10 21:45:45 -05:00
David Hill
06d2707744 We only care about the peers.json file... 2014-07-10 19:28:30 -05:00
David Hill
d269887c56 Put mutexes in exported functions. 2014-07-10 19:23:31 -05:00
David Hill
36e8b4c82e organize.
no objections from @davecgh
2014-07-10 19:03:34 -05:00
David Hill
ba937630d0 each goroutine needs its own random source.
caught by the race detector.
2014-07-10 14:52:02 -04:00
Dave Collins
bd7a100ebb Address a few more comments. 2014-07-10 09:43:03 -05:00
Dave Collins
ffe0b09890 Seed random generator in RPC server during init.
Rather than reseeding the PRNG used throughout the RPC server on each
call, do it once during init.

Suggested by @jrick
2014-07-10 09:43:02 -05:00
Dave Collins
180f4ac0a2 Implement some BIP0023 getblocktemplate mutations.
This commit implements a portion of the mutations section of BIP0023.
In particular, it adds the mutable, mintime, maxtime, and noncerange keys
to the returned block template along with indicating support for the time,
transactions/add, prevblock, and coinbase/append mutations.  Also, the
addition of the mintime and maxtime fields imply support for the
time/decrement and time/increment mutations.  Further, if the caller
indicates the coinbasevalue capability, the coinbasetxn field will be
omitted thereby implying support for the coinbase and generation
mutations.

Closes #124.
2014-07-10 09:43:01 -05:00
Dave Collins
21050b4751 Implement BIP0023 getblocktemplate block proposals.
This commit implements block proposals as defined by BIP0023.

This is work towards #124.
2014-07-10 09:43:00 -05:00
Dave Collins
db20f25ff7 Implement BIP0023 basic pool extensions support.
This commit implements the basic pool extension portion of the getblocktemplate
RPC as defined by BIP0023.

This is work towards #124.
2014-07-10 09:42:59 -05:00
Dave Collins
fc5656894d Implement getblocktemplate long poll support.
This commit implements the long polling portion of the getblocktemplate
RPC as defined by BIP0022.  Per the specification, each block template is
returned with a longpollid which can be used in a subsequent
getblocktemplate request to keep the connection open until the server
determines the block template associated with the longpollid should be
replaced with a new one.

This is work towards #124.
2014-07-10 09:42:58 -05:00
Dave Collins
eb7ecdcc22 Implement basic getblocktemplate BIP0022 support.
This commit implements the non-optional and template tweaking support for
the getblocktemplate RPC as defined by BIP0022.  This implementation does
not yet include long polling support.

This is work towards #124.
2014-07-10 09:42:57 -05:00
David Hill
3a45ec1058 Change AddAddressByIP to return an error. 2014-07-09 21:24:06 -04:00
David Hill
f7ce37f8c1 Switch btcctl to use btcutil.Amount. 2014-07-09 16:28:45 -04:00
David Hill
e68d46f556 Add full support for BIP0037 bloom filters.
This commit implements full support for filtering based on the filterload,
filteradd, filterclear, and merkleblock messages introduced by BIP0037.

This allows btcd to work seamlessly with SPV wallets such as BitcoinJ.

Original code by @dajohi.  Cleanup, bug fixes, and polish by @davecgh.
2014-07-09 13:33:42 -05:00
Dave Collins
307c52f25b Add new DNS seed for seeds.bitcoin.open-nodes.org. 2014-07-09 09:20:40 -05:00
Dave Collins
6a8b806a20 Correct QueueNotification comment.
This comment incorrectly said QueueMessage instead of QueueNotification.
2014-07-09 01:37:55 -05:00
Dave Collins
6248dd5e5d Don't return a double pointer.
This commit has no effect on the effective functionality since Go
automatically deferences pointers, but there is no reason to have a
double indirection when returning the reply for getmininginfo.
2014-07-09 01:34:56 -05:00
Dave Collins
95167204d9 Add ExtractPkScriptAddrs examples. 2014-07-08 14:59:57 -05:00
Dave Collins
631c7850ec Correct example link in README.md. 2014-07-08 14:43:50 -05:00
Dave Collins
abafe9678b Use testable example and update doc.go README.md.
This commit adds an example test file so it integrates nicely with Go's
example tooling.

This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
It is also nice to have the example in one place rather than repeating it
in doc.go and README.md.

Links and information about the example have been included in README.md in
place of the example.
2014-07-08 14:42:39 -05:00
Dave Collins
3c2ae358b4 Add godoc reference badge to README.md. 2014-07-08 14:13:08 -05:00
Josh Rickmar
9e60210f18 Update for untyped btcutil consts.
ok @davecgh
2014-07-08 11:14:46 -05:00
Dave Collins
cc315d045e Use a more specific license adjective in README.md. 2014-07-08 10:32:29 -05:00
Dave Collins
d9ee066af6 Example link godoc web don't match local godoc. 2014-07-08 10:05:58 -05:00
Dave Collins
1c877b33ea Use magic syntax for godoc NewestSha example. 2014-07-08 10:04:03 -05:00
Dave Collins
4422b14f63 Categorize NewestSha example under Db interface.
It seems the godoc example extraction does not recognize the same syntax
used for functions with receivers when working with interfaces.

So, instead, categorize the example on the interface.
2014-07-08 09:27:13 -05:00
Dave Collins
05ff5bd8ec Add NewestSha example. 2014-07-08 09:10:14 -05:00
Dave Collins
329c0bf094 Update overview documentation to more recent stats. 2014-07-08 08:54:55 -05:00
Dave Collins
a12b62c24c Add commented imports to the example. 2014-07-08 08:50:12 -05:00
Dave Collins
9ed908f44a Use testable example and update README.md.
This commit moves the example to a test file so it integrates nicely with
Go's example tooling.

This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
It is also nice to have the example in one place rather than repeating it
in doc.go and README.md.

Links and information about the example have been included in README.md in
place of the example.
2014-07-08 08:47:18 -05:00
Dave Collins
7354ecefe8 Add godoc reference badge to README.md. 2014-07-08 08:26:17 -05:00
Dave Collins
01fa7fa069 Add BigToCompact example. 2014-07-08 07:57:22 -05:00
Dave Collins
1a2baa3099 Add CompactToBig example. 2014-07-08 02:15:41 -05:00
Dave Collins
62c14b7001 Name new example so it shows up properly on godoc. 2014-07-08 01:49:48 -05:00
Dave Collins
94845326b5 Use testable example and update doc.go README.md.
This commit moves the ProcessBlock example to a test file so it integrates
nicely with Go's example tooling.

This allows the example output to be tested as a part of running the
normal Go tests to help ensure it doesn't get out of date with the code.
It is also nice to have the example in one place rather than repeating it
in doc.go and README.md.

Links and information about the example have been incldued in doc.go and
README.md in place of the example.
2014-07-08 01:45:28 -05:00
Dave Collins
7e875e7952 Add godoc reference badge to README.md. 2014-07-07 23:00:13 -05:00
Dave Collins
5a4242cb03 Update doc.go and README.md examples to use memdb.
Since the code is only intended to be example code, there is no reason to
use a database which actually writes to disk.
2014-07-07 22:52:36 -05:00
Dave Collins
8005d2e455 Update TODO list in README.
This package has supported https for quite some time.
2014-07-07 22:40:32 -05:00