diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 90e20cfe88a27ec505bc87f35ad72054df21eb92..85f70ab27bb256cafe909d33d185a4ea6536f686 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -69,9 +69,11 @@ class Account(object): dead_communities = [] for data in json_data['communities']: try: - communities.append(Community.load(data)) + community = Community.load(data) + communities.append(community) except NoPeerAvailable: - dead_communities.append(data['currency']) + community = Community.without_network(data) + dead_communities.append(community) account = cls(salt, pubkey, name, communities, wallets, contacts, dead_communities) @@ -210,7 +212,8 @@ class Account(object): def jsonify(self): data_communities = [] - for c in self.communities: + communities = self.communities + self.dead_communities + for c in communities: data_communities.append(c.jsonify()) data_wallets = [] diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py index dda64837a5cdfa31eb2d0c724d86bb8f4f5bfd29..9f83796aa663c81d3ca61a3aa409541cec7ddb38 100644 --- a/src/cutecoin/core/community.py +++ b/src/cutecoin/core/community.py @@ -59,18 +59,16 @@ class Community(object): self.peers = [p for p in peers if p.currency == currency] self._cache = Cache(self) - # After initializing the community from latest peers, - # we refresh its peers tree - logging.debug("Creating community") - self.peers = self.peering() - logging.debug("{0} peers found".format(len(self.peers))) - logging.debug([peer.pubkey for peer in peers]) - self._cache.refresh() @classmethod def create(cls, currency, peer): - return cls(currency, [peer]) + community = cls(currency, [peer]) + logging.debug("Creating community") + community.peers = community.peering() + logging.debug("{0} peers found".format(len(community.peers))) + logging.debug([peer.pubkey for peer in community.peers]) + return community @classmethod def load(cls, json_data): @@ -92,6 +90,28 @@ class Community(object): except: pass + community = cls(currency, peers) + logging.debug("Creating community") + community.peers = community.peering() + logging.debug("{0} peers found".format(len(community.peers))) + logging.debug([peer.pubkey for peer in community.peers]) + return community + + @classmethod + def without_network(cls, json_data): + peers = [] + + currency = json_data['currency'] + + for data in json_data['peers']: + endpoints = [] + for e in data['endpoints']: + endpoints.append(Endpoint.from_inline(e)) + peer = Peer(PROTOCOL_VERSION, currency, data['pubkey'], + "0-DA39A3EE5E6B4B0D3255BFEF95601890AFD80709", + endpoints, None) + peers.append(peer) + community = cls(currency, peers) return community diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index 66e90d29b24168cda1cc4a36a1883a155e972436..675c4c4c4e21c8f5b0ba869e026e2264cc186b14 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -172,11 +172,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.action_configure_parameters.setEnabled(False) self.action_set_as_default.setEnabled(False) else: - for dead in self.app.current_account.dead_communities: - QMessageBox.critical(self, ":(", - "No {0} peers could be joined. Connection to its network is lost.".format(dead), - QMessageBox.Ok) - self.action_set_as_default.setEnabled(self.app.current_account.name != self.app.default_account) self.password_asker = PasswordAskerDialog(self.app.current_account)