Browse Source

Be able to mark relays as fallback relays

Fallback relays should never terminate
Ian Goldberg 5 years ago
parent
commit
8532b300ab
1 changed files with 10 additions and 0 deletions
  1. 10 0
      relay.py

+ 10 - 0
relay.py

@@ -182,8 +182,16 @@ class Relay(network.Server):
         # Create the CellRelay connection manager
         self.cellrelay = CellRelay(self.netaddr, dirauthaddrs)
 
+        # Initially, we're not a fallback relay
+        self.is_fallbackrelay = False
+
         self.uploaddesc()
 
+    def set_is_fallbackrelay(self, isfallback = True):
+        """Set this relay to be a fallback relay (or unset if passed
+        False)."""
+        self.is_fallbackrelay = isfallback
+
     def epoch_ending(self, epoch):
         # Download the new consensus, which will have been created
         # already since the dirauths' epoch_ending callbacks happened
@@ -254,6 +262,8 @@ if __name__ == '__main__':
     # relays, used by clients for bootstrapping
     numfallbackrelays = int(numrelays * 0.05) + 1
     fallbackrelays = random.sample(relays, numfallbackrelays)
+    for r in fallbackrelays:
+        r.set_is_fallbackrelay()
     network.thenetwork.setfallbackrelays(fallbackrelays)
 
     # Tick the epoch