Esempio n. 1
0
    def bootstrap_nodes(self):
        if self._bootstrap_nodes is None or len(self._bootstrap_nodes) == 0:
            if self.is_dev_test_node:
                self.save_node_address_to_local_peer_pool_file()

                if len(self.preferred_nodes) == 0:
                    self._bootstrap_nodes = tuple(
                        KademliaNode.from_uri(enode)
                        for enode in MAINNET_BOOTNODES)
                else:
                    saved_bootstrap_nodes = tuple(
                        load_local_nodes(self.local_peer_pool_path))

                    #assume instance 0 is the bootstrap node for dev testing
                    bootstrap_node = None
                    for loop_bootstrap_node in saved_bootstrap_nodes:
                        if loop_bootstrap_node.address.tcp_port == 30303:
                            bootstrap_node = loop_bootstrap_node

                    if bootstrap_node is not None and (bootstrap_node.pubkey !=
                                                       self.nodekey_public):
                        self._bootstrap_nodes = (bootstrap_node, )
                    else:
                        self._bootstrap_nodes = ()

            else:
                if self.network_id == MAINNET_NETWORK_ID:
                    self._bootstrap_nodes = tuple(
                        KademliaNode.from_uri(enode)
                        for enode in MAINNET_BOOTNODES)
        return self._bootstrap_nodes
Esempio n. 2
0
 def preferred_nodes(self):
     if self.is_dev_test_node and (self._preferred_nodes is None
                                   or len(self._preferred_nodes) == 0):
         try:
             self._preferred_nodes = tuple(
                 load_local_nodes(self.local_peer_pool_path, self.nodekey))
         except FileNotFoundError:
             self._preferred_nodes = ()
     return self._preferred_nodes