Skip to content
Snippets Groups Projects
Commit cf7dcc8b authored by Vincent Texier's avatar Vincent Texier
Browse files

Fix inaccurate actual growth in informations_tab

parent 2851920f
No related branches found
No related tags found
No related merge requests found
......@@ -148,10 +148,10 @@ class Community(object):
else:
return 1
def get_ud_block(self):
ud = self.request(bma.blockchain.UD)
if len(ud['result']['blocks']) > 0:
block_number = ud['result']['blocks'][-1]
def get_ud_block(self, x=0):
blocks = self.request(bma.blockchain.UD)['result']['blocks']
if len(blocks) > 0:
block_number = blocks[len(blocks)-(1+x)]
block = self.request(bma.blockchain.Block,
req_args={'number': block_number})
return block
......
......@@ -40,6 +40,11 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
except Exception as e:
logging.debug('community get_ud_block error : ' + str(e))
return False
try:
block_t_minus_1 = self.community.get_ud_block(1)
except Exception as e:
logging.debug('community get_ud_block error : ' + str(e))
return False
# set infos in label
self.label_general.setText(
......@@ -64,7 +69,7 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
self.get_referential_value(block['monetaryMass'] / block['membersCount']),
'Monetary Mass per member M(t)/N(t) in',
self.get_referential_name(),
block['dividend'] / (block['monetaryMass'] / block['membersCount']),
block['dividend'] / (block_t_minus_1['monetaryMass'] / block['membersCount']),
params['dt'] / 86400,
'Actual growth c = UD(t)/[M(t-1)/N(t)]',
datetime.datetime.fromtimestamp(block['medianTime'] + params['dt']).strftime("%d/%m/%Y %I:%M"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment