Skip to content

Commit

Permalink
Small changes to requestcache
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsZeilemaker committed Dec 16, 2013
1 parent b7afb3e commit a6d5f59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions Tribler/community/anontunnel/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,6 @@ def on_bypass_message(self, sock_addr, packet):
relay_key = (candidate, circuit_id)
packet_type = self.proxy_conversion.get_type(data)

# TODO: remove this line
if packet_type == chr(6):
return

logger.debug("GOT %s from %s:%d over circuit %d", MESSAGE_STRING_REPRESENTATION[packet_type], candidate.sock_addr[0], candidate.sock_addr[1], circuit_id)

# First, relay packet if we know whom to forward message to for this circuit
Expand All @@ -342,7 +338,7 @@ def on_bypass_message(self, sock_addr, packet):
if circuit_id in self.circuits:
self.circuits[circuit_id].last_incomming = time()

if not self.on_custom[packet_type](circuit_id, candidate, payload):
if not self.on_custom.get(packet_type, lambda *args:None)(circuit_id, candidate, payload):
self.dict_inc(dispersy.statistics.success, MESSAGE_STRING_REPRESENTATION[packet_type] + '-ignored')
logger.debug("Prev message was IGNORED")
else:
Expand All @@ -352,7 +348,7 @@ class CircuitRequestCache(NumberCache):

@staticmethod
def create_number(force_number= -1):
return force_number if force_number >= 0 else IntroductionRequestCache.create_number()
return force_number if force_number >= 0 else NumberCache.create_number()

@staticmethod
def create_identifier(number, force_number= -1):
Expand Down Expand Up @@ -561,7 +557,7 @@ class PingRequestCache(NumberCache):

@staticmethod
def create_number(force_number= -1):
return force_number if force_number >= 0 else IntroductionRequestCache.create_number()
return force_number if force_number >= 0 else NumberCache.create_number()

@staticmethod
def create_identifier(number, force_number= -1):
Expand Down Expand Up @@ -668,7 +664,7 @@ def check_ready(self):
self.circuit_selection_strategy.try_select(self.active_circuits)
self.online = True

except BaseException:
except ValueError:
self.online = False

finally:
Expand Down
2 changes: 1 addition & 1 deletion Tribler/dispersy

0 comments on commit a6d5f59

Please sign in to comment.