This commit is contained in:
aozhiwei 2024-07-20 17:52:23 +08:00
parent 8ad8174bd1
commit abdb4cd477
2 changed files with 60 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
)
type Contract struct {
netId int32
name string
address string
}
@ -19,6 +20,10 @@ type ContractTable struct {
netIdAddressHash *q5.ConcurrentMap[string, *Contract]
}
func (this *Contract) GetNetId() int32 {
return this.netId
}
func (this *Contract) GetName() string {
return this.name
}
@ -60,6 +65,7 @@ func (this *ContractTable) Load() {
}
for _, val2 := range contracts {
p := new(Contract)
p.netId = netId
p.name = q5.SafeToString(val2.Name)
p.address = strings.ToLower(q5.SafeToString(val2.Address))
{
@ -107,3 +113,9 @@ func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contr
return nil
}
}
func (this *ContractTable) Traverse(cb func(*Contract) bool) {
this.netIdNameHash.Range(func (k string, v *Contract) bool {
return cb(v)
})
}

View File

@ -3,7 +3,10 @@ package task
import (
"q5"
"f5"
"jccommon"
"main/constant"
"time"
"fmt"
)
type contribution struct {
@ -18,6 +21,47 @@ func (this* contribution) unInit() {
}
func (this* contribution) stat(statTime int64, nowTime int64) {
for true {
if this.internalStat(statTime, nowTime) {
return
}
time.Sleep(time.Second * 60)
}
}
func (this* contribution) internalStat(statTime int64, nowTime int64) bool {
statDaySeconds := q5.GetDaySeconds(statTime, 0)
if statDaySeconds <= 0 {
panic("task.contribution.statDayseconds error")
return true
}
if err, ok := this.isStatEd(statDaySeconds); err != nil {
return false
} else {
if ok {
return true
}
}
{
sqlTpl := "SELECT * FROM t_nft WHERE idx > %d AND token_type <> ? AND "
params := []string{
q5.ToString(jccommon.NFT_TYPE_GOLD_BULLION),
}
f5.GetGoStyleDb().BatchLoad(
constant.BCNFT_DB,
func (lastIdx int64) string {
sql := fmt.Sprintf(sqlTpl, lastIdx)
return sql
},
params,
func () int64 {
return 0
},
func (ds *f5.DataSet) bool {
return true
})
}
return false
}
func (this* contribution) calc() {
@ -31,3 +75,7 @@ func (this* contribution) calc() {
time.Sleep(time.Second * time.Duration(sleepTime))
}
}
func (this* contribution) isStatEd(statDaySeconds int64) (error, bool) {
return nil, true
}