diff --git a/bin/marketserver/config/currencys/13473/currency.json b/bin/marketserver/config/currencys/13473/currency.json index 1987a1a4..6eaea9ed 100644 --- a/bin/marketserver/config/currencys/13473/currency.json +++ b/bin/marketserver/config/currencys/13473/currency.json @@ -1,4 +1,6 @@ -{ - "currency_name": "TestToken", - "currency_decimal": 6 -} +[ + { + "currency_name": "TestToken", + "currency_decimal": 6 + } +] diff --git a/server/marketserver/mt/Currency.go b/server/marketserver/mt/Currency.go index 0fd742de..c18c21f0 100644 --- a/server/marketserver/mt/Currency.go +++ b/server/marketserver/mt/Currency.go @@ -105,23 +105,25 @@ func (this *CurrencyTable) Load() { fileName := fmt.Sprintf("../config/currencys/%d/currency.json", netId) if jsonStr, err := f5.ReadJsonFile(fileName); err == nil { f5.GetSysLog().Info("load currency %s", fileName) - currencyCfg := struct { + currencysCfg := []struct { CurrencyName string `json:"currency_name"` ExchangeRate int64 `json:"exchange_rate"` CurrencyDecimal int64 `json:"currency_decimal"` }{} - if err := q5.DecodeJson(jsonStr, ¤cyCfg); err != nil { + if err := q5.DecodeJson(jsonStr, ¤cysCfg); err != nil { panic(fmt.Sprintf("load metafile json decode error %s %s", "currency.json", err)) } - p := new(Currency) - p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal) - p.check() - currencysMeta := this.GetByNetId(netId) - if currencysMeta == nil { - currencysMeta = new(q5.ConcurrentMap[string, *Currency]) - this.netIdHash.Store(netId, currencysMeta) + for _, currencyCfg := range currencysCfg { + p := new(Currency) + p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal) + p.check() + currencysMeta := this.GetByNetId(netId) + if currencysMeta == nil { + currencysMeta = new(q5.ConcurrentMap[string, *Currency]) + this.netIdHash.Store(netId, currencysMeta) + } + currencysMeta.Store(p.GetCurrencyName(), p) } - currencysMeta.Store(p.GetCurrencyName(), p) } } }