1
This commit is contained in:
parent
b32267d897
commit
21c247106c
@ -318,6 +318,7 @@ func (this *MailApi) DelMail(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (this *MailApi) CheckAttachment(list []common.Attachment, c *gin.Context) bool {
|
||||
return true
|
||||
if data, err := json.Marshal(list); err != nil || len(data) > 0xFF {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 2,
|
||||
|
@ -30,7 +30,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
}{}
|
||||
|
||||
currencysMeta := mt.Table.Currency.GetByNetId(netId)
|
||||
if len(currencysMeta) <= 0 {
|
||||
if currencysMeta == nil {
|
||||
f5.RspErr(c, 2, "server internal error")
|
||||
return
|
||||
}
|
||||
@ -57,11 +57,14 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) {
|
||||
Name string `json:"name"`
|
||||
Address string `json:"address"`
|
||||
}{}
|
||||
for _, currency := range currencysMeta {
|
||||
p := q5.NewSliceElement(¤cyList)
|
||||
p.Name = currency.GetCurrencyName()
|
||||
p.Address = currency.GetContract().GetAddress()
|
||||
}
|
||||
currencysMeta.Range(
|
||||
func (key string, val *mt.Currency) bool {
|
||||
currency := val
|
||||
p := q5.NewSliceElement(¤cyList)
|
||||
p.Name = currency.GetCurrencyName()
|
||||
p.Address = currency.GetContract().GetAddress()
|
||||
return true
|
||||
})
|
||||
tmpmap["currency_list"] = currencyList
|
||||
|
||||
rspObj.Rows = append(rspObj.Rows, tmpmap)
|
||||
|
@ -16,7 +16,7 @@ type Currency struct {
|
||||
|
||||
type CurrencyTable struct {
|
||||
f5.CustomMetaTable
|
||||
netIdHash *q5.ConcurrentMap[int32, *Currency]
|
||||
netIdHash *q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]]
|
||||
}
|
||||
|
||||
func (this *Currency) init(currencyName string, exchangeRate int64, currencyDecimal int64) {
|
||||
@ -60,11 +60,11 @@ func (this *Currency) check() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *CurrencyTable) GetByNetId(netId int32) []*Currency {
|
||||
func (this *CurrencyTable) GetByNetId(netId int32) *q5.ConcurrentMap[string, *Currency] {
|
||||
if v, ok := this.netIdHash.Load(netId); ok {
|
||||
return []*Currency{*v}
|
||||
return *v
|
||||
} else {
|
||||
return []*Currency{}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ func (this *CurrencyTable) GetByNetIdAddress(netId int32, currencyAddress string
|
||||
}
|
||||
|
||||
func (this *CurrencyTable) Load() {
|
||||
this.netIdHash = new(q5.ConcurrentMap[int32, *Currency])
|
||||
this.netIdHash = new(q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]])
|
||||
nets := []int32{}
|
||||
{
|
||||
if jsonStr, err := f5.ReadJsonFile("../config/nets.json"); err == nil {
|
||||
@ -101,7 +101,7 @@ func (this *CurrencyTable) Load() {
|
||||
p := new(Currency)
|
||||
p.init(currencyCfg.CurrencyName, currencyCfg.ExchangeRate, currencyCfg.CurrencyDecimal)
|
||||
p.check()
|
||||
this.netIdHash.Store(netId, p)
|
||||
//this.netIdHash.Store(netId, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,20 +109,24 @@ func (this *CurrencyTable) Load() {
|
||||
|
||||
func (this *CurrencyTable) PostInit1() {
|
||||
this.netIdHash.Range(
|
||||
func (key int32, val *Currency) bool {
|
||||
func (key int32, val *q5.ConcurrentMap[string, *Currency]) bool {
|
||||
netId := key
|
||||
currencyMeta := val
|
||||
Table.Recharge.Traverse(func(ele *Recharge) bool {
|
||||
if int64(ele.GetPrice()) * currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) {
|
||||
panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId()))
|
||||
}
|
||||
return true
|
||||
})
|
||||
contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName())
|
||||
if contractMeta == nil {
|
||||
panic(fmt.Sprintf("currency contract not found"))
|
||||
}
|
||||
currencyMeta.contract = contractMeta
|
||||
val.Range(
|
||||
func (key2 string, val2 *Currency) bool {
|
||||
currencyMeta := val2
|
||||
Table.Recharge.Traverse(func(ele *Recharge) bool {
|
||||
if int64(ele.GetPrice()) * currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) {
|
||||
panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId()))
|
||||
}
|
||||
return true
|
||||
})
|
||||
contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName())
|
||||
if contractMeta == nil {
|
||||
panic(fmt.Sprintf("currency contract not found"))
|
||||
}
|
||||
currencyMeta.contract = contractMeta
|
||||
return true
|
||||
});
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user