1
This commit is contained in:
parent
a260dc9d4f
commit
22d8936b85
@ -114,6 +114,16 @@ type ContractStakeAndUnstakeCecPo struct {
|
|||||||
Amount string `json:"amount"`
|
Amount string `json:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Erc20TransferPo struct {
|
||||||
|
From string `json:"from"`
|
||||||
|
To string `json:"to"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BlockDataPo struct {
|
||||||
|
TimeStamp string `json:"timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
type NftIdentity struct {
|
type NftIdentity struct {
|
||||||
NetId int32
|
NetId int32
|
||||||
ContractAddress string
|
ContractAddress string
|
||||||
@ -157,3 +167,13 @@ func NewUserStackingPo() *UserStackingPo {
|
|||||||
p.Contracts = []*ContractStackingPo{}
|
p.Contracts = []*ContractStackingPo{}
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewErc20TransferPo() *Erc20TransferPo {
|
||||||
|
p := new(Erc20TransferPo)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBlockDataPo() *BlockDataPo {
|
||||||
|
p := new(BlockDataPo)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
@ -30,6 +30,9 @@ func (this *vip) Add(accountAddress string, val string, idx int64, valField stri
|
|||||||
}
|
}
|
||||||
nowTime := f5.GetApp().GetRealSeconds()
|
nowTime := f5.GetApp().GetRealSeconds()
|
||||||
if ds.Next() {
|
if ds.Next() {
|
||||||
|
if q5.ToInt64(ds.GetByName(idxField)) <= idx {
|
||||||
|
return true
|
||||||
|
}
|
||||||
bnVal, ok := new(big.Int).SetString(val, 10)
|
bnVal, ok := new(big.Int).SetString(val, 10)
|
||||||
if !ok {
|
if !ok {
|
||||||
f5.GetSysLog().Info("vip.Add val to bigint error:%s", val)
|
f5.GetSysLog().Info("vip.Add val to bigint error:%s", val)
|
||||||
@ -71,5 +74,5 @@ func (this *vip) Add(accountAddress string, val string, idx int64, valField stri
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"jccommon"
|
"jccommon"
|
||||||
"main/mt"
|
"main/mt"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
|
"main/service"
|
||||||
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,5 +60,62 @@ ORDER BY idx LIMIT 1000
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this* esCecTransfer) saveToDb(ds *f5.DataSet) bool {
|
func (this* esCecTransfer) saveToDb(ds *f5.DataSet) bool {
|
||||||
|
ro := jccommon.NewErc20TransferPo()
|
||||||
|
bo := jccommon.NewBlockDataPo()
|
||||||
|
if err := q5.DecodeJson(ds.GetByName("return_values"), ro); err != nil {
|
||||||
|
f5.GetSysLog().Warning("esCecTransfer.parser.return_values error:%s", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err := q5.DecodeJson(ds.GetByName("block_data"), bo); err != nil {
|
||||||
|
f5.GetSysLog().Warning("esCecTransfer.parser.block_data error:%s", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
idx := q5.ToInt64(ds.GetByName("idx"))
|
||||||
|
if !q5.IsWeb3ZeroAddress(ro.To) {
|
||||||
|
if !service.Vip.Add(ro.To, ro.Value, idx, "escec_balance", "escec_transfer_last_src_idx") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !q5.IsWeb3ZeroAddress(ro.From) {
|
||||||
|
if !service.Vip.Add(ro.From, "-" + ro.Value, idx, "escec_balance", "escec_transfer_last_src_idx") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
txhash := ds.GetByName("txhash")
|
||||||
|
logIndex := ds.GetByName("log_index")
|
||||||
|
netId := ds.GetByName("net_id")
|
||||||
|
eventName := ds.GetByName("event_name")
|
||||||
|
contractAddress := ds.GetByName("contract_address")
|
||||||
|
createTime := ds.GetByName("createtime")
|
||||||
|
modifyTime := ds.GetByName("modifytime")
|
||||||
|
|
||||||
|
if err, _, _ := f5.GetGoStyleDb().NewUpsert(
|
||||||
|
constant.BCEVENT_DB,
|
||||||
|
"t_escec_transfer",
|
||||||
|
[][]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", q5.ToString(idx)},
|
||||||
|
{"event_name", eventName},
|
||||||
|
{"chain_timestamp", q5.ToString(bo.TimeStamp)},
|
||||||
|
{"from_address", strings.ToLower(ro.From)},
|
||||||
|
{"to_address", strings.ToLower(ro.To)},
|
||||||
|
{"value", ro.Value},
|
||||||
|
{"createtime", createTime},
|
||||||
|
{"modifytime", modifyTime},
|
||||||
|
}); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user