Commit 9a31b596 authored by mdj33's avatar mdj33 Committed by vipwzw

add fork to para filter

parent a2362420
...@@ -224,15 +224,19 @@ func hasCommited(addrs []string, addr string) (bool, int) { ...@@ -224,15 +224,19 @@ func hasCommited(addrs []string, addr string) (bool, int) {
return false, 0 return false, 0
} }
func getDappForkHeight(fork string) int64 { func getDappForkHeight(forkKey string) int64 {
var forkHeight int64 var forkHeight int64
if types.IsPara() { if types.IsPara() {
forkHeight = types.Conf("config.consensus.sub.para").GInt("MainForkParacrossCommitTx") key := forkKey
if forkKey == pt.ForkCommitTx{
key = "MainForkParacrossCommitTx"
}
forkHeight = types.Conf("config.consensus.sub.para").GInt(key)
if forkHeight <= 0 { if forkHeight <= 0 {
forkHeight = types.MaxHeight forkHeight = types.MaxHeight
} }
} else { } else {
forkHeight = types.GetDappFork(pt.ParaX, fork) forkHeight = types.GetDappFork(pt.ParaX, forkKey)
} }
return forkHeight return forkHeight
} }
......
...@@ -46,7 +46,7 @@ func checkReceiptExecOk(receipt *types.ReceiptData) bool { ...@@ -46,7 +46,7 @@ func checkReceiptExecOk(receipt *types.ReceiptData) bool {
// 1, 主链+平行链 user.p.xx.paracross 交易组 混合跨链资产转移 paracross主链执行成功 // 1, 主链+平行链 user.p.xx.paracross 交易组 混合跨链资产转移 paracross主链执行成功
// 2, 平行链 user.p.xx.paracross + user.p.xx.other 混合平行链组合 paracross主链执行成功 // 2, 平行链 user.p.xx.paracross + user.p.xx.other 混合平行链组合 paracross主链执行成功
// 3, 平行链 user.p.xx.other 交易组 混合平行链组合 other主链pack // 3, 平行链 user.p.xx.other 交易组 混合平行链组合 other主链pack
func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDetail, index int) ([]*types.Transaction, int) { func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDetail, index int,forkHeight int64) ([]*types.Transaction, int) {
var headIdx int var headIdx int
for i := index; i >= 0; i-- { for i := index; i >= 0; i-- {
...@@ -58,6 +58,12 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet ...@@ -58,6 +58,12 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet
endIdx := headIdx + int(tx.GroupCount) endIdx := headIdx + int(tx.GroupCount)
for i := headIdx; i < endIdx; i++ { for i := headIdx; i < endIdx; i++ {
if types.IsPara() && main.Block.Height < forkHeight {
if types.IsMyParaExecName(string(main.Block.Txs[i].Execer)) {
continue
}
}
if !checkReceiptExecOk(main.Receipts[i]) { if !checkReceiptExecOk(main.Receipts[i]) {
return nil, endIdx return nil, endIdx
} }
...@@ -69,18 +75,21 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet ...@@ -69,18 +75,21 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet
//FilterTxsForPara include some main tx in tx group before ForkParacrossCommitTx //FilterTxsForPara include some main tx in tx group before ForkParacrossCommitTx
func FilterTxsForPara(title string, main *types.BlockDetail) []*types.Transaction { func FilterTxsForPara(title string, main *types.BlockDetail) []*types.Transaction {
var txs []*types.Transaction var txs []*types.Transaction
forkHeight := getDappForkHeight(pt.ForkCommitTx)
for i := 0; i < len(main.Block.Txs); i++ { for i := 0; i < len(main.Block.Txs); i++ {
tx := main.Block.Txs[i] tx := main.Block.Txs[i]
if types.IsSpecificParaExecName(title, string(tx.Execer)) { if types.IsSpecificParaExecName(title, string(tx.Execer)) {
if tx.GroupCount >= 2 { if tx.GroupCount >= 2 {
mainTxs, endIdx := filterParaTxGroup(title, tx, main, i) mainTxs, endIdx := filterParaTxGroup(title, tx, main, i,forkHeight)
txs = append(txs, mainTxs...) txs = append(txs, mainTxs...)
i = endIdx - 1 i = endIdx - 1
continue continue
} }
//单独的paracross跨链合约 如果主链执行失败也要排除 //单独的paracross tx 如果主链执行失败也要排除
if bytes.HasSuffix(tx.Execer, []byte(pt.ParaX)) && !checkReceiptExecOk(main.Receipts[i]) { if main.Block.Height >= forkHeight{
continue if types.IsMyParaExecName(string(tx.Execer)) && !checkReceiptExecOk(main.Receipts[i]) {
continue
}
} }
txs = append(txs, tx) txs = append(txs, tx)
......
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