Skip to content

Commit

Permalink
getBestHops now lazy loads trades
Browse files Browse the repository at this point in the history
In the case where you are calling getBestHops without having fully loaded the trades set, if it encounters stations for which it does not yet have trades out of, it will load that data. Once it has loaded data for a station, it won't try to reload it.
  • Loading branch information
kfsone committed Nov 17, 2014
1 parent f499e5c commit 9d93ee4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tradecalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ def getBestHops(self, routes, restrictTo=None):
bestToDest = {}
safetyMargin = 1.0 - tdenv.margin
unique = tdenv.unique

stationsNotYetLoaded = [
src.ID for src in [ route.route[-1] for route in routes ]
if src.tradingWith is None
]
if stationsNotYetLoaded:
self.tdb.loadStationTrades(stationsNotYetLoaded)

for route in routes:
tdenv.DEBUG1("Route = {}", route.str())

Expand Down

0 comments on commit 9d93ee4

Please sign in to comment.