Skip to content

Commit

Permalink
Fix bug in Tor consensus downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnchaC committed Jan 22, 2016
1 parent 20e6aa0 commit d566b7c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions oniontip/util.py
Expand Up @@ -101,7 +101,7 @@ def __init__(self,request):

class Result():
WEIGHT_FIELDS = {
'consensus_weight_fraction': 'cw',
'consensus_weight_fraction': 'cw',
'advertised_bandwidth_fraction': 'adv_bw',
'guard_probability': 'p_guard',
'middle_probability': 'p_middle',
Expand Down Expand Up @@ -273,10 +273,10 @@ def sort_and_reduce(self, relay_set, options):
filtered), sort it and return the ones requested
in the 'top' option. Add index numbers to them as well.
Returns a hash with three values:
Returns a hash with three values:
*results*: A list of Result objects representing the selected
relays
*excluded*: A Result object representing the stats for the
*excluded*: A Result object representing the stats for the
filtered out relays. May be None
*total*: A Result object representing the stats for all of the
relays in this filterset.
Expand All @@ -289,7 +289,7 @@ def sort_and_reduce(self, relay_set, options):
# We need a simple sorting key function
def sort_fn(r):
return getattr(r,options.sort)

relay_set.sort(key=sort_fn,reverse=options.sort_reverse)

if options.top < 0:
Expand Down Expand Up @@ -351,7 +351,7 @@ def sort_fn(r):
}


def select_relays(self, grouped_relays, options):
def select_relays(self, grouped_relays, options):
"""
Return a Pythonic representation of the relays result set. Return it as a set of Result objects.
"""
Expand Down Expand Up @@ -417,7 +417,7 @@ def select_relays(self, grouped_relays, options):
return results


@cache.memoize(timeout=300)
#@cache.memoize(timeout=300)
def determine_relays(options):
stats = RelayStats(options)
results = stats.select_relays(stats.relays, options)
Expand Down Expand Up @@ -474,4 +474,7 @@ def check_and_update_bitcoin_fields(relay_details):
shutil.move(temp_file_name, details_file_path)

# Remove the currently loaded relay object as we have new data
del app.relay_data
try:
del app.relay_data
except AttributeError:
pass

0 comments on commit d566b7c

Please sign in to comment.