This commit is contained in:
aozhiwei 2024-07-23 14:30:50 +08:00
parent 03e0047b60
commit ecf9029b97

View File

@ -2,8 +2,9 @@ package task
import ( import (
"f5" "f5"
"main/constant" "mt"
"jccommon" "jccommon"
"main/constant"
"fmt" "fmt"
) )
@ -25,28 +26,41 @@ type unLockReturnValues struct {
} }
func (this* chainActivity) init() { func (this* chainActivity) init() {
go this.process() mt.Table.Contract.Traverse(func (ele *mt.Contract) bool {
if ele.GetName() == jccommon.CONTRACT_NAME_NFTLock {
go this.processLockAndUnLockEvent(ele.GetNetId(), ele.GetAddress())
}
return true
})
} }
func (this* chainActivity) unInit() { func (this* chainActivity) unInit() {
} }
func (this* chainActivity) process() { func (this* chainActivity) processLockAndUnLockEvent(netId int32, lockContractAddress string) {
f5.GetGoStyleDb().IncrementLoad( f5.GetGoStyleDb().IncrementLoad(
constant.BCNFT_DB, constant.BCNFT_DB,
"chainActivity", "chainActivity",
"t_blockchain_event", "t_blockchain_event",
0,
func (lastIdx int64, maxIdx int64) (string, []string) { func (lastIdx int64, maxIdx int64) (string, []string) {
sql := fmt.Sprintf(` sql := fmt.Sprintf(`
SELECT * FROM t_blockchain_event SELECT * FROM t_blockchain_event
WHERE idx > %d AND idx <= %d AND item_id = 0 AND token_type <> %d ORDER BY idx LIMIT 1000 WHERE idx > %d AND idx <= %d AND netId = %d AND contract_address = ? AND event_name IN (?, ?)
ORDER BY idx LIMIT 1000
`, `,
lastIdx, lastIdx,
maxIdx, maxIdx,
jccommon.NFT_TYPE_FOUNDER_TAG, netId)
) params := []string{
params := []string{} lockContractAddress,
"Lock",
"UnLock",
}
return sql, params return sql, params
},
func (newLastIdx int64) {
}, },
this.repairNft) this.repairNft)
} }