Commit 08d6555a authored by hezhengjun's avatar hezhengjun Committed by 33cn

filter old push

parent 4b977fc8
...@@ -106,17 +106,11 @@ func (syncTx *EVMTxLogs) SaveAndSyncTxs2Relayer() { ...@@ -106,17 +106,11 @@ func (syncTx *EVMTxLogs) SaveAndSyncTxs2Relayer() {
// 处理输入流程 // 处理输入流程
func (syncTx *EVMTxLogs) dealEVMTxLogs(evmTxLogsInBlks *types.EVMTxLogsInBlks) { func (syncTx *EVMTxLogs) dealEVMTxLogs(evmTxLogsInBlks *types.EVMTxLogsInBlks) {
count, start, evmTxLogsParsed, err := parseEvmTxLogsInBlks(evmTxLogsInBlks) count, start, evmTxLogsParsed, err := parseEvmTxLogsInBlks(evmTxLogsInBlks, syncTx.seqNum)
if err != nil { if err != nil {
resultCh <- err resultCh <- err
} }
//正常情况下,本次开始的的seq不能小于上次结束的seq
if start < syncTx.seqNum {
log.Error("dealEVMTxLogs err: the tx and receipt pushed is old", "start", start, "current_seq", syncTx.seqNum)
resultCh <- errors.New("The tx and receipt pushed is old")
return
}
var height int64 var height int64
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
txsPerBlock := evmTxLogsParsed[i] txsPerBlock := evmTxLogsParsed[i]
...@@ -134,10 +128,9 @@ func (syncTx *EVMTxLogs) dealEVMTxLogs(evmTxLogsInBlks *types.EVMTxLogsInBlks) { ...@@ -134,10 +128,9 @@ func (syncTx *EVMTxLogs) dealEVMTxLogs(evmTxLogsInBlks *types.EVMTxLogsInBlks) {
syncTx.setBlockHeight(height) syncTx.setBlockHeight(height)
} }
} }
//syncTx.syncReceiptChan <- height
//发送回复,确认接收成功 //发送回复,确认接收成功
resultCh <- nil resultCh <- nil
log.Debug("dealEVMTxLogs", "seqStart", start, "count", count, "maxBlockHeight", height) log.Debug("dealEVMTxLogs", "seqStart", start, "count", count, "maxBlockHeight", height, "syncTx.seqNum", syncTx.seqNum)
} }
func (syncTx *EVMTxLogs) loadBlockLastSequence() (int64, error) { func (syncTx *EVMTxLogs) loadBlockLastSequence() (int64, error) {
...@@ -213,7 +206,7 @@ func (syncTx *EVMTxLogs) delTxReceipts(height int64) { ...@@ -213,7 +206,7 @@ func (syncTx *EVMTxLogs) delTxReceipts(height int64) {
} }
// 检查输入是否有问题, 并解析输入 // 检查输入是否有问题, 并解析输入
func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks) (count int, start int64, txsWithReceipt []*types.EVMTxLogPerBlk, err error) { func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks, seqNumLast int64) (count int, start int64, txsWithReceipt []*types.EVMTxLogPerBlk, err error) {
count = len(evmTxLogs.Logs4EVMPerBlk) count = len(evmTxLogs.Logs4EVMPerBlk)
txsWithReceipt = make([]*types.EVMTxLogPerBlk, 0) txsWithReceipt = make([]*types.EVMTxLogPerBlk, 0)
start = math.MaxInt64 start = math.MaxInt64
...@@ -223,6 +216,12 @@ func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks) (count int, start in ...@@ -223,6 +216,12 @@ func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks) (count int, start in
"height", evmTxLogs.Logs4EVMPerBlk[i].Height, "seqOp", evmTxLogs.Logs4EVMPerBlk[i].AddDelType) "height", evmTxLogs.Logs4EVMPerBlk[i].Height, "seqOp", evmTxLogs.Logs4EVMPerBlk[i].AddDelType)
continue continue
} }
//过滤掉老的信息, 正常情况下,本次开始的的seq不能小于上次结束的seq
if seqNumLast >= evmTxLogs.Logs4EVMPerBlk[i].SeqNum {
log.Error("parseEvmTxLogsInBlks err: the tx and receipt pushed is old", "seqNumLast", seqNumLast,
"evmTxLogs.Logs4EVMPerBlk[i].SeqNum", evmTxLogs.Logs4EVMPerBlk[i].SeqNum, "i", i)
continue
}
txsWithReceipt = append(txsWithReceipt, evmTxLogs.Logs4EVMPerBlk[i]) txsWithReceipt = append(txsWithReceipt, evmTxLogs.Logs4EVMPerBlk[i])
if evmTxLogs.Logs4EVMPerBlk[i].SeqNum < start { if evmTxLogs.Logs4EVMPerBlk[i].SeqNum < start {
start = evmTxLogs.Logs4EVMPerBlk[i].SeqNum start = evmTxLogs.Logs4EVMPerBlk[i].SeqNum
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment