add blockchain.get_name method, update kivy gui
This commit is contained in:
@@ -81,6 +81,7 @@ class ElectrumWindow(App):
|
||||
server_host = StringProperty('')
|
||||
server_port = StringProperty('')
|
||||
blockchain_name = StringProperty('')
|
||||
blockchain_checkpoint = NumericProperty(0)
|
||||
|
||||
auto_connect = BooleanProperty(False)
|
||||
def on_auto_connect(self, instance, x):
|
||||
@@ -103,12 +104,13 @@ class ElectrumWindow(App):
|
||||
|
||||
def choose_blockchain_dialog(self, dt):
|
||||
from uix.dialogs.choice_dialog import ChoiceDialog
|
||||
chains = self.network.get_blockchains()
|
||||
def cb(name):
|
||||
for index, b in self.network.blockchains.items():
|
||||
if name == self.network.get_blockchain_name(b):
|
||||
self.network.follow_chain(index)
|
||||
#self.block
|
||||
names = [self.network.get_blockchain_name(b) for b in self.network.blockchains.values()]
|
||||
names = [self.network.blockchains[b].get_name() for b in chains]
|
||||
if len(names) >1:
|
||||
ChoiceDialog(_('Choose your chain'), names, '', cb).open()
|
||||
|
||||
@@ -590,23 +592,10 @@ class ElectrumWindow(App):
|
||||
self.network.register_callback(self.on_network, interests)
|
||||
self.tabs = self.root.ids['tabs']
|
||||
|
||||
def blockchain_status(self):
|
||||
if len(self.network.blockchains)>1:
|
||||
msg = self.network.get_blockchain_name(self.network.blockchain())
|
||||
else:
|
||||
msg = _('Genesis')
|
||||
return msg
|
||||
|
||||
def blockchain_info(self):
|
||||
if len(self.network.blockchains)>1:
|
||||
checkpoint = self.network.get_checkpoint()
|
||||
msg = _('Fork detected at block %d')%checkpoint
|
||||
else:
|
||||
msg = _('The blockchain appears to be one')
|
||||
return msg
|
||||
|
||||
def on_network(self, event, *args):
|
||||
self.blockchain_name = self.blockchain_status()
|
||||
chain = self.network.blockchain()
|
||||
self.blockchain_checkpoint = chain.get_checkpoint()
|
||||
self.blockchain_name = chain.get_name()
|
||||
if self.network.interface:
|
||||
self.server_host = self.network.interface.host
|
||||
if event == 'updated':
|
||||
|
||||
@@ -46,9 +46,8 @@ Popup:
|
||||
|
||||
CardSeparator
|
||||
SettingsItem:
|
||||
title: app.blockchain_info()
|
||||
title: _('Fork detected at block %d')%app.blockchain_checkpoint if app.blockchain_checkpoint else _('No fork detected')
|
||||
fork_description: (_('You are following branch') if app.auto_connect else _("Your server is on branch")) + ' ' + app.blockchain_name
|
||||
description: _('Everything is fine') if self.disabled else self.fork_description
|
||||
description: self.fork_description if app.blockchain_checkpoint else ''
|
||||
action: app.choose_blockchain_dialog
|
||||
disabled: len(app.network.blockchains) == 1
|
||||
|
||||
disabled: app.blockchain_checkpoint == 0
|
||||
|
||||
@@ -95,14 +95,13 @@ class NodesListWidget(QTreeWidget):
|
||||
def update(self, network):
|
||||
self.clear()
|
||||
self.addChild = self.addTopLevelItem
|
||||
checkpoint = network.get_checkpoint()
|
||||
chains = network.get_blockchains()
|
||||
n_chains = len(chains)
|
||||
for k, items in chains.items():
|
||||
b = network.blockchains[k]
|
||||
name = network.get_blockchain_name(b)
|
||||
name = b.get_name()
|
||||
if n_chains >1:
|
||||
x = QTreeWidgetItem([name + '@%d'%checkpoint, '%d'%b.height()])
|
||||
x = QTreeWidgetItem([name + '@%d'%b.get_checkpoint(), '%d'%b.height()])
|
||||
x.setData(0, Qt.UserRole, 1)
|
||||
x.setData(1, Qt.UserRole, b.checkpoint)
|
||||
else:
|
||||
@@ -361,8 +360,8 @@ class NetworkChoiceLayout(object):
|
||||
chains = self.network.get_blockchains()
|
||||
if len(chains)>1:
|
||||
chain = self.network.blockchain()
|
||||
checkpoint = self.network.get_checkpoint()
|
||||
name = self.network.get_blockchain_name(self.network.blockchain())
|
||||
checkpoint = chain.get_checkpoint()
|
||||
name = chain.get_name()
|
||||
msg = _('Chain split detected at block %d')%checkpoint + '\n'
|
||||
msg += (_('You are following branch') if auto_connect else _('Your server is on branch'))+ ' ' + name
|
||||
msg += ' (%d %s)' % (chain.get_branch_size(), _('blocks'))
|
||||
|
||||
Reference in New Issue
Block a user