From 9addeefa3d6a8d42d2406e44143a4f4e4db3a5fb Mon Sep 17 00:00:00 2001
From: Inso <insomniak.fr@gmail.com>
Date: Fri, 22 May 2015 13:31:10 +0200
Subject: [PATCH] Fixed a bug when nodes are not syncing fast enough

---
 src/cutecoin/core/net/network.py | 4 ++++
 src/cutecoin/core/net/node.py    | 8 +++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py
index 4a85193f..7798d94c 100644
--- a/src/cutecoin/core/net/network.py
+++ b/src/cutecoin/core/net/network.py
@@ -113,6 +113,10 @@ class Network(Watcher):
         '''
         Get nodes which are in the ONLINE state.
         '''
+        latest = self.latest_block
+        for n in self._nodes:
+            if n.state in (Node.ONLINE, Node.DESYNCED):
+                n.check_sync(latest)
         return [n for n in self.nodes if n.state == Node.ONLINE]
 
     @property
diff --git a/src/cutecoin/core/net/node.py b/src/cutecoin/core/net/node.py
index 8f2be800..efd6a842 100644
--- a/src/cutecoin/core/net/node.py
+++ b/src/cutecoin/core/net/node.py
@@ -192,20 +192,18 @@ class Node(QObject):
 
     @last_change.setter
     def last_change(self, val):
-        logging.debug("{:} | Changed state : {:}".format(self.pubkey[:5],
-                                                         val))
+        #logging.debug("{:} | Changed state : {:}".format(self.pubkey[:5],val))
         self._last_change = val
 
     @state.setter
     def state(self, new_state):
-        logging.debug("{:} | Last state : {:} / new state : {:}".format(self.pubkey[:5],
-                                                                        self.state, new_state))
+        #logging.debug("{:} | Last state : {:} / new state : {:}".format(self.pubkey[:5],self.state, new_state))
         if self._state != new_state:
             self.last_change = time.time()
         self._state = new_state
 
     def check_sync(self, block):
-        logging.debug("Check sync")
+        #logging.debug("Check sync")
         if self.block < block:
             self.state = Node.DESYNCED
         else:
-- 
GitLab