|
@@ -77,7 +77,11 @@ class ClientChannelManager(relay.ChannelManager):
|
|
|
def get_consensus_from_fallbackrelay(self):
|
|
|
"""Download a fresh consensus from a random fallbackrelay."""
|
|
|
fb = random.choice(network.thenetwork.getfallbackrelays())
|
|
|
- self.send_msg(relay.RelayGetConsensusMsg(), fb.netaddr)
|
|
|
+ if self.consensus is not None and \
|
|
|
+ len(self.consensus.consdict['relays']) > 0:
|
|
|
+ self.send_msg(relay.RelayGetConsensusDiffMsg(), fb.netaddr)
|
|
|
+ else:
|
|
|
+ self.send_msg(relay.RelayGetConsensusMsg(), fb.netaddr)
|
|
|
|
|
|
def ensure_guard_vanilla(self):
|
|
|
"""Ensure that we have a channel to a guard (Vanilla Onion
|
|
@@ -141,7 +145,7 @@ class ClientChannelManager(relay.ChannelManager):
|
|
|
received."""
|
|
|
print("Client %s received msg %s from %s" % (self.myaddr, msg, peeraddr))
|
|
|
if isinstance(msg, relay.RelayConsensusMsg) or \
|
|
|
- instance(msg, relay.RelayConsensusDiffMsg):
|
|
|
+ isinstance(msg, relay.RelayConsensusDiffMsg):
|
|
|
dirauth.Consensus.verify(msg.consensus,
|
|
|
network.thenetwork.dirauthkeys(), self.perfstats)
|
|
|
self.consensus = msg.consensus
|
|
@@ -305,10 +309,10 @@ if __name__ == '__main__':
|
|
|
r = clients[0].channelmgr.consensus.select_weighted_relay(clients[0].channelmgr.consensus_cdf)
|
|
|
print("relay",r.descdict["addr"])
|
|
|
|
|
|
- #relays[3].terminate()
|
|
|
- #relaysent += relays[3].perfstats.bytes_sent
|
|
|
- #relayrecv += relays[3].perfstats.bytes_received
|
|
|
- #del relays[3]
|
|
|
+ relays[3].terminate()
|
|
|
+ relaysent += relays[3].perfstats.bytes_sent
|
|
|
+ relayrecv += relays[3].perfstats.bytes_received
|
|
|
+ del relays[3]
|
|
|
|
|
|
# Tick the epoch
|
|
|
network.thenetwork.nextepoch()
|