Commit 780bfbe3 authored by Julien Muchembled's avatar Julien Muchembled

Faster recovery of registry node (e.g. restart or temporary network cut)

parent f68cdf51
...@@ -380,9 +380,14 @@ class TunnelManager(object): ...@@ -380,9 +380,14 @@ class TunnelManager(object):
distant_peers.sort(key=self._newTunnelScore) distant_peers.sort(key=self._newTunnelScore)
# Check whether we're connected to the network. # Check whether we're connected to the network.
registry = self.peer_db.registry_prefix registry = self.peer_db.registry_prefix
if (registry == self._prefix or registry in peers if registry == self._prefix:
or registry in self._connection_dict if not distant_peers:
or registry in self._served): # Faster recovery of registry node: use cache instead
# of waiting that another node tries to connect to it.
distant_peers = None
elif (registry in peers or
registry in self._connection_dict or
registry in self._served):
self._disconnected = 0 self._disconnected = 0
# Do not bootstrap too often, especially if we are several # Do not bootstrap too often, especially if we are several
# nodes to try. # nodes to try.
...@@ -433,12 +438,12 @@ class TunnelManager(object): ...@@ -433,12 +438,12 @@ class TunnelManager(object):
# The following condition on 'peers' is the same as above, # The following condition on 'peers' is the same as above,
# when we asked the registry for a node to bootstrap. # when we asked the registry for a node to bootstrap.
if not (new or peers): if not (new or peers):
if bootstrap: if bootstrap and registry != self._prefix:
# Startup without any good address in the cache. # Startup without any good address in the cache.
peer = self.peer_db.getBootstrapPeer() peer = self.peer_db.getBootstrapPeer()
if peer and self._makeTunnel(*peer): if peer and self._makeTunnel(*peer):
return return
# Failed to bootstrap ! Last change to connect is to # Failed to bootstrap ! Last chance to connect is to
# retry an address that already failed :( # retry an address that already failed :(
for peer in self.peer_db.getPeerList(1): for peer in self.peer_db.getPeerList(1):
if self._makeTunnel(*peer): if self._makeTunnel(*peer):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment