mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 04:05:49 +00:00
Clean up code comments.
This commit is contained in:
@@ -2,22 +2,22 @@ const xrpl = require("xrpl")
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
||||||
// Create client and connect to network.
|
// Create a client and connect to the network.
|
||||||
const client = new xrpl.Client("wss://xrplcluster.com/")
|
const client = new xrpl.Client("wss://xrplcluster.com/")
|
||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
// Query ledger data.
|
// Specify a ledger to query for info.
|
||||||
let ledger = await client.request({
|
let ledger = await client.request({
|
||||||
"command": "ledger_data",
|
"command": "ledger_data",
|
||||||
"ledger_index": 500000,
|
"ledger_index": 500000,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Create function to loop through API calls.
|
// Create a function to run on each API call.
|
||||||
function code(){
|
function code(){
|
||||||
console.log(ledger["result"])
|
console.log(ledger["result"])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run code at least once before checking for markers.
|
// Execute function at least once before checking for markers.
|
||||||
do {
|
do {
|
||||||
code()
|
code()
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ async function main() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specify the same ledger and add the marker to continue querying.
|
||||||
const ledger_marker = await client.request({
|
const ledger_marker = await client.request({
|
||||||
"command": "ledger_data",
|
"command": "ledger_data",
|
||||||
"ledger_index": 500000,
|
"ledger_index": 500000,
|
||||||
@@ -34,6 +35,7 @@ async function main() {
|
|||||||
|
|
||||||
} while (true)
|
} while (true)
|
||||||
|
|
||||||
|
// Disconnect when done. If you omit this, Node.js won't end the process.
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
from xrpl.clients import JsonRpcClient
|
from xrpl.clients import JsonRpcClient
|
||||||
from xrpl.models.requests import LedgerData
|
from xrpl.models.requests import LedgerData
|
||||||
|
|
||||||
# Create a client to connect to the main network.
|
# Create a client to connect to the network.
|
||||||
client = JsonRpcClient("https://xrplcluster.com/")
|
client = JsonRpcClient("https://xrplcluster.com/")
|
||||||
|
|
||||||
# Specify ledger to query and request data.
|
# Specify a ledger to query for info.
|
||||||
ledger = LedgerData(ledger_index=500000)
|
ledger = LedgerData(ledger_index=500000)
|
||||||
ledger_data = client.request(ledger).result
|
ledger_data = client.request(ledger).result
|
||||||
|
|
||||||
# Code to run on each call.
|
# Create a function to run on each API call.
|
||||||
def code():
|
def code():
|
||||||
print(ledger_data)
|
print(ledger_data)
|
||||||
|
|
||||||
#Execute code at least once before checking for markers.
|
# Execute function at least once before checking for markers.
|
||||||
while True:
|
while True:
|
||||||
code()
|
code()
|
||||||
if "marker" not in ledger_data:
|
if "marker" not in ledger_data:
|
||||||
break
|
break
|
||||||
|
|
||||||
# Specify ledger and marker to continue querying.
|
# Specify the same ledger and add the marker to continue querying.
|
||||||
ledger_marker = LedgerData(ledger_index=500000, marker=ledger_data["marker"])
|
ledger_marker = LedgerData(ledger_index=500000, marker=ledger_data["marker"])
|
||||||
ledger_data = client.request(ledger_marker).result
|
ledger_data = client.request(ledger_marker).result
|
||||||
Reference in New Issue
Block a user