Commit graph

3390 commits

Author SHA1 Message Date
Dave Collins
2835238287 Correct child and orphan block removal logic.
It is not safe to remove elements from a slice while iterating them with
the range statement since it does not reevaluate the slice on each
iteration nor does it adjust the index for the modified slice.  This
commit modifies the code to use a for loop with an index (which does
reevaluate on every iteration) and manually adjusts the index when
elements are removed from the slice.
2013-08-17 14:05:36 -05:00
Dave Collins
60779ea8df Add message blocking semantics to block processing.
This commit modifies the input message handler so that when a remote peer
sends a block, no further messages from that peer are accepted until the
block has been fully processed and therefore known good or bad.  This
helps prevent a malicious peer from queueing up a bunch of bad blocks
before disconnecting (or being disconnected) and wasting memory.

Additionally, this behavior is depended on by at least the block
acceptance test tool as the reference implementation processes blocks in
the same thread and therefore blocks further messages until the block has
been fully processed as well.
2013-08-16 13:40:05 -05:00
John C. Vernaleo
b0ca6d5903 Fix typo in comment. 2013-08-15 10:15:25 -04:00
John C. Vernaleo
5d40d51672 Correct bug in walletpassphrase arguements.
Thanks to pureveg and hngchiming for pointing it out.
2013-08-14 10:15:16 -04:00
John C. Vernaleo
7a7fa56407 Make id an interface in CreateMessageWithId to match the struct better. 2013-08-13 17:01:38 -04:00
John C. Vernaleo
2e77f0bb0e Add CreateMessageWithId to allow custom id to be sent with message. 2013-08-13 14:39:56 -04:00
John C. Vernaleo
a456d195d6 Add JSONGetMethod to get method name from raw json reply. 2013-08-13 13:32:19 -04:00
John C. Vernaleo
96a68227bd Add RpcRawCommand and export ReadResultCommand.
Add new RpcRawCommand to get []byte represtation of reply instead of
btcjson.Result.

Export ReadResultCommand to allow caller of RpcRawCommand to deal with
the reply in the same way RpcCommand does.

Adjust test code to for the above changes.
2013-08-13 09:03:22 -04:00
Andrew Tian
8679275090 Fix doc example typo 2013-08-12 22:53:50 -05:00
John C. Vernaleo
c8bb6b304e Correct optional parameters for listsinceblock.
Fixes #3
2013-08-12 13:46:03 -04:00
John C. Vernaleo
dc2fe40a3d Fix comment typo noticed by jrick@ 2013-08-12 11:24:49 -04:00
Dave Collins
2570ecd2ac Move log closure code into its own file. 2013-08-10 20:07:37 -05:00
Dave Collins
f269ad2ff4 Comment the logClosure code. 2013-08-09 16:02:47 -05:00
Dave Collins
8634a2fa01 Refactor peer disconnect code into single func. 2013-08-09 15:57:13 -05:00
John C. Vernaleo
00cd730c3f Add stop command to rpcserver. 2013-08-09 16:20:06 -04:00
John C. Vernaleo
da7e872354 Add proper result type for listunspent. 2013-08-09 15:49:31 -04:00
Dave Collins
a3531957f4 Rework server startup and shutdown sequence.
The commit reworks the server statup and shutdown sequence to ensure the
server can always shutdown cleanly.  The peer code depends on being able
to send messages to the address and block managers, so they need to have
their lifecycle tied to the peer handler to prevent issues with
asynchronous shutdown order.
2013-08-09 14:43:30 -05:00
John C. Vernaleo
b28cded23e Add return types for additional commands and bug fixes.
Add return types for serveral additional commands.

Fix required vs. optional arguments for createrawtransaction.

Update tests and test coverage for all changes.
2013-08-09 14:06:45 -04:00
Dave Collins
f80bc8c8f9 Misc comment and doco cleanup. 2013-08-08 12:47:15 -05:00
David Hill
52416ec28f new option --tor (requires --proxy)
Although not required if the proxy set is indeed Tor, setting this option
does the following:
   - Sends DNS queries over the Tor network (during dns seed lookup).  This
     stops your IP from being leaked via DNS.
   - Does not disable the listening port.  This allows the hidden services
     feature of Tor to be used.
2013-08-08 12:11:39 -04:00
Dave Collins
41910c0944 Import needed package. 2013-08-08 10:11:03 -05:00
Dave Collins
1fecbec3df Move userAgent to peer where it's used. 2013-08-08 09:26:18 -05:00
Dave Collins
48d3c5f585 Make user agent use the app version constants. 2013-08-08 09:12:40 -05:00
Dave Collins
eab9c1f0c1 Insert genesis block if needed on db load.
Previously, the genesis block was only inserted when the database was
created, but it's possible due to rollback that the database is created
and the genesis block insert gets rolled back if the app is existed too
quickly.  This commit modifies the logic to test the need for the genesis
block any time the database is loaded and insert it if necessary.
2013-08-08 00:47:48 -05:00
Dave Collins
aad69df74b Include proxy address in connection messages. 2013-08-08 00:35:45 -05:00
Dave Collins
5ca605dadc Remove duplicate proxy setting from config. 2013-08-08 00:22:10 -05:00
Dave Collins
f0a0b06f29 Move sample proxy config near top of net settings. 2013-08-08 00:17:13 -05:00
David Hill
3f782928fd initial proxy code 2013-08-08 00:13:47 -05:00
Dave Collins
9a9f41a2f3 Modify code to use proxy aware NetAddresses.
This paves the way for support with proxied connections.
2013-08-07 23:53:19 -05:00
Dave Collins
0d7bff2444 Remove some unused code. 2013-08-07 23:44:04 -05:00
Dave Collins
b759bafa60 Add version information and -V/--version flags. 2013-08-07 18:53:01 -05:00
Dave Collins
f168694ecf Convert .gitignore line endings to unix. 2013-08-07 15:00:20 -05:00
Dave Collins
335736e59f Add new func NetAddressIPPort.
This function is a convenience method to create a new NetAddress
from a net.IP and uint16 port as opposed to a net.Addr which must be of
type *net.TCPAddr.  This allows callers to support connection types that
don't provide access to a concrete *net.TCPAddr implementation.
2013-08-07 13:05:25 -05:00
Dave Collins
8574846e87 Move btcd to root directory.
This allows easier go get paths.
2013-08-07 12:47:51 -05:00
Dave Collins
c9502f0932 Add option to disable listen for incoming conns.
This commit provide support for a new nolisten option which disables
listening for incoming connections.  It also disable listening when the
--connect option is used.
2013-08-07 12:37:46 -05:00
Dave Collins
58055a0b5c Reorder some of the config options. 2013-08-07 12:29:45 -05:00
Dave Collins
3195020fee Improve sample-btcd.conf.
This commit improves the sample-btcd.conf file by including some
explanatory text and adding a few more available options.
2013-08-07 12:12:46 -05:00
Dave Collins
a9662d3169 Disable RPC server if no user/pass is provided.
This commit disables the RPC server by default if no RPC username of
password is specified (either via the command line or through the config
file).

Closes #2.
2013-08-07 11:02:31 -05:00
Dave Collins
ca8496e66d Make IPv4 and IPv6 listen on different sockets.
This commit implements support for listening on multiple sockets and
changes the default listen code to use one socket per address family (IPv4
and IPv6).

In addition, it changes the default listen binding for the RPC server to
localhost so only local clients can connect to it.

There need to be several options added to allow customization of these
settings and those will be in future commits.

Fixes #3.
2013-08-07 10:39:23 -05:00
Dave Collins
c526c3af59 Use external paths for imports.
This commit modifies the import paths to externally accessible paths.
Fixes #1.
2013-08-07 00:33:46 -05:00
Dave Collins
3f54e4199f Initial import. 2013-08-06 19:17:05 -05:00
Owain G. Ainsworth
abfd6b44af More documentation commentary. 2013-08-06 18:22:16 +01:00
Owain G. Ainsworth
840708a3e7 Fix up some format strings to appease go vet.
Extra argument present when no format directive for it (and not needed,
either).
2013-08-06 18:00:47 +01:00
Owain G. Ainsworth
17d37e3b06 Fix up some ErrorF strings in tests.
One was missing a format directive. the others changed for consistency.
Appeases go vet.
2013-08-06 18:00:05 +01:00
Dave Collins
519e183151 Update the insertfail test for the latest changes. 2013-08-06 11:48:23 -05:00
Dave Collins
c59a86c467 Initial commit. 2013-08-06 11:32:43 -05:00
Dave Collins
b4b7204a97 Remove BtcDecodeTxLoc since it has been replaced.
BtcDecodeTxLoc is no longer needed since it has been replaced by
DeserializeTxLoc.
2013-08-05 19:18:45 -05:00
Dave Collins
10a62a37a3 Update for latest btcutil, btcscript, and btcwire.
This commit updates the calls into btcutil, btcscript, and btcwire for the
latest API changes which remove the need for the protocol version for
serialization and deserialization of blocks and transactions.
2013-08-05 18:53:50 -05:00
Dave Collins
8062889d04 Update for latest btcutil and btcwire changes.
This commit updates the calls into btcutil and btcwire for the latest API
changes which remove the need for the protocol version for serialization
and deserialization of blocks and transactions.
2013-08-05 18:28:17 -05:00
Dave Collins
26fb20e4ed Remove need for protocol version.
This commit modifies the code to no longer require a protocol version.  It
does this by making use of the new Serialize function in btcwire.

Unfortuantely this does entail a public API change which I generally don't
like to do, but eliminating the usage of the protocol version throughout
the codebase was important enough to warrant the change.
2013-08-05 18:11:34 -05:00