Skip to content

Conversation

@mDuo13
Copy link
Collaborator

@mDuo13 mDuo13 commented Nov 15, 2025

This is not the most useful code sample but it does provide a useful sample of using the ledger_entry command to iterate over an account's owner directory and can be used to show owner directory fragmentation where it occurs.

@mDuo13 mDuo13 added python Pull requests that update Python code javascript Pull requests that update Javascript code labels Nov 15, 2025
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
await client.connect()

const owner = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" // Testnet faucet
Copy link
Contributor

@pdp2121 pdp2121 Nov 26, 2025

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}`)
Copy link
Contributor

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}`)

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}")

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

Copy link

@achowdhry-ripple achowdhry-ripple left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants