diff --git a/res/icons/connected.svg b/res/icons/connected.svg new file mode 100644 index 0000000000000000000000000000000000000000..8e4a17174e997d1a0166da44dfac69f53719f8f8 --- /dev/null +++ b/res/icons/connected.svg @@ -0,0 +1,98 @@ +<?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> diff --git a/res/icons/disconnected.svg b/res/icons/disconnected.svg new file mode 100644 index 0000000000000000000000000000000000000000..4224156fbf5b7cd077c4a6db7a5b268e0205a55a --- /dev/null +++ b/res/icons/disconnected.svg @@ -0,0 +1,98 @@ +<?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> diff --git a/res/icons/weak_connect.svg b/res/icons/weak_connect.svg new file mode 100644 index 0000000000000000000000000000000000000000..26e2d94c4cff206add115b6cb46efd5397e7a646 --- /dev/null +++ b/res/icons/weak_connect.svg @@ -0,0 +1,98 @@ +<?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> diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index 1c3f66af331a73ff5de6b5cf3639ee588ddefc6b..dfe01ce6ea129d3ceceb50cd629c84ab37e07cdc 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -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)) diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 2e24ab1b838fe8a696e7d676d8c0f291b0cb3dd9..27c3881dd86b1965760f38013258483d62fa5be6 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -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)