-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add code sample showing how to walk an owner directory #3381
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
base: master
Are you sure you want to change the base?
Conversation
| const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233') | ||
| await client.connect() | ||
|
|
||
| const owner = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" // Testnet faucet |
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.
constant should be upper case, same with 2 constants below
| console.log("Page #\t\t\tEntry count") | ||
| console.log("-----------------------------------") | ||
| while (true) { | ||
| // console.log(`Getting directory page ${sub_index}`) |
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.
I would prefer we keeping the logs (instead of commenting out), so that users are aware of what's going on. Also, for log before an async call, probably consider adding ... so users know to wait for the call to finish
| ledger_index = resp.result.ledger_index | ||
| } | ||
|
|
||
| console.log(`${sub_index}\t\t\t${resp.result.node.Indexes.length}`) |
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.
nit: I'd prefer this have a sentence format for clarity or a descriptor of some kind, similar to the commented out log below
|
|
||
| # The entries are stored in the 'Indexes' field of the 'DirectoryNode' | ||
| entry_count = len(response.result["node"]["Indexes"]) | ||
| print(f"{sub_index}\t\t\t{entry_count}") |
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.
same here as other comment
achowdhry-ripple
left a comment
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.
aside from a few nits looks good!
This is not the most useful code sample but it does provide a useful sample of using the
ledger_entrycommand to iterate over an account's owner directory and can be used to show owner directory fragmentation where it occurs.