Skip to content

Commit

Permalink
Fixed token balance in the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
xoriole committed Sep 25, 2019
1 parent cdba1d6 commit 6a16220
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 3 additions & 6 deletions TriblerGUI/tribler_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,9 @@ def received_trustchain_statistics(self, statistics):
self.trust_page.received_trustchain_statistics(statistics)

statistics = statistics["statistics"]
if 'latest_block' in statistics:
balance = (statistics["latest_block"]["transaction"]["total_up"] -
statistics["latest_block"]["transaction"]["total_down"])
self.set_token_balance(balance)
else:
self.token_balance_label.setText("0 MB")
balance = (statistics.get("total_up", 0) -
statistics.get("total_down", 0))
self.set_token_balance(balance)

# If trust page is currently visible, then load the graph as well
if self.stackedWidget.currentIndex() == PAGE_TRUST:
Expand Down
10 changes: 4 additions & 6 deletions TriblerGUI/widgets/trustpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ def load_blocks(self):
self.received_trustchain_blocks)

def received_trustchain_statistics(self, statistics):
if not statistics:
if not statistics or "statistics" not in statistics:
return
statistics = statistics["statistics"]
self.public_key = statistics["id"]
total_up = 0
total_down = 0
if 'latest_block' in statistics:
total_up = statistics["latest_block"]["transaction"]["total_up"]
total_down = statistics["latest_block"]["transaction"]["total_down"]

total_up = statistics.get("total_up", 0)
total_down = statistics.get("total_down", 0)

self.window().trust_contribution_amount_label.setText("%s MBytes" % (total_up / self.byte_scale))
self.window().trust_consumption_amount_label.setText("%s MBytes" % (total_down / self.byte_scale))
Expand Down

0 comments on commit 6a16220

Please sign in to comment.