1
This commit is contained in:
parent
a7a0bab43c
commit
b659201260
@ -137,7 +137,7 @@ type VesterDepositPo struct {
|
||||
type VesterWithdrawPo struct {
|
||||
Account string `json:"account"`
|
||||
ClaimedAmount string `json:"claimedAmount"`
|
||||
Amount string `json:"amount"`
|
||||
Balance string `json:"balance"`
|
||||
}
|
||||
|
||||
type NftIdentity struct {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"main/constant"
|
||||
"jccommon"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const VESTER_DEPOSIT_EVENT_NAME = "Deposit"
|
||||
@ -70,5 +71,86 @@ ORDER BY idx LIMIT 1000
|
||||
}
|
||||
|
||||
func (this* vester) saveToDb(ds *f5.DataSet) bool {
|
||||
f5.GetSysLog().Info("load vester deposit/withdraw idx:%s contract_name:%s event_name:%s",
|
||||
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")
|
||||
|
||||
whereKv := [][]string{
|
||||
{"txhash", txhash},
|
||||
{"log_index", logIndex},
|
||||
{"net_id", netId},
|
||||
{"event_name", eventName},
|
||||
{"contract_address", contractAddress},
|
||||
}
|
||||
genInsertKv := func (extKv [][]string) [][]string {
|
||||
insertKv := [][]string{
|
||||
{"txhash", txhash},
|
||||
{"log_index", logIndex},
|
||||
{"net_id", netId},
|
||||
{"event_name", eventName},
|
||||
{"contract_address", strings.ToLower(contractAddress)},
|
||||
{"src_idx", idx},
|
||||
{"createtime", createTime},
|
||||
{"modifytime", modifyTime},
|
||||
}
|
||||
insertKv = append(insertKv, extKv...)
|
||||
return insertKv
|
||||
}
|
||||
|
||||
decodeJsonOk := false
|
||||
if eventName == VESTER_DEPOSIT_EVENT_NAME {
|
||||
p := new(jccommon.VesterDepositPo)
|
||||
if q5.DecodeJson(returnValues, p) == nil {
|
||||
decodeJsonOk = true
|
||||
f5.GetGoStyleDb().NewUpsert(
|
||||
constant.BCEVENT_DB,
|
||||
"t_vester_deposit_withdraw",
|
||||
whereKv,
|
||||
[][]string{},
|
||||
genInsertKv([][]string{
|
||||
{"account_address", p.Account},
|
||||
{"deposit_amount", p.Amount},
|
||||
}))
|
||||
}
|
||||
} else if eventName == VESTER_WITHDRAW_EVENT_NAME {
|
||||
p := new(jccommon.VesterWithdrawPo)
|
||||
if q5.DecodeJson(returnValues, p) == nil {
|
||||
decodeJsonOk = true
|
||||
f5.GetGoStyleDb().NewUpsert(
|
||||
constant.BCEVENT_DB,
|
||||
"t_vester_deposit_withdraw",
|
||||
whereKv,
|
||||
[][]string{},
|
||||
genInsertKv([][]string{
|
||||
{"account_address", p.Account},
|
||||
{"withdraw_clamied_amount", p.ClaimedAmount},
|
||||
{"withdraw_balance", p.Balance},
|
||||
}))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("vester unknow event_name %s", eventName))
|
||||
}
|
||||
|
||||
if !decodeJsonOk {
|
||||
jccommon.AddDbLog(constant.BCEVENT_DB, "vester.depositAndWithdraw", "decodeJsonError",
|
||||
map[string]string{
|
||||
"param1": txhash,
|
||||
"param2": netId,
|
||||
"param3": eventName,
|
||||
"param4": idx,
|
||||
"param5": contractAddress,
|
||||
})
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user