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