-
Notifications
You must be signed in to change notification settings - Fork 312
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
updates balancesActions.js to work with 2.9.0 nodes #1543
Conversation
app/actions/balancesActions.js
Outdated
return accum | ||
} | ||
|
||
if (accum[accum.length - 1].length < 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 4? a good variable name would help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look guys... so 4 represents the "maximum chunk size" I will go ahead and make this a constant
} | ||
|
||
if (accum[accum.length - 1].length < 4) { | ||
accum[accum.length - 1].push(currVal.scriptHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this push does not have an array surrounding currVal.scripthash but the rest do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats because its pushing into an existing arr... Think of the structure like this:
[ [hash1, hash2, hash3, hash4], [hash5, hash6, hash7, hash8] ... ]
app/actions/balancesActions.js
Outdated
) | ||
const results = await Promise.all(promiseMap) | ||
const resultObject = results.reduce((result, currentObject) => { | ||
Object.keys(currentObject).forEach(key => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just use return Object.assign({}, currentObject)
app/actions/balancesActions.js
Outdated
|
||
const parsedTokenBalances = Object.keys(tokenBalances) | ||
const parsedTokenBalances = Object.keys(resultObject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also return the format you need from the reduce method instead of calling object.keys on the data after calling reduce. its not a big deal though unless the data is large and we want to be efficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Because nodes running 2.9.0 have been capped at 10 GAS limit for invoke scripts we can no longer request balance info in one RPC call... This PR chunks out the request so that balance data for no more than 4 tokens is ever made at once.
Fixes #1541
Related update: neo-project/neo#397