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

Potential problem with batch JSON-RPC request #85

Open
gagarin55 opened this issue Sep 12, 2017 · 1 comment
Open

Potential problem with batch JSON-RPC request #85

gagarin55 opened this issue Sep 12, 2017 · 1 comment
Labels

Comments

@gagarin55
Copy link
Contributor

You may have an issue with this code

rpc.getTransactionData(address).then((result) => {
            const balance = new BigNumber(result[0].result).toString();
            const gasPrice = result[1].result;
            const nonce = result[2].result;

https://github.com/ethereumproject/TokenMint/blob/master/src/store/transactionActions.js#L11

According to JSON-RPC specification (http://www.jsonrpc.org/specification):

The Response objects being returned from a batch call MAY be returned in any order within the Array

So, there is no order in result.

In emerald-js library I suggest following implementation for batch requests - https://github.com/ethereumproject/emerald-js/blob/master/src/rpc/jsonrpc.js#L73

You can check example in tests - https://github.com/ethereumproject/emerald-js/blob/master/src/rpc/jsonrpc.test.js#L5

The idea is that we map handler for each response by request id.

Much appreciate any comments and suggestions!

@elaineo
Copy link
Contributor

elaineo commented Sep 14, 2017

@gagarin55 I think that is a reasonable solution. The current batch API is used because it matches Epool's mewapi. Gastracker API does not support batch requests right now, I think. It would be good to standardize batch requests.

@elaineo elaineo added the bug label Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants