1
This commit is contained in:
parent
083bfe6060
commit
35ba92e955
@ -1,5 +1,8 @@
|
|||||||
package jccommon
|
package jccommon
|
||||||
|
|
||||||
|
import (
|
||||||
|
)
|
||||||
|
|
||||||
func AddDbLog(dataSource string, logType int32, subType int32,
|
func AddDbLog(dataSource string, logType int32, subType int32,
|
||||||
params map[string]string) error {
|
params map[string]string) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DBPARAM_CHAIN_ACTIVITY_PRE = "chain_activity"
|
||||||
|
|
||||||
type chainActivity struct {
|
type chainActivity struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -40,31 +42,36 @@ func (this* chainActivity) unInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this* chainActivity) processLockAndUnLockEvent(netId int32, lockContractAddress string) {
|
func (this* chainActivity) processLockAndUnLockEvent(netId int32, lockContractAddress string) {
|
||||||
f5.GetGoStyleDb().IncrementLoad(
|
key := fmt.Sprintf("chainActivity.lastIdx.%d.%s", netId, lockContractAddress)
|
||||||
constant.BCEVENT_DB,
|
if dbLastIdxStr, err := jccommon.GetDbParam(constant.BCEVENT_DB, key); err == nil {
|
||||||
"chainActivity." + q5.ToString(netId) + "." + lockContractAddress,
|
f5.GetGoStyleDb().IncrementLoad(
|
||||||
"t_blockchain_event",
|
constant.BCEVENT_DB,
|
||||||
0,
|
"chainActivity." + q5.ToString(netId) + "." + lockContractAddress,
|
||||||
func (lastIdx int64, maxIdx int64) (string, []string) {
|
"t_blockchain_event",
|
||||||
sql := fmt.Sprintf(`
|
q5.ToInt64(dbLastIdxStr),
|
||||||
|
func (lastIdx int64, maxIdx int64) (string, []string) {
|
||||||
|
sql := fmt.Sprintf(`
|
||||||
SELECT * FROM t_blockchain_event
|
SELECT * FROM t_blockchain_event
|
||||||
WHERE idx > %d AND idx <= %d AND net_id = %d AND contract_address = ? AND event_name IN (?, ?)
|
WHERE idx > %d AND idx <= %d AND net_id = %d AND contract_address = ? AND event_name IN (?, ?)
|
||||||
ORDER BY idx LIMIT 10
|
ORDER BY idx LIMIT 10
|
||||||
`,
|
`,
|
||||||
lastIdx,
|
lastIdx,
|
||||||
maxIdx,
|
maxIdx,
|
||||||
netId)
|
netId)
|
||||||
params := []string{
|
params := []string{
|
||||||
lockContractAddress,
|
lockContractAddress,
|
||||||
"Lock",
|
"Lock",
|
||||||
"UnLock",
|
"UnLock",
|
||||||
}
|
}
|
||||||
return sql, params
|
return sql, params
|
||||||
},
|
},
|
||||||
func (newLastIdx int64) {
|
func (newLastIdx int64) {
|
||||||
|
jccommon.SaveDbParam(constant.BCEVENT_DB, key, q5.ToString(newLastIdx))
|
||||||
},
|
},
|
||||||
this.saveToDb)
|
this.saveToDb)
|
||||||
|
} else {
|
||||||
|
panic(fmt.Sprintf("chainActivity.processLockAndUnLockEvent getDBParam error %s", err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* chainActivity) saveToDb(ds *f5.DataSet) bool {
|
func (this* chainActivity) saveToDb(ds *f5.DataSet) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user