1
This commit is contained in:
parent
f2032d7b42
commit
6c56a720c5
@ -7,6 +7,7 @@ import (
|
|||||||
"jccommon"
|
"jccommon"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type chainActivity struct {
|
type chainActivity struct {
|
||||||
@ -23,7 +24,7 @@ type lockReturnValues struct {
|
|||||||
type unLockReturnValues struct {
|
type unLockReturnValues struct {
|
||||||
Nft string `json:"nft"`
|
Nft string `json:"nft"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
NftList []interface{} `json:"nftList"`
|
NftList [][]interface{} `json:"nftList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* chainActivity) init() {
|
func (this* chainActivity) init() {
|
||||||
@ -63,13 +64,100 @@ ORDER BY idx LIMIT 10
|
|||||||
func (newLastIdx int64) {
|
func (newLastIdx int64) {
|
||||||
|
|
||||||
},
|
},
|
||||||
this.repairNft)
|
this.saveToDb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* chainActivity) repairNft(ds *f5.DataSet) bool {
|
func (this* chainActivity) saveToDb(ds *f5.DataSet) bool {
|
||||||
f5.GetSysLog().Info("load lock/unlock idx:%s contract_name:%s event_name:%s",
|
f5.GetSysLog().Info("load lock/unlock idx:%s contract_name:%s event_name:%s",
|
||||||
ds.GetByName("idx"),
|
ds.GetByName("idx"),
|
||||||
ds.GetByName("contract_name"),
|
ds.GetByName("contract_name"),
|
||||||
ds.GetByName("event_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")
|
||||||
|
if eventName == "Lock" {
|
||||||
|
p := new(lockReturnValues)
|
||||||
|
if q5.DecodeJson(returnValues, p) == nil {
|
||||||
|
for _, tokenId := range p.TokenIds {
|
||||||
|
f5.GetGoStyleDb().Upsert(
|
||||||
|
constant.BCEVENT_DB,
|
||||||
|
"t_chain_activity",
|
||||||
|
[][]string{
|
||||||
|
{"txhash", txhash},
|
||||||
|
{"log_index", logIndex},
|
||||||
|
{"net_id", netId},
|
||||||
|
{"event_name", eventName},
|
||||||
|
{"contract_address", contractAddress},
|
||||||
|
{"token_id", tokenId},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"txhash", txhash},
|
||||||
|
{"log_index", logIndex},
|
||||||
|
{"net_id", netId},
|
||||||
|
{"event_name", eventName},
|
||||||
|
{"contract_address", contractAddress},
|
||||||
|
{"nft_contract_address", strings.ToLower(p.Nft)},
|
||||||
|
{"token_id", tokenId},
|
||||||
|
{"src_idx", idx},
|
||||||
|
{"sender_address", strings.ToLower(p.Sender)},
|
||||||
|
{"to_address", strings.ToLower(p.To)},
|
||||||
|
{"createtime", createTime},
|
||||||
|
{"modifytime", modifyTime},
|
||||||
|
},
|
||||||
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if eventName == "UnLock" {
|
||||||
|
p := new(unLockReturnValues)
|
||||||
|
if q5.DecodeJson(returnValues, p) == nil {
|
||||||
|
for _, nft := range p.NftList {
|
||||||
|
tokenId := q5.SafeToString(nft[0])
|
||||||
|
sender := q5.SafeToString(nft[1])
|
||||||
|
to := q5.SafeToString(nft[1])
|
||||||
|
f5.GetGoStyleDb().Upsert(
|
||||||
|
constant.BCEVENT_DB,
|
||||||
|
"t_chain_activity",
|
||||||
|
[][]string{
|
||||||
|
{"txhash", txhash},
|
||||||
|
{"log_index", logIndex},
|
||||||
|
{"net_id", netId},
|
||||||
|
{"event_name", eventName},
|
||||||
|
{"contract_address", contractAddress},
|
||||||
|
{"token_id", tokenId},
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
},
|
||||||
|
[][]string{
|
||||||
|
{"txhash", txhash},
|
||||||
|
{"log_index", logIndex},
|
||||||
|
{"net_id", netId},
|
||||||
|
{"event_name", eventName},
|
||||||
|
{"contract_address", contractAddress},
|
||||||
|
{"nft_contract_address", strings.ToLower(p.Nft)},
|
||||||
|
{"token_id", tokenId},
|
||||||
|
{"src_idx", idx},
|
||||||
|
{"sender_address", strings.ToLower(sender)},
|
||||||
|
{"to_address", strings.ToLower(to)},
|
||||||
|
{"createtime", createTime},
|
||||||
|
{"modifytime", modifyTime},
|
||||||
|
},
|
||||||
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
panic(fmt.Sprintf("chainActivity unknow event_name %s", eventName))
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user