Skip to content
Snippets Groups Projects
Commit 56a7a8e6 authored by inso's avatar inso
Browse files

Check sync between nodes ONLINE or DESYNCED

parent b3e3755a
No related branches found
No related tags found
No related merge requests found
...@@ -198,18 +198,18 @@ class Network(QObject): ...@@ -198,18 +198,18 @@ class Network(QObject):
4 : The biggest number or timestamp 4 : The biggest number or timestamp
""" """
# rule number 1 : block of the majority # rule number 1 : block of the majority
blocks = [n.block['hash'] for n in self.nodes if n.block] blocks = [n.block['hash'] for n in self.online_nodes if n.block]
blocks_occurences = Counter(blocks) blocks_occurences = Counter(blocks)
blocks_by_occurences = {} blocks_by_occurences = {}
for key, value in blocks_occurences.items(): for key, value in blocks_occurences.items():
the_block = [n.block for n in self.nodes if n.block and n.block['hash'] == key][0] the_block = [n.block for n in self.online_nodes if n.block and n.block['hash'] == key][0]
if value not in blocks_by_occurences: if value not in blocks_by_occurences:
blocks_by_occurences[value] = [the_block] blocks_by_occurences[value] = [the_block]
else: else:
blocks_by_occurences[value].append(the_block) blocks_by_occurences[value].append(the_block)
if len(blocks_by_occurences) == 0: if len(blocks_by_occurences) == 0:
for n in [n for n in self._nodes if n.state in (Node.ONLINE, Node.DESYNCED)]: for n in [n for n in self.online_nodes if n.state in (Node.ONLINE, Node.DESYNCED)]:
n.state = Node.ONLINE n.state = Node.ONLINE
return return
......
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