diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index e600aab45594befae3d28846f092ae9b51b2bd60..c00c8fac572b1dce287bcd61c198a5a53442c0d2 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -198,18 +198,18 @@ class Network(QObject): 4 : The biggest number or timestamp """ # 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_by_occurences = {} 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: blocks_by_occurences[value] = [the_block] else: blocks_by_occurences[value].append(the_block) 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 return @@ -243,7 +243,7 @@ class Network(QObject): else: synced_block_hash = blocks_by_occurences[most_present][0]['hash'] - for n in [n for n in self._nodes if n.state in (Node.ONLINE, Node.DESYNCED)]: + for n in self.online_nodes: if n.block and n.block['hash'] == synced_block_hash: n.state = Node.ONLINE else: diff --git a/src/cutecoin/core/net/node.py b/src/cutecoin/core/net/node.py index 916bc6d99eb941c36bc559ba9978dd51f4f8629c..28d44778936342545273feed8a916ce28e6948c8 100644 --- a/src/cutecoin/core/net/node.py +++ b/src/cutecoin/core/net/node.py @@ -104,7 +104,7 @@ class Node(QObject): node = cls(peer.currency, peer.endpoints, "", pubkey, None, - Node.ONLINE, time.time(), + Node.OFFLINE, time.time(), {'root': "", 'leaves': []}, "", "", 0) logging.debug("Node from peer : {:}".format(str(node)))