Add clarifying comments to individual-freeze

This commit is contained in:
Jackson Mills
2021-10-18 10:01:12 -07:00
parent 95a1de45f7
commit 7f89d3734c

View File

@@ -19,20 +19,19 @@ async function main() {
const counterparty_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v' const counterparty_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v'
const frozen_currency = 'USD' const frozen_currency = 'USD'
// Look up current state of trust line // Look up current state of the trust line ----------------------------------
const account_lines = { const account_lines = {
command: 'account_lines', command: 'account_lines',
account: my_address, account: my_address,
peer: counterparty_address, peer: counterparty_address,
} }
console.log('looking up all trust lines from', console.log(`Looking up all trust lines from
counterparty_address, 'to', my_address) ${counterparty_address} to ${my_address}`)
const data = await client.request(account_lines) const data = await client.request(account_lines)
// There is only one trust line per currency code per account, // Find the trust line for our frozen_currency ------------------------------
// so we stop after the first match
let trustline = null let trustline = null
for (let i = 0; i < data.result.lines.length; i++) { for (let i = 0; i < data.result.lines.length; i++) {
if(data.result.lines[i].currency === frozen_currency) { if(data.result.lines[i].currency === frozen_currency) {
@@ -45,12 +44,15 @@ async function main() {
throw `There was no ${frozen_currency} trust line` throw `There was no ${frozen_currency} trust line`
} }
// Check if the trust line is frozen -----------------------------------------
console.log('Trust line frozen from our side?', console.log('Trust line frozen from our side?',
trustline.freeze === true) trustline.freeze === true)
console.log('Trust line frozen from counterparty\'s side?', console.log('Trust line frozen from counterparty\'s side?',
trustline.freeze_peer === true) trustline.freeze_peer === true)
await client.disconnect() await client.disconnect()
// End main()
} }
main().catch(console.error) main().catch(console.error)