From 9968b41d28e6e581b52f701291c69e95c59af86a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 22 Jun 2024 21:25:54 +0800 Subject: [PATCH] 1 --- server/backtask/mt/Contract.go | 21 +++++++++++++++++++-- third_party/q5 | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/server/backtask/mt/Contract.go b/server/backtask/mt/Contract.go index 48ea85e1..6996e046 100644 --- a/server/backtask/mt/Contract.go +++ b/server/backtask/mt/Contract.go @@ -16,6 +16,7 @@ type Contract struct { type ContractTable struct { netIdNameHash *q5.ConcurrentMap[string, *Contract] + netIdAddressHash *q5.ConcurrentMap[string, *Contract] } func (this *Contract) GetName() string { @@ -32,6 +33,7 @@ func (this *ContractTable) IsNoLoad() bool { func (this *ContractTable) Load() { this.netIdNameHash = new(q5.ConcurrentMap[string, *Contract]) + this.netIdAddressHash = new(q5.ConcurrentMap[string, *Contract]) nets := []interface{}{} { if f, err := os.Open("../config/nets.json"); err == nil { @@ -60,8 +62,14 @@ func (this *ContractTable) Load() { p := new(Contract) p.name = q5.SafeToString(val2.Name) p.address = strings.ToLower(q5.SafeToString(val2.Address)) - key := fmt.Sprintf("%d_%s", netId, p.name) - this.netIdNameHash.Store(key, p) + { + key := fmt.Sprintf("%d_%s", netId, p.name) + this.netIdNameHash.Store(key, p) + } + { + key := fmt.Sprintf("%d_%s", netId, p.address) + this.netIdAddressHash.Store(key, p) + } } } else { panic(fmt.Sprintf("load metafile error %s %s", "contract.json", err)) @@ -90,3 +98,12 @@ func (this *ContractTable) GetByNetIdName(netId int32, name string) *Contract { return nil } } + +func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contract { + key := fmt.Sprintf("%d_%s", netId, address) + if v, ok := this.netIdAddressHash.Load(key); ok { + return *v + } else { + return nil + } +} diff --git a/third_party/q5 b/third_party/q5 index a26208f7..763b161e 160000 --- a/third_party/q5 +++ b/third_party/q5 @@ -1 +1 @@ -Subproject commit a26208f76e262b5c4db46c3034cf55cb4647ae2f +Subproject commit 763b161e26e76046ee7614852ccdd4a360f15237