Skip to content
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

Fix account state decode error #40

Merged
merged 2 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,11 @@ def acct_details(acct):
try:
acct_info = get_acct_info(acct_state_raw)
except:
# FIXME: temp patch to missing blob issue
acct_info = (acct, '(unknown - missing blob error)', '(unknown - missing blob error)',
'(unknown - missing blob error)', '(unknown - missing blob error)')
# if account_state_with_proof.blob does not exist
acct_info = (acct, 0, '-', 0, 0, None)
app.logger.info('acct_info: {}'.format(acct_info))

tx_tbl = ''.join(gen_tx_table_row(tx) for tx in
tx_tbl = ''.join(gen_tx_table_row(tx) for tx in
session.query(Transaction).filter(
(Transaction.src == acct) | (Transaction.dest == acct)
).order_by(desc(Transaction.version)).limit(100).offset(page*100)
Expand Down
15 changes: 8 additions & 7 deletions rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,20 @@ def get_acct_raw(acct):

def get_acct_info(state):
try:
#struct inferred from: https://github.com/libra/libra/blob/master/types/src/account_config.rs#L129
acct_state = struct.unpack_from('32sQQQQ', state.account_state_with_proof.blob.blob,
len(state.account_state_with_proof.blob.blob) - struct.calcsize('32sQQQQ'))
#struct inferred from: https://github.com/libra/libra/blob/master/types/src/account_config.rs#L147-L152
acct_state = struct.unpack_from('=32sQ?QQQ', state.account_state_with_proof.blob.blob,
len(state.account_state_with_proof.blob.blob) - struct.calcsize('=32sQ?QQQ'))

account = bytes.hex(acct_state[0])
balance = acct_state[1] / 1000000
recv_events = acct_state[2]
sent_events = acct_state[3]
sq_num = acct_state[4]
delegated_withdrawal_cap = acct_state[2]
recv_events = acct_state[3]
sent_events = acct_state[4]
sq_num = acct_state[5]
except:
logger.exception('exception in get_acct_info')

return account, balance, sq_num, sent_events, recv_events
return account, balance, sq_num, sent_events, recv_events, delegated_withdrawal_cap


def get_raw_tx_lst(version, limit):
Expand Down