Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Last active September 20, 2017 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simform-solutions/dbe29536a75345cee6292f491222edf6 to your computer and use it in GitHub Desktop.
Save simform-solutions/dbe29536a75345cee6292f491222edf6 to your computer and use it in GitHub Desktop.
# Takes the f_index and/or the l_index and saves them in the account file
# "f_index" is the index of the first address with balance and "l_index" is the index of the last address with balance
def write_fal_balance(f_index=0, l_index=0):
if f_index > 0 and l_index > 0:
fal_balance[0]["f_index"] = f_index
fal_balance[0]["l_index"] = l_index
elif f_index > 0:
fal_balance[0]["f_index"] = f_index
elif l_index > 0:
fal_balance[0]["l_index"] = l_index
else:
return
with open(file_name, 'w') as account_data:
json.dump(raw_account_data, account_data)
# Writes data of an transaction to the account file
def write_transfers_data(
transaction_hash,
is_confirmed,
timestamp,
tag,
address,
message,
value,
bundle
):
for p in transfers_data:
if p["transaction_hash"] == transaction_hash:
if is_confirmed == p["is_confirmed"]:
return
else:
p['is_confirmed'] = is_confirmed
with open(file_name, 'w') as account_data:
json.dump(raw_account_data, account_data)
return
raw_account_data["account_data"][0]["transfers_data"].append({
'transaction_hash': transaction_hash,
'is_confirmed': is_confirmed,
'timestamp': timestamp,
'tag': tag,
'address': address,
'message': message,
'value': value,
'bundle': bundle
})
with open(file_name, 'w') as account_data:
json.dump(raw_account_data, account_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment