Skip to content

Commit

Permalink
chore: clean up SupplyChainBuilder a little
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Feb 25, 2024
1 parent 8e1b062 commit 97837d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions packages/cli/bin/exports_supply_chain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,23 @@ class DescribingVisitor extends SupplyLinkVisitor {

void source(
MarketListingSnapshot marketListings,
SystemsCache systemsCache,
TradeExportCache exportCache,
SystemsCache systems,
TradeExportCache exports,
MarketPriceSnapshot marketPrices,
TradeSymbol tradeSymbol,
WaypointSymbol waypointSymbol,
) {
logger.info('Sourcing $tradeSymbol for $waypointSymbol');
final action = SupplyChainBuilder(
marketListings,
systemsCache,
exportCache,
systems: systems,
exports: exports,
marketListings: marketListings,
).buildChainTo(tradeSymbol, waypointSymbol);
if (action == null) {
logger.warn('No source for $tradeSymbol for $waypointSymbol');
return;
}
final visitor = DescribingVisitor(systemsCache, marketPrices);
action.accept(visitor);
action.accept(DescribingVisitor(systems, marketPrices));
}

Future<void> command(FileSystem fs, Database db, ArgResults argResults) async {
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/lib/supply_chain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class SupplyLink {
/// The trade symbol being supplied.
final TradeSymbol tradeSymbol;

/// Does a depth-first traversal of the supply chain.
/// Does a depth first walk with pre-order traversal.
void accept(SupplyLinkVisitor visitor, {int depth = 0});
}

Expand Down Expand Up @@ -155,11 +155,11 @@ MarketListing? _nearestListingWithExport(
/// Builds a supply chain.
class SupplyChainBuilder {
/// Create a new supply chain builder.
const SupplyChainBuilder(
MarketListingSnapshot marketListings,
SystemsCache systems,
TradeExportCache exports,
) : _marketListings = marketListings,
const SupplyChainBuilder({
required SystemsCache systems,
required MarketListingSnapshot marketListings,
required TradeExportCache exports,
}) : _marketListings = marketListings,
_systems = systems,
_exports = exports;

Expand Down

0 comments on commit 97837d9

Please sign in to comment.