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

getmininginfo returns a poorly-formatted JSON response in v2. #225

Closed
NotoriousPyro opened this issue Jan 7, 2018 · 4 comments
Closed

Comments

@NotoriousPyro
Copy link

NotoriousPyro commented Jan 7, 2018

In v1 API, the response was fine but could have been renamed from "mining-info" to "result":
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"getmininginfo","params":[],"id":1}' http://127.0.0.1:8820/rpc

{
        "mining-info" :
        {
                "difficulty" : "9230099912566",
                "height" : "852401",
                "is-mining" : false,
                "rate" : "0"
        }
}

Now, in v2 this is a sub-object of "result" and causes headaches, is obtuse (as we already know we are asking for mining info) when trying to Unmarshal JSON:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"getmininginfo","params":[],"id":1}' http://127.0.0.1:8820/rpc/v2

{
        "id" : 1,
        "jsonrpc" : "2.0",
        "result" :
        {
                "mining-info" :
                {
                        "difficulty" : "9212081176185",
                        "height" : "852403",
                        "is-mining" : false,
                        "rate" : "0"
                }
        }
}

Instead, the following should preferentially be returned:

{
        "id" : 1,
        "jsonrpc" : "2.0",
        "result" :
        {
                "difficulty" : "9212081176185",
                "height" : "852403",
                "is-mining" : false,
                "rate" : "0"
        }
}
jowenshaw pushed a commit to jowenshaw/metaverse that referenced this issue Jan 11, 2018
@jowenshaw
Copy link
Contributor

For compatibility reasons with v1, we won't change this soon. There exists many of the same situations of the response result. It may be re-designed later.

@NotoriousPyro
Copy link
Author

Why is the fact that a v2 request returns this because a v2 response would not be read by languages such as golang if it was written v1 in mind.

@NotoriousPyro
Copy link
Author

The api should differentiate between v1 and v2 and return a different result.

@NotoriousPyro NotoriousPyro changed the title getmininginfo returns a poor JSON-formatted response in v2. getmininginfo returns a poorly-formatted JSON response in v2. Jan 23, 2018
@luozhaohui
Copy link
Contributor

Fixed in APIv3 getmininginfo

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

No branches or pull requests

3 participants