From 941814e687a080a7b703be520efdfa0dab6cfa26 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 17 Aug 2024 17:41:20 +0800 Subject: [PATCH] 1 --- server/marketserver/mt/Currency.go | 13 ++++++++++--- server/marketserver/mtb/mtb.auto_gen.go | 10 ++++++++++ server/marketserver/proto/mt.proto | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/server/marketserver/mt/Currency.go b/server/marketserver/mt/Currency.go index b165ee33..6bc7bcba 100644 --- a/server/marketserver/mt/Currency.go +++ b/server/marketserver/mt/Currency.go @@ -10,6 +10,7 @@ import ( type Currency struct { currencyName string + contractName string currencyDecimal int64 contract *Contract } @@ -19,8 +20,9 @@ type CurrencyTable struct { netIdHash *q5.ConcurrentMap[int32, *q5.ConcurrentMap[string, *Currency]] } -func (this *Currency) init(currencyName string, currencyDecimal int64) { +func (this *Currency) init(currencyName string, contractName string, currencyDecimal int64) { this.currencyName = currencyName + this.contractName = contractName this.currencyDecimal = currencyDecimal } @@ -28,6 +30,10 @@ func (this *Currency) GetCurrencyName() string { return this.currencyName } +func (this *Currency) GetContractName() string { + return this.contractName +} + func (this *Currency) GetCurrencyDecimal() int64 { return this.currencyDecimal } @@ -93,6 +99,7 @@ func (this *CurrencyTable) Load() { f5.GetSysLog().Info("load currency %s", fileName) currencysCfg := []struct { CurrencyName string `json:"currency_name"` + ContractName string `json:"contract_name"` CurrencyDecimal int64 `json:"currency_decimal"` }{} if err := q5.DecodeJson(jsonStr, ¤cysCfg); err != nil { @@ -100,7 +107,7 @@ func (this *CurrencyTable) Load() { } for _, currencyCfg := range currencysCfg { p := new(Currency) - p.init(currencyCfg.CurrencyName, currencyCfg.CurrencyDecimal) + p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal) p.check() currencysMeta := this.GetByNetId(netId) if currencysMeta == nil { @@ -128,7 +135,7 @@ func (this *CurrencyTable) PostInit1() { } return true }) - contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetCurrencyName()) + contractMeta := Table.Contract.GetByNetIdName(netId, currencyMeta.GetContractName()) if contractMeta == nil { panic(fmt.Sprintf("currency contract not found")) } diff --git a/server/marketserver/mtb/mtb.auto_gen.go b/server/marketserver/mtb/mtb.auto_gen.go index cd7c8236..5039562a 100644 --- a/server/marketserver/mtb/mtb.auto_gen.go +++ b/server/marketserver/mtb/mtb.auto_gen.go @@ -75,6 +75,7 @@ type Config struct { type RechargeCurrency struct { currency_name string + contract_name string currency_decimal int64 _flags1_ uint64 @@ -396,6 +397,14 @@ func (this *RechargeCurrency) HasCurrencyName() bool { return (this._flags1_ & (uint64(1) << 1)) > 0 } +func (this *RechargeCurrency) GetContractName() string { + return this.contract_name +} + +func (this *RechargeCurrency) HasContractName() bool { + return (this._flags1_ & (uint64(1) << 2)) > 0 +} + func (this *RechargeCurrency) GetCurrencyDecimal() int64 { return this.currency_decimal } @@ -562,6 +571,7 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) { func (this *RechargeCurrency) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.currency_name, "currency_name", &this._flags1_, 1, kv) + f5.ReadMetaTableField(&this.contract_name, "contract_name", &this._flags1_, 2, kv) f5.ReadMetaTableField(&this.currency_decimal, "currency_decimal", &this._flags1_, 3, kv) } diff --git a/server/marketserver/proto/mt.proto b/server/marketserver/proto/mt.proto index 544e740e..6ab31cab 100644 --- a/server/marketserver/proto/mt.proto +++ b/server/marketserver/proto/mt.proto @@ -62,7 +62,7 @@ message Config message RechargeCurrency { optional string currency_name = 1; - //optional int64 exchange_rate = 2; + optional string contract_name = 2; optional int64 currency_decimal = 3; }