Skip to content
Snippets Groups Projects
Commit 3b87756f authored by inso's avatar inso
Browse files

Finally ! Network stabilized.

- New icon showing network connection quality
- Lots of bugs fixed
parent 38ea4399
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
viewBox="0 0 100 100"
id="svg3336"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="connected.svg">
<defs
id="defs3338">
<linearGradient
inkscape:collect="always"
id="linearGradient4150">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop4152" />
<stop
style="stop-color:#ffffff;stop-opacity:0.04620462"
offset="1"
id="stop4154" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4150"
id="radialGradient4162"
cx="52.325901"
cy="1005.1627"
fx="52.325901"
fy="1005.1627"
r="42.926411"
gradientTransform="matrix(1.539681,0,0,1.5451884,-48.391841,-562.49866)"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="80.436882"
inkscape:cy="33.829638"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="false"
inkscape:window-width="1366"
inkscape:window-height="725"
inkscape:window-x="-7"
inkscape:window-y="17"
inkscape:window-maximized="1" />
<metadata
id="metadata3341">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-952.36216)">
<ellipse
style="opacity:1;fill:#17d017;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path3346"
cx="51.785713"
cy="1005.5765"
rx="41.785713"
ry="40.714287" />
<ellipse
style="opacity:0.65;fill:url(#radialGradient4162);fill-opacity:1;stroke:none;stroke-width:1.25129819;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4148"
cx="32.173359"
cy="990.66699"
rx="64.928177"
ry="65.10495" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
viewBox="0 0 100 100"
id="svg3336"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="disconnected.svg">
<defs
id="defs3338">
<linearGradient
inkscape:collect="always"
id="linearGradient4150">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop4152" />
<stop
style="stop-color:#ffffff;stop-opacity:0.04620462"
offset="1"
id="stop4154" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4150"
id="radialGradient4162"
cx="52.325901"
cy="1005.1627"
fx="52.325901"
fy="1005.1627"
r="42.926411"
gradientTransform="matrix(1.539681,0,0,1.5451884,-48.038287,-560.37733)"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="80.436882"
inkscape:cy="33.829638"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="false"
inkscape:window-width="1366"
inkscape:window-height="725"
inkscape:window-x="-7"
inkscape:window-y="17"
inkscape:window-maximized="1" />
<metadata
id="metadata3341">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-952.36216)">
<ellipse
style="opacity:1;fill:#c60002;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path3346"
cx="51.785713"
cy="1005.5765"
rx="41.785713"
ry="40.714287" />
<ellipse
style="opacity:0.65;fill:url(#radialGradient4162);fill-opacity:1;stroke:none;stroke-width:1.25129819;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4148"
cx="32.526913"
cy="992.78827"
rx="64.928177"
ry="65.10495" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
viewBox="0 0 100 100"
id="svg3336"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="weak_connect.svg">
<defs
id="defs3338">
<linearGradient
inkscape:collect="always"
id="linearGradient4150">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop4152" />
<stop
style="stop-color:#ffffff;stop-opacity:0.04620462"
offset="1"
id="stop4154" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient4150"
id="radialGradient4162"
cx="52.325901"
cy="1005.1627"
fx="52.325901"
fy="1005.1627"
r="42.926411"
gradientTransform="matrix(1.539681,0,0,1.5451884,-51.220268,-564.97353)"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="80.436882"
inkscape:cy="33.829638"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="false"
inkscape:window-width="1366"
inkscape:window-height="725"
inkscape:window-x="-7"
inkscape:window-y="17"
inkscape:window-maximized="1" />
<metadata
id="metadata3341">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-952.36216)">
<ellipse
style="opacity:1;fill:#fff41c;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path3346"
cx="51.785713"
cy="1005.5765"
rx="41.785713"
ry="40.714287" />
<ellipse
style="opacity:0.65;fill:url(#radialGradient4162);fill-opacity:1;stroke:none;stroke-width:1.25129819;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4148"
cx="29.344933"
cy="988.19208"
rx="64.928177"
ry="65.10495" />
</g>
</svg>
......@@ -35,6 +35,7 @@ class Network(Watcher):
self.nodes = nodes
self._must_crawl = False
self._is_perpetual = False
self._block_found = 0
@classmethod
def create(cls, node):
......@@ -52,7 +53,7 @@ class Network(Watcher):
for node in nodes:
node.check_sync(block_max)
network.nodes = nodes
network.latest_block = block_max
network._block_found = network.latest_block
return network
def merge_with_json(self, json_data):
......@@ -89,7 +90,9 @@ class Network(Watcher):
block_max = max([n.block for n in nodes])
for node in nodes:
node.check_sync(block_max)
return cls(currency, nodes)
network = cls(currency, nodes)
network._block_found = network.latest_block
return network
def jsonify(self):
'''
......@@ -206,13 +209,11 @@ class Network(Watcher):
def handle_change(self):
node = self.sender()
logging.debug("Handle change")
block_max = max([n.block for n in self.nodes])
if node.state in (Node.ONLINE, Node.DESYNCED):
node.check_sync(block_max)
if self.latest_block != block_max:
logging.debug("New block found : {0}".format(block_max))
self.latest_block = block_max
node.check_sync(self.latest_block)
logging.debug("{0} -> {1}".format(self.latest_block, self.latest_block))
if self._block_found != self.latest_block:
logging.debug("New block found : {0}".format(self.latest_block))
self.new_block_mined.emit(self.latest_block)
if node.last_change + 3600 < time.time() and \
......@@ -224,6 +225,7 @@ class Network(Watcher):
pass
self.nodes.remove(node)
QCoreApplication.processEvents()
logging.debug("Syncing : {0} : last changed {1} : unsynced : {2}".format(node.pubkey[:5],
node.last_change, time.time() - node.last_change))
......
......@@ -136,6 +136,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
@pyqtSlot(int)
def refresh_block(self, block_number):
logging.debug("Refesh block")
if self.tab_wallets:
self.tab_wallets.refresh()
......@@ -150,6 +151,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
@pyqtSlot()
def refresh_status(self):
logging.debug("Refresh status")
if self.community.network_quality() > 0.66:
icon = '<img src=":/icons/connected" width="12" height="12"/>'
text = "Connected : Block {0}".format(self.community.network.latest_block)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment