Skip to content

Commit

Permalink
Fixed --max-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Mar 15, 2015
1 parent 381db3b commit c1fec63
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions commands/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,14 +1019,15 @@ def run(results, cmdenv, tdb):
elif len(viaSet) > cmdenv.adhocHops:
restrictTo = viaSet

if cmdenv.maxRoutes and hopNo >= 1:
routes = routes[:cmdenv.maxRoutes]

if pruneMod and hopNo + 1 >= cmdenv.pruneHops and len(routes) > 10:
if hopNo >= 1 and cmdenv.maxRoutes or pruneMod:
routes.sort()
crop = int(len(routes) * pruneMod)
routes = routes[:-crop]
cmdenv.NOTE("Pruned {} origins", crop)
if cmdenv.maxRoutes:
routes = routes[:cmdenv.maxRoutes]

if pruneMod and hopNo + 1 >= cmdenv.pruneHops and len(routes) > 10:
crop = int(len(routes) * pruneMod)
routes = routes[:-crop]
cmdenv.NOTE("Pruned {} origins", crop)

if cmdenv.progress:
print("* Hop {:3n}: {:.>10n} origins".format(hopNo+1, len(routes)))
Expand Down

0 comments on commit c1fec63

Please sign in to comment.