Skip to content
Snippets Groups Projects
Commit 435dd4f5 authored by inso's avatar inso
Browse files

Fixed a bug in network traversal

parent c1025b49
No related branches found
No related tags found
No related merge requests found
...@@ -82,14 +82,24 @@ class Network(QObject): ...@@ -82,14 +82,24 @@ class Network(QObject):
def start_perpetual_crawling(self): def start_perpetual_crawling(self):
self.must_crawl = True self.must_crawl = True
while self.must_crawl: while self.must_crawl:
self.nodes = self.crawling(interval=10) nodes = self.crawling(interval=10)
for n in self._nodes:
n.changed.connect(self.nodes_changed) new_inlines = [n.endpoint.inline() for n in nodes]
last_inlines = [n.endpoint.inline() for n in self._nodes]
hash_new_nodes = hash(tuple(frozenset(sorted(new_inlines))))
hash_last_nodes= hash(tuple(frozenset(sorted(last_inlines))))
if hash_new_nodes != hash_last_nodes:
self._nodes = nodes
self.nodes_changed.emit()
for n in self._nodes:
n.changed.connect(self.nodes_changed)
def crawling(self, interval=0): def crawling(self, interval=0):
nodes = [] nodes = []
traversed_pubkeys = [] traversed_pubkeys = []
for n in self.nodes: for n in self._nodes.copy():
logging.debug(traversed_pubkeys) logging.debug(traversed_pubkeys)
logging.debug("Peering : next to read : {0} : {1}".format(n.pubkey, logging.debug("Peering : next to read : {0} : {1}".format(n.pubkey,
(n.pubkey not in traversed_pubkeys))) (n.pubkey not in traversed_pubkeys)))
......
...@@ -112,8 +112,9 @@ class Node(QObject): ...@@ -112,8 +112,9 @@ class Node(QObject):
self._pubkey = node_pubkey self._pubkey = node_pubkey
emit_change = True emit_change = True
new_inlines = [e.inline() for e in [n for n in self._neighbours]] logging.debug(neighbours)
last_inlines = [e.inline() for e in [n for n in self._neighbours]] new_inlines = [e.inline() for n in neighbours for e in n]
last_inlines = [e.inline() for n in self._neighbours for e in n]
hash_new_neighbours = hash(tuple(frozenset(sorted(new_inlines)))) hash_new_neighbours = hash(tuple(frozenset(sorted(new_inlines))))
hash_last_neighbours = hash(tuple(frozenset(sorted(last_inlines)))) hash_last_neighbours = hash(tuple(frozenset(sorted(last_inlines))))
...@@ -138,7 +139,7 @@ class Node(QObject): ...@@ -138,7 +139,7 @@ class Node(QObject):
peering = bma.network.Peering(self.endpoint.conn_handler()).get() peering = bma.network.Peering(self.endpoint.conn_handler()).get()
peer = Peer.from_signed_raw("{0}{1}\n".format(peering['raw'], peer = Peer.from_signed_raw("{0}{1}\n".format(peering['raw'],
peering['signature'])) peering['signature']))
node = Node.from_peer(peer) node = Node.from_peer(currency, peer)
logging.debug(traversed_pubkeys) logging.debug(traversed_pubkeys)
logging.debug("Traversing : next to read : {0} : {1}".format(node.pubkey, logging.debug("Traversing : next to read : {0} : {1}".format(node.pubkey,
(node.pubkey not in traversed_pubkeys))) (node.pubkey not in traversed_pubkeys)))
......
...@@ -36,6 +36,6 @@ class NetworkTabWidget(QWidget, Ui_NetworkTabWidget): ...@@ -36,6 +36,6 @@ class NetworkTabWidget(QWidget, Ui_NetworkTabWidget):
community.network.nodes_changed.connect(self.refresh_nodes) community.network.nodes_changed.connect(self.refresh_nodes)
def refresh_nodes(self): def refresh_nodes(self):
self.table_network.sourceModel.dataChanged.emit(QModelIndex(), QModelIndex()) self.table_network.model().sourceModel().modelReset.emit()
...@@ -47,6 +47,8 @@ class NetworkFilterProxyModel(QSortFilterProxyModel): ...@@ -47,6 +47,8 @@ class NetworkFilterProxyModel(QSortFilterProxyModel):
def data(self, index, role): def data(self, index, role):
source_index = self.mapToSource(index) source_index = self.mapToSource(index)
if not source_index.isValid():
return QVariant()
source_data = self.sourceModel().data(source_index, role) source_data = self.sourceModel().data(source_index, role)
if index.column() == self.sourceModel().column_types.index('is_member') \ if index.column() == self.sourceModel().column_types.index('is_member') \
and role == Qt.DisplayRole: and role == Qt.DisplayRole:
......
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