1
This commit is contained in:
parent
0c6f21e211
commit
9fcc66005a
@ -1,4 +1,6 @@
|
||||
{
|
||||
"currency_name": "TestToken",
|
||||
"currency_decimal": 6
|
||||
}
|
||||
[
|
||||
{
|
||||
"currency_name": "TestToken",
|
||||
"currency_decimal": 6
|
||||
}
|
||||
]
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user