This commit is contained in:
aozhiwei 2024-09-03 11:40:20 +08:00
parent 3e5fccd132
commit 25ff66cd9c
3 changed files with 90 additions and 10 deletions

View File

@ -108,11 +108,16 @@ type UserStackingPo struct {
Contracts []*ContractStackingPo `json:"contracts"`
}
type ContractStackingCecPo struct {
NetId int32 `json:"net_id"`
ContractAddress string `json:"contract_address"`
TokenType int32 `json:"token_type"`
Nfts []*NftStackingPo `json:"nfts"`
type ContractStakeCecPo struct {
Account string `json:"account"`
Token string `json:"token"`
Amount string `json:"amount"`
}
type ContractUnstakeCecPo struct {
Account string `json:"account"`
Token string `json:"token"`
Amount string `json:"amount"`
}
type NftIdentity struct {
@ -148,8 +153,13 @@ func NewContractStackingPo() *ContractStackingPo {
return p
}
func NewContractStackingCecPo() *ContractStackingCecPo {
p := new(ContractStackingCecPo)
func NewContractStakeCecPo() *ContractStakeCecPo {
p := new(ContractStakeCecPo)
return p
}
func NewContractUnstakeCecPo() *ContractUnstakeCecPo {
p := new(ContractUnstakeCecPo)
return p
}

View File

@ -7,6 +7,12 @@ import (
"main/constant"
"jccommon"
"fmt"
"strings"
)
const (
EVENT_NAME_STAKE_CEC = "StakeCec"
EVENT_NAME_UNSTAKE_CEC = "UnstakeCec"
)
type stackingCec struct {
@ -44,8 +50,8 @@ ORDER BY idx LIMIT 1000
netId)
params := []string{
contractAddress,
"StakeCec",
"UnstakeCec",
EVENT_NAME_STAKE_CEC,
EVENT_NAME_UNSTAKE_CEC,
}
return sql, params
},
@ -59,5 +65,69 @@ ORDER BY idx LIMIT 1000
}
func (this *stackingCec) saveToDb(ds *f5.DataSet) bool {
f5.GetSysLog().Info("load stackingCec idx:%s net_id:%s contract_name:%s event_name:%s",
ds.GetByName("net_id"),
ds.GetByName("idx"),
ds.GetByName("contract_name"),
ds.GetByName("event_name"))
idx := ds.GetByName("idx")
txhash := ds.GetByName("txhash")
logIndex := ds.GetByName("log_index")
netId := ds.GetByName("net_id")
eventName := ds.GetByName("event_name")
contractAddress := ds.GetByName("contract_address")
returnValues := ds.GetByName("return_values")
createTime := ds.GetByName("createtime")
modifyTime := ds.GetByName("modifytime")
accountAddress := ""
token := ""
amount := ""
decodeJsonOk := false
p := new(itemSoldOut)
if q5.DecodeJson(returnValues, p) == nil {
decodeJsonOk = true
var dbErr error
f5.GetGoStyleDb().Upsert(
constant.BCEVENT_DB,
"t_staking_cec_record",
[][]string{
{"txhash", txhash},
{"log_index", logIndex},
{"net_id", netId},
{"contract_address", contractAddress},
},
[][]string{},
[][]string{
{"txhash", txhash},
{"log_index", logIndex},
{"net_id", netId},
{"contract_address", strings.ToLower(contractAddress)},
{"src_idx", idx},
{"event_name", eventName},
{"account_address", accountAddress},
{"token_address", token},
{"amount", amount},
{"createtime", createTime},
{"modifytime", modifyTime},
},
func (err error, lastInsertId int64, rowsAffected int64) {
dbErr = err
})
if dbErr != nil {
return false
}
}
if !decodeJsonOk {
jccommon.AddDbLog(constant.BCEVENT_DB, "stackingCec", "decodeJsonError",
map[string]string{
"param1": txhash,
"param2": netId,
"param3": eventName,
"param4": idx,
"param5": contractAddress,
})
}
return true
}

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit e6b6ca73a1ad43c8950d037e9ac5de08d8e05f5c
Subproject commit f3c6bd34599966b9d3724d3eb7f0703cdf0383bd