Skip to content
Snippets Groups Projects
Commit 17a36e17 authored by inso's avatar inso
Browse files

Listing des noeuds Downstream

parent e29cf3fa
No related branches found
No related tags found
No related merge requests found
......@@ -24,12 +24,12 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTableView" name="communitiesTable"/>
<widget class="QTreeView" name="communitiesList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="serverEdit">
<property name="text">
<string/>
</property>
......@@ -39,24 +39,20 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2">
<property name="text">
<string/>
<widget class="QSpinBox" name="portBox">
<property name="minimum">
<number>1025</number>
</property>
<property name="placeholderText">
<string>Port</string>
<property name="maximum">
<number>99999</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Auth</string>
<property name="value">
<number>8081</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeCommunity">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
......@@ -113,5 +109,24 @@
</hint>
</hints>
</connection>
<connection>
<sender>addButton</sender>
<signal>clicked()</signal>
<receiver>AddCommunityDialog</receiver>
<slot>addCommunity()</slot>
<hints>
<hint type="sourcelabel">
<x>337</x>
<y>236</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>addCommunity()</slot>
</slots>
</ui>
......@@ -6,6 +6,9 @@ Created on 2 févr. 2014
from cutecoin.gen_resources.addAccountDialog_uic import Ui_AddAccountDialog
from PyQt5.QtWidgets import QDialog
from cutecoin.gui.addCommunityDialog import AddCommunityDialog
from cutecoin.models.community import CommunitiesManager
import gnupg
class AddAccountDialog(QDialog, Ui_AddAccountDialog):
'''
......@@ -20,9 +23,22 @@ class AddAccountDialog(QDialog, Ui_AddAccountDialog):
# Set up the user interface from Designer.
super(AddAccountDialog, self).__init__()
self.setupUi(self)
print("stiio")
self.dialog = AddCommunityDialog()
def setData(self):
self.communitiesManager = CommunitiesManager()
gpg = gnupg.GPG()
availableKeys = gpg.list_keys(True)
for key in availableKeys:
self.pgpkeyList.addItem(key['uids'][0])
def openAddCommunityDialog(self):
dialog = AddCommunityDialog()
dialog.show()
self.dialog.setCommunitiesManager(self.communitiesManager)
self.dialog.exec_()
def validAddCommunityDialog(self):
# TODO Show items in tree
pass
......@@ -5,6 +5,10 @@ Created on 2 févr. 2014
'''
from cutecoin.gen_resources.addCommunityDialog_uic import Ui_AddCommunityDialog
from PyQt5.QtWidgets import QDialog
from PyQt5.QtWidgets import QListWidgetItem
from cutecoin.models.community import CommunitiesManager, Community
from cutecoin.models.node import MainNode
import ucoinpy as ucoin
class AddCommunityDialog(QDialog, Ui_AddCommunityDialog):
'''
......@@ -19,3 +23,15 @@ class AddCommunityDialog(QDialog, Ui_AddCommunityDialog):
super(AddCommunityDialog, self).__init__()
self.setupUi(self)
def setCommunitiesManager(self, communitiesManager):
self.communitiesManager = communitiesManager
def addCommunity(self):
'''
Add community slot
'''
server = self.serverEdit.text()
port = self.portBox.value()
self.communitiesManager.addCommunity(MainNode(server, port))
......@@ -23,6 +23,5 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def openAddAccountDialog(self):
dialog = AddAccountDialog()
print("shoow")
dialog.show()
print("shoow2")
\ No newline at end of file
dialog.setData()
dialog.exec_()
\ No newline at end of file
......@@ -11,13 +11,13 @@ class Account(object):
classdocs
'''
def __init__(self, pgpKey, name, communities):
def __init__(self, pgpKey, name, communityManager):
'''
Constructor
'''
self.pgpKey = pgpKey
self.name = name
self.communities = communities
self.communityManager = communityManager
self.transactionNodes = []
self.trustableNodes = []
self.wallets = []
......
......@@ -10,14 +10,14 @@ class Community(object):
'''
classdocs
'''
def __init__(self, mainNode, currency):
'''
Constructor
'''
self.knowNodes = []
self.knowNodes.append(mainNode)
self.knownNodes = []
self.knownNodes.append(mainNode)
self.currency = currency
def members(self):
'''
......@@ -27,13 +27,15 @@ class Community(object):
# TODO : Try connecting with nodes of the list
# if the first fails
# Maybe create a method
ucoin.settings['server'] = self.knowNodes[0].address
ucoin.settings['server'] = self.knowNodes[0].server
ucoin.settings['port'] = self.knowNodes[0].port
ucoin.settings['auth'] = self.knowNodes[0].auth
members = ucoin.hdc.amendments.view.Members( ucoin.hdc.amendments.Current )
members = ucoin.hdc.amendments.view.Members().get()
return members
def nodes(self):
return self.knownNodes
class CommunitiesManager(object):
'''
classdocs
......@@ -49,11 +51,11 @@ class CommunitiesManager(object):
if com.currency == currency:
return com
def addCommunity(self, node):
ucoin.settings['server'] = node.address
ucoin.settings['port'] = node.port
ucoin.settings['auth'] = node.auth
currentAmendment = ucoin.hdc.amendments.Current.get(self)
def addCommunity(self, mainNode):
ucoin.settings['server'] = mainNode.server
ucoin.settings['port'] = mainNode.port
mainNode.downstreamPeers()
currentAmendment = ucoin.hdc.amendments.Promoted().get()
currency = currentAmendment['currency']
self.communities.append(Community(node), currency)
if self.getCommunity(currency) == None:
self.communities.append(Community(mainNode, currency))
......@@ -4,16 +4,31 @@ Created on 1 févr. 2014
@author: inso
'''
import ucoinpy as ucoin
class Node(object):
'''
classdocs
'''
def __init__(self, server, port, auth):
def __init__(self, server, port):
'''
Constructor
'''
self.server = server
self.port = port
self.auth = auth
def __eq__(self, other):
return ( self.server == other.server and self.port == other.port )
class MainNode(Node):
def downstreamPeers(self):
ucoin.settings['server'] = self.server
ucoin.settings['port'] = self.port
peers = []
for peer in ucoin.ucg.peering.peers.DownStream().get()['peers']:
node = Node(peer['ipv4'], peer['port'])
print(node.server + ":" + node.port)
peers.append(node)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment