Skip to content

Commit 25577a6

Browse files
committed
mtgban/client: Correctly use the new shorthand for multi registration
And improve documentation and variable naming to better reflect their contents.
1 parent 31ff66c commit 25577a6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

mtgban/client.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@ func (bc *BanClient) RegisterSeller(scraper Scraper) {
6666
}
6767
}
6868

69-
// Add a Scraper to the client, enable the Market with the given shorthand
70-
func (bc *BanClient) RegisterMarket(scraper Market, shorthand string) {
69+
// Add a Scraper to the client, enable the Market with the given name
70+
func (bc *BanClient) RegisterMarket(scraper Market, name string) {
7171
market := &BaseMarket{}
7272
market.scraper = scraper
73-
market.info = scraper.InfoForScraper(shorthand)
73+
market.info = scraper.InfoForScraper(name)
7474

7575
// Disable the market itself from providing seller data
7676
bc.sellerDisabled[scraper.Info().Shorthand] = true
7777
// Disable any vendor side of the split market (not the market itself)
78-
_, found := bc.vendorDisabled[shorthand]
78+
_, found := bc.vendorDisabled[market.info.Shorthand]
7979
if !found {
80-
bc.vendorDisabled[shorthand] = true
80+
bc.vendorDisabled[market.info.Shorthand] = true
8181
}
8282

8383
// Register
84-
bc.scrapers[shorthand] = market
84+
bc.scrapers[market.info.Shorthand] = market
8585
}
8686

8787
// Add a Scraper to the client, enable the vendor side only (if any)
@@ -103,22 +103,22 @@ func (bc *BanClient) RegisterVendor(scraper Scraper) {
103103
bc.vendorDisabled[scraper.Info().Shorthand] = false
104104
}
105105

106-
// Add a Scraper to the client, enable the Trader with the given shorthand
107-
func (bc *BanClient) RegisterTrader(scraper Trader, shorthand string) {
106+
// Add a Scraper to the client, enable the Trader with the given name
107+
func (bc *BanClient) RegisterTrader(scraper Trader, name string) {
108108
trader := &BaseTrader{}
109109
trader.scraper = scraper
110-
trader.info = scraper.InfoForScraper(shorthand)
110+
trader.info = scraper.InfoForScraper(name)
111111

112112
// Disable the trader itself from providing vendor data
113113
bc.vendorDisabled[scraper.Info().Shorthand] = true
114114
// Disable any seller side of the split trader (not the trader itself)
115-
_, found := bc.sellerDisabled[shorthand]
115+
_, found := bc.sellerDisabled[trader.info.Shorthand]
116116
if !found {
117-
bc.sellerDisabled[shorthand] = true
117+
bc.sellerDisabled[trader.info.Shorthand] = true
118118
}
119119

120120
// Register
121-
bc.scrapers[shorthand] = trader
121+
bc.scrapers[trader.info.Shorthand] = trader
122122
}
123123

124124
// Load inventory and buylist content for each scraper registered in the client

mtgban/mtgban.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ type Scraper interface {
156156

157157
// MultiScraper is the interface both Market and Trader need to implement
158158
type MultiScraper interface {
159-
// Retrieve the ScraperInfo for one of the internal scrapers
160-
InfoForScraper(string) ScraperInfo
159+
// Retrieve the ScraperInfo for an internal scraper with the given name
160+
InfoForScraper(name string) ScraperInfo
161161

162162
// MultiScraper implements the Scraper interface
163163
Scraper

0 commit comments

Comments
 (0)