Commit graph

2632 commits

Author SHA1 Message Date
Geert-Johan Riemer
94451d7a9c Changed strings.Contains(?, "{") to bytes.IndexOf(?, '{')>-1 2014-05-05 13:28:48 +02:00
Dave Collins
a4a79387cc Add support for getmininginfo RPC.
Closes #126.
2014-05-04 14:34:25 -05:00
GeertJohan
4fb5272063 Return pointer to TxRawResult and use bytes.IndexByte instead of Strings.Contains 2014-05-04 17:12:32 +02:00
Dave Collins
4202bf2e93 Make TestNet field name consistent.
The commit makes the TestNet field in GetMiningInfoResult consistent with
InfoResult.
2014-05-03 23:38:47 -05:00
Dave Collins
4178c36dc3 Populate connections field in getinfo RPC.
The JSON object returned from the getinfo RPC contains a connection count
field that was not being populated.
2014-05-03 14:07:08 -05:00
Dave Collins
d443b48994 Improve InfoResult.
This commit modifies InfoResult to remove all of the omitempty tags since
the fields should be present in the marshalled JSON regardless of them
being zero values or not.
2014-05-03 14:05:37 -05:00
Dave Collins
d0a2506a96 Improve GetMiningInfoResult.
This commit modifies the types of the GetMiningInfoResult to better match
their underlying types.  While the information was all available and
accurate, it's nicer to treat numeric values as proper types instead of
all float64s.

Also, a new networkhashps field has been added for compatibility with the
reference implementation.
2014-05-03 12:28:04 -05:00
Dave Collins
0a7543516c Update block manager chainstate for all sources.
This commit updates the block manager's local chain state when a block
processed by submitting it directly to the block manager as opposed to
only when it comes from the network.

Also, it modifies the submitblock RPC to use the concurrent safe block
manager process block instead of the unsafe btcchain version.

The combination of these two fixes ensure the internal block manager chain
state is properly synced with the actual btcchain state regardless of how
blocks are added.
2014-05-02 23:02:10 -05:00
Dave Collins
92ca0e92c0 Implement getwork RPC.
This commit adds full support for the getwork RPC which can be used to
support external mining through applications such as cgminer.

Closes #125.
2014-05-01 10:52:28 -05:00
Dave Collins
a38f93bf06 use fastsha256 in rpcwebsocket.go.
While this is not performance critical code, there is no need to import
another package into the final binary.
2014-05-01 10:36:41 -05:00
David Hill
76e8fa9766 Reduce OP_RETURN standard relay bytes to 40.
This matches commit 8175c790eb12f0b0ca3197895a6d1d479b340b67 of
the reference software.
2014-05-01 09:42:15 -04:00
David Hill
d72da506c5 Some UPNP devices require the protocol to be uppercase.
This matches what miniupnpc sends.
2014-04-26 14:46:17 -04:00
Josh Rickmar
bba0a0482d Include P2PK outputs for rescanned P2PKH addrs.
This change fixes rescan to include transactions that pay to the
pubkey for a rescanned pubkey hash address.  This behavior was lost
when the rescan was optimized for specific types of the
btcutil.Address interface.

ok @davecgh
2014-04-25 10:33:58 -05:00
Dave Collins
27082ace79 Correct error handling on createMarshalledReply.
This commit correctly sets the error in the marhsalled reply if it is
already a *btcjson.Error.  Previously it would only set the error if it
was not of that type which led to some RPC results showing no error when
they actually had one.
2014-04-25 02:51:57 -05:00
Josh Rickmar
3fd5904859 Always return unparsableCmds when possible.
This change overrides the cmd return value of custom registered
methods to always return an unparsableCmd if the marshaling as a
JSON-RPC request succeeded, but the request was an invalid structure
for the custom method.
2014-04-25 01:04:24 -05:00
Dave Collins
bdaa5f7f8d Set RPC content type to applicaton/json.
Closes #121.
2014-04-24 23:20:13 -05:00
David Hill
765dbb443d Fix a bug in fetching the XML URL.
In Discover, the reponse was lowercased for comparison.  However,
this caused a 404 - Not found when fetching the url provided by
the location header if the url contained uppercase.

ok @owainga
2014-04-23 19:10:53 -04:00
Dave Collins
4595c9d90d Add listreceivedbyaccount concrete result.
ok @jcvernaleo.
2014-04-23 15:47:25 -05:00
Owain G. Ainsworth
4d44eeb877 Move to protecting all peer stats by the same mutex.
In practise the races caused by not protecting these quite simply didn't
matter, they couldn't actually cause any damage whatsoever. However, I
am sick of hearing about these essentially false positivies whenever
someone runs the race detector (yes, i know that race detector has no
false positives but this was effectively harmess).

verified to shut the detector up by dhill.
2014-04-23 17:38:14 +01:00
Owain G. Ainsworth
88ea84cf12 Addrman: only shuffle as much as we need.
If we switch the knuth shuffle to the version that swaps the element
with an element between it and the end of the array, then once we have
gotten to the amount of elements we need they won't change later in the
algorithm. Terminating here means that we only do 23% of the length of
the array worth of random swaps at most.
2014-04-23 17:38:13 +01:00
Owain G. Ainsworth
ec8d0e582c Attempt to create less garbage for getaddr calls.
We make ka.na immutable in the address manager. Whenever we would update
the structure we replace it with a new copy. This beats making a copy of
all addresses once per getaddr command (max is just over 23000 we would
be copying, compared to at most 2000 copies on a new getaddr that has
all addresses we know with newer dates).
2014-04-23 17:38:13 +01:00
David Hill
08377c21e2 Lower maxKnownInventory from 20000 to 1000.
ok @davecgh
2014-04-23 07:48:52 -04:00
David Hill
8a322e4792 Bypass rate limiter for sendrawtransaction.
ok @davecgh
2014-04-23 07:45:56 -04:00
David Hill
75bb52d715 In handleGetDataMsg, fix two unknown inv type bugs.
On unknown inventory types, handleGetDataMsg would loop forever.
After fixing that, if a getdata request only had unknown inventory
types, it would block forever.

ok @davecgh
2014-04-21 14:52:02 -04:00
Dave Collins
2cc89bbf5b Remove function name from ShaHash error message.
This makes golint happy.
2014-04-21 10:53:22 -05:00
Dave Collins
8857485fa8 Remove note that is no longer true.
The code was updated to automatically handle the transaction count in the
block header without having the additional field some time ago.  This
comment was outdated.
2014-04-20 23:24:56 -05:00
Josh Rickmar
f88db561f1 Make rescan faster by avoiding hash copies.
Copying the RIPEMD160 after SHA256 hash result into a new stack array
to be used as a map lookup key can be quite expensive, and this should
be avoided if possible on intensive tasks such as rescans.  This
change takes advantage of the new Hash160 methods of the
AddressPubKeyHash and AddressScriptHash types to use the address's
underlying hash array directly, rather than creating a copy from the
ScriptAddress result.

Unfortunately, for AddressPubKey, ScriptAddress may return either a
byte slice of len 33 or 65 depending on whether the pubkey is
compressed or not, so no such straightforward optimization is
possible.

As a result of this change, I have seen rescans perform roughly 3.5x
faster than before.
2014-04-20 21:16:59 -05:00
Dave Collins
1e75ccc9b9 Update for recent btcwire AddUserAgent addition. 2014-04-20 17:46:32 -05:00
Dave Collins
d848bc453b Improve comments on new AddUserAgent function. 2014-04-20 17:44:46 -05:00
Javed Khan
620cbdeb8e Implemented BIP 0014 format for user agent
the new function AddUserAgent adds the user agent to the stack
and formats it as per BIP 0014
e.g: "/btcwire:0.1.4/myclient:1.2.3(optional; comments)/"

the validation on UserAgent has been moved to a new function
validateUserAgent
2014-04-21 02:36:13 +05:30
David Hill
88093cb838 Use NewMsgInvSizeHint since we know the size.
ok @davecgh
2014-04-19 20:05:35 -04:00
Dave Collins
a9293bd32e Add godoc reference badge to README.md. 2014-04-19 15:46:03 -05:00
Dave Collins
44e34926a7 Remove test coverage report refs from README.md.
This is no longer needed since the repository is now configured to work
with coveralls.io for test coverage reporting.

Closes #17
2014-04-19 14:49:42 -05:00
Dave Collins
755944738a Instruct TravisCI to install coverage report tool. 2014-04-19 14:41:52 -05:00
Dave Collins
6b82da13b4 Setup TravisCI to report cov stats to coveralls.io.
Also add a coveralls.io test coverage badge to the README.
2014-04-19 14:36:16 -05:00
Javed Khan
9130de2de2 add tmp wire file to .gitignore 2014-04-19 15:53:03 +05:30
Dave Collins
1349f96d8e Correct GetRawMempoolResult types.
The StartingPriority and CurrentPriority fields of the GetRawMempoolResult
are float64s instead of ints.
2014-04-18 12:37:23 -05:00
Dave Collins
ce48290169 Rename new transaction register/notifications.
This commit renames the notifyallnewtxs RPC to notifynewtransactions to be
more consistent with the standard RPC names and to more accurately
reflect its intention which is to register for new transactions as they
are accepted to the memory pool.  In addition, the notifications produced
have been renamed to txaccepted and txacceptedverbose depending on whether
or not the verbose flag was set when the client registered to receive the
notifications via notifynewtransactions.

This closes conformal/btcd#98.
2014-04-15 13:08:26 -05:00
Dave Collins
a4673597bd Update for notifyallnewtxs rename.
The websocket extension command to register for notifications when a new
transaction has been accepted to the memory pool and the resulting
notifications have been renamed.  This commit catches up to the change.
2014-04-15 12:22:52 -05:00
Dale Rahn
ae25e28d7e Update test to new API. 2014-04-15 10:47:29 -04:00
Dale Rahn
dd41d71a31 If data for tx is not present, return error. 2014-04-15 10:47:25 -04:00
Dale Rahn
4d63076526 All external entry points into the database must be locked. 2014-04-15 10:17:37 -04:00
Dave Collins
f389d39c43 Update tests for notifynewtxs -> notifyreceived. 2014-04-14 22:45:56 -05:00
Dave Collins
0b4401ddb6 Rename NotifyNewTXsCmd to NotifyReceivedCmd.
This commit renamed the notifynewtxs RPC to notifyreceived since it more
accurately reflects its intention which is to register addresses to be
notified about when they receive funds.

This is work towards conformal/btcd#98.

ok @jrick.
2014-04-14 22:18:54 -05:00
Dave Collins
05a7979292 Update for notifynewtxs to notifyreceived rename.
The websocket extension command to register for notifications when an
address receives funds has been renamed.  This commit catches up to the
change.
2014-04-14 19:11:08 -05:00
Dave Collins
de51409185 Add debug print for chain verify.
Since a chain verification can take a long time depending on the
parameters, this commit adds a debug print to the RPC server at the info
level for how many blocks are being verified and at what level.

The logic was also slightly modified so the number of blocks being checked
can easily be calculated and shown.
2014-04-14 10:29:51 -05:00
Josh Rickmar
79beb22aef Export CoinbaseMaturity as a const.
The unexported variable is still kept so that tests may modify it.

ok @davecgh
2014-04-14 08:45:43 -05:00
David Hill
3937c1a67c This RPCS debug statement should be a trace. 2014-04-13 15:50:28 -04:00
David Hill
997d98bddf add a few missing and fix misspelled commands. 2014-04-12 10:47:07 -04:00
David Hill
ea7947f74e Add support for decodescript concrete result. 2014-04-12 10:41:32 -04:00