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)
|
fileName := fmt.Sprintf("../config/currencys/%d/currency.json", netId)
|
||||||
if jsonStr, err := f5.ReadJsonFile(fileName); err == nil {
|
if jsonStr, err := f5.ReadJsonFile(fileName); err == nil {
|
||||||
f5.GetSysLog().Info("load currency %s", fileName)
|
f5.GetSysLog().Info("load currency %s", fileName)
|
||||||
currencyCfg := struct {
|
currencysCfg := []struct {
|
||||||
CurrencyName string `json:"currency_name"`
|
CurrencyName string `json:"currency_name"`
|
||||||
ExchangeRate int64 `json:"exchange_rate"`
|
ExchangeRate int64 `json:"exchange_rate"`
|
||||||
CurrencyDecimal int64 `json:"currency_decimal"`
|
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))
|
panic(fmt.Sprintf("load metafile json decode error %s %s", "currency.json", err))
|
||||||
}
|
}
|
||||||
p := new(Currency)
|
for _, currencyCfg := range currencysCfg {
|
||||||
p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal)
|
p := new(Currency)
|
||||||
p.check()
|
p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal)
|
||||||
currencysMeta := this.GetByNetId(netId)
|
p.check()
|
||||||
if currencysMeta == nil {
|
currencysMeta := this.GetByNetId(netId)
|
||||||
currencysMeta = new(q5.ConcurrentMap[string, *Currency])
|
if currencysMeta == nil {
|
||||||
this.netIdHash.Store(netId, currencysMeta)
|
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