Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcserver: Convert to make use of new btcjson. #314

Closed
wants to merge 0 commits into from

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Feb 24, 2015

This pull request converts the RPC server over to use the new features available in the latest version of btcjson and improve a few things along the way. This following summarizes the changes:

  • All btcjson imports have been updated to the latest package version
  • The help has been significantly improved
    • Invoking help with no command specified now provides an alphabetized list of all supported commands along with one-line usage
    • The help for each command is automatically generated and provides much more explicit information such as the type of each parameter, whether or not it's optional or required, etc
    • The websocket-specific commands are now provided when accessing the help when connected via websockets
    • Help has been added for all websocket-specific commands and is only accessible when connected via websockets
  • The error returns and handling of both the standard and websocket handlers has been made consistent
  • All RPC errors have been converted to the new RPCError type
  • Various variables have been renamed for consistency
  • Several RPC errors have been improved
  • The commands that are marked as unimplemented have been moved into the
    separate map where they belong
  • Several comments have been improved
  • An unnecessary check has been removed from the createrawtransaction handler
  • The command parsing has been restructured a bit to pave the way for JSON-RPC 2.0 batching support
  • The order of several functions has been udpated to more closely match the ordering used by the rest of the base base such that functions are typically defined before they are used and near their call site
  • When invalid HTTP Basic Access Authentication details are provided to the websocket endpoint, return a WWW-Authenticate header just like the non-websocket endpoint
  • When a connection to the websocket endpoint fails to properly upgrade, return a 400 Bad Request HTTP error status code

@jrick
Copy link
Member

jrick commented Feb 24, 2015

Could we generate the help strings in a 'go generate' step, instead of at init each time?

@davecgh
Copy link
Member Author

davecgh commented Feb 24, 2015

They aren't generated at init. They're only generated when requested, and then cached.

EDIT: That said, using a go generate step is not a bad idea for a future optimization.

@jrick
Copy link
Member

jrick commented Feb 24, 2015

Well, the map is still created at init. :)

And left in memory for the entire duration of the program. We should at least nil it.

rawTx, err := createTxRawResult(net, txShaStr, mtx, nil,
0, nil)
if err != nil {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just shuffled code, but shouldn't this error be logged?

@davecgh
Copy link
Member Author

davecgh commented Feb 24, 2015

The map is referenced at run-time in order to dynamically generate the help as needed. We can't nil it. As mentioned before creating code to use go generate is not a bad optimization, but it won't make it into this pr.

@davecgh
Copy link
Member Author

davecgh commented Feb 25, 2015

All review items have been addressed.

@davecgh
Copy link
Member Author

davecgh commented Feb 25, 2015

Rebased and updated to latest master.

@davecgh davecgh closed this Feb 25, 2015
@davecgh davecgh deleted the btcjsonv2 branch February 25, 2015 06:57
@davecgh
Copy link
Member Author

davecgh commented Feb 25, 2015

This was merged, but not marked properly by github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants