show only active chains
This commit is contained in:
parent
a39e270bd3
commit
814792eee1
|
@ -94,31 +94,28 @@ class NodesListWidget(QTreeWidget):
|
||||||
|
|
||||||
def update(self, network):
|
def update(self, network):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
self.addChild = self.addTopLevelItem
|
||||||
checkpoint = network.get_checkpoint()
|
checkpoint = network.get_checkpoint()
|
||||||
n_chains = len(network.blockchains)
|
chains = network.get_blockchains()
|
||||||
if n_chains > 1:
|
n_chains = len(chains)
|
||||||
for b in network.blockchains.values():
|
for k, items in chains.items():
|
||||||
items = filter(lambda i: i.blockchain==b, network.interfaces.values())
|
b = network.blockchains[k]
|
||||||
if items:
|
name = network.get_blockchain_name(b)
|
||||||
name = network.get_blockchain_name(b)
|
if n_chains >1:
|
||||||
x = QTreeWidgetItem([name + '@%d'%checkpoint, '%d'%b.height()])
|
x = QTreeWidgetItem([name + '@%d'%checkpoint, '%d'%b.height()])
|
||||||
x.setData(0, Qt.UserRole, 1)
|
x.setData(0, Qt.UserRole, 1)
|
||||||
x.setData(1, Qt.UserRole, b.checkpoint)
|
x.setData(1, Qt.UserRole, b.checkpoint)
|
||||||
for i in items:
|
else:
|
||||||
star = ' *' if i == network.interface else ''
|
x = self
|
||||||
item = QTreeWidgetItem([i.host + star, '%d'%i.tip])
|
for i in items:
|
||||||
item.setData(0, Qt.UserRole, 0)
|
|
||||||
item.setData(1, Qt.UserRole, i.server)
|
|
||||||
x.addChild(item)
|
|
||||||
self.addTopLevelItem(x)
|
|
||||||
x.setExpanded(True)
|
|
||||||
else:
|
|
||||||
for i in network.interfaces.values():
|
|
||||||
star = ' *' if i == network.interface else ''
|
star = ' *' if i == network.interface else ''
|
||||||
item = QTreeWidgetItem([i.host + star, '%d'%i.tip])
|
item = QTreeWidgetItem([i.host + star, '%d'%i.tip])
|
||||||
item.setData(0, Qt.UserRole, 0)
|
item.setData(0, Qt.UserRole, 0)
|
||||||
item.setData(1, Qt.UserRole, i.server)
|
item.setData(1, Qt.UserRole, i.server)
|
||||||
self.addTopLevelItem(item)
|
x.addChild(item)
|
||||||
|
if n_chains>1:
|
||||||
|
self.addTopLevelItem(x)
|
||||||
|
x.setExpanded(True)
|
||||||
|
|
||||||
h = self.header()
|
h = self.header()
|
||||||
h.setStretchLastSection(False)
|
h.setStretchLastSection(False)
|
||||||
|
@ -361,7 +358,8 @@ class NetworkChoiceLayout(object):
|
||||||
n = len(self.network.get_interfaces())
|
n = len(self.network.get_interfaces())
|
||||||
status = _("Connected to %d nodes.")%n if n else _("Not connected")
|
status = _("Connected to %d nodes.")%n if n else _("Not connected")
|
||||||
self.status_label.setText(status)
|
self.status_label.setText(status)
|
||||||
if len(self.network.blockchains)>1:
|
chains = self.network.get_blockchains()
|
||||||
|
if len(chains)>1:
|
||||||
chain = self.network.blockchain()
|
chain = self.network.blockchain()
|
||||||
checkpoint = self.network.get_checkpoint()
|
checkpoint = self.network.get_checkpoint()
|
||||||
name = self.network.get_blockchain_name(self.network.blockchain())
|
name = self.network.get_blockchain_name(self.network.blockchain())
|
||||||
|
|
|
@ -1001,9 +1001,16 @@ class Network(util.DaemonThread):
|
||||||
if self.interface and self.interface.blockchain is not None:
|
if self.interface and self.interface.blockchain is not None:
|
||||||
self.blockchain_index = self.interface.blockchain.checkpoint
|
self.blockchain_index = self.interface.blockchain.checkpoint
|
||||||
self.config.set_key('blockchain_index', self.blockchain_index)
|
self.config.set_key('blockchain_index', self.blockchain_index)
|
||||||
|
|
||||||
return self.blockchains[self.blockchain_index]
|
return self.blockchains[self.blockchain_index]
|
||||||
|
|
||||||
|
def get_blockchains(self):
|
||||||
|
out = {}
|
||||||
|
for k, b in self.blockchains.items():
|
||||||
|
r = filter(lambda i: i.blockchain==b, self.interfaces.values())
|
||||||
|
if r:
|
||||||
|
out[k] = r
|
||||||
|
return out
|
||||||
|
|
||||||
def get_blockchain_name(self, blockchain):
|
def get_blockchain_name(self, blockchain):
|
||||||
checkpoint = self.get_checkpoint()
|
checkpoint = self.get_checkpoint()
|
||||||
_hash = blockchain.get_hash(checkpoint)
|
_hash = blockchain.get_hash(checkpoint)
|
||||||
|
|
Loading…
Reference in New Issue