Unverified Commit 1fb4c5b2 authored by vipwzw's avatar vipwzw Committed by GitHub

Merge pull request #116 from mdj33/ISSUE114_para_filterTx

issue 114 filter tx with title
parents b5e1f9d7 71099b46
......@@ -251,7 +251,7 @@ func calcParaCrossTxGroup(tx *types.Transaction, main *types.BlockDetail, index
endIdx := headIdx + int(tx.GroupCount)
for i := headIdx; i < endIdx; i++ {
if types.IsParaExecName(string(main.Block.Txs[i].Execer)) {
if types.IsMyParaExecName(string(main.Block.Txs[i].Execer)) {
continue
}
if main.Receipts[i].Ty == types.ExecOk {
......@@ -272,7 +272,7 @@ func (client *client) FilterTxsForPara(main *types.BlockDetail) []*types.Transac
var txs []*types.Transaction
for i := 0; i < len(main.Block.Txs); i++ {
tx := main.Block.Txs[i]
if types.IsParaExecName(string(tx.Execer)) {
if types.IsMyParaExecName(string(tx.Execer)) {
if tx.GroupCount >= paraCrossTxCount {
mainTxs, endIdx := calcParaCrossTxGroup(tx, main, i)
txs = append(txs, mainTxs...)
......
......@@ -19,6 +19,7 @@ import (
var (
Amount = int64(1 * types.Coin)
Title = string("user.p.para.")
Title2 = string("user.p.test.")
)
func TestFilterTxsForPara(t *testing.T) {
......@@ -72,6 +73,10 @@ func TestFilterTxsForPara(t *testing.T) {
txGroupBC, err := createTxsGroup(txBC)
assert.Nil(t, err)
//single para tx
txD, err := createCrossParaTempTx("toB", 10)
assert.Nil(t, err)
txs := []*types.Transaction{tx0}
txs = append(txs, txGroup12...)
txs = append(txs, txGroup34...)
......@@ -79,6 +84,7 @@ func TestFilterTxsForPara(t *testing.T) {
txs = append(txs, txGroup78...)
txs = append(txs, tx9, txA)
txs = append(txs, txGroupBC...)
txs = append(txs, txD)
//for i, tx := range txs {
// t.Log("tx exec name", "i", i, "name", string(tx.Execer))
......@@ -101,8 +107,9 @@ func TestFilterTxsForPara(t *testing.T) {
recptA := &types.ReceiptData{Ty: types.ExecPack}
recptB := &types.ReceiptData{Ty: types.ExecPack}
recptC := &types.ReceiptData{Ty: types.ExecPack}
recptD := &types.ReceiptData{Ty: types.ExecPack}
receipts := []*types.ReceiptData{recpt0, recpt1, recpt2, recpt3, recpt4, recpt5,
recpt6, recpt7, recpt8, recpt9, recptA, recptB, recptC}
recpt6, recpt7, recpt8, recpt9, recptA, recptB, recptC, recptD}
block := &types.Block{Txs: txs}
detail := &types.BlockDetail{
......@@ -187,6 +194,22 @@ func createCrossParaTx(to string, amount int64) (*types.Transaction, error) {
return tx, err
}
func createCrossParaTempTx(to string, amount int64) (*types.Transaction, error) {
param := types.CreateTx{
To: string(to),
Amount: amount,
Fee: 0,
Note: []byte("test asset transfer"),
IsWithdraw: false,
IsToken: false,
TokenSymbol: "",
ExecName: Title2 + pt.ParaX,
}
tx, err := pt.CreateRawAssetTransferTx(&param)
return tx, err
}
func createTxsGroup(txs []*types.Transaction) ([]*types.Transaction, error) {
group, err := types.CreateTxGroup(txs)
......
......@@ -86,7 +86,7 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
hash := tx.Hash()
mixTxHashs = append(mixTxHashs, hash)
//跨链交易包含了主链交易,需要过滤出来
if types.IsParaExecName(string(tx.Execer)) {
if types.IsMyParaExecName(string(tx.Execer)) {
paraTxHashs = append(paraTxHashs, hash)
}
}
......@@ -100,7 +100,7 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
i = int(end) - 1
continue
}
if types.IsParaExecName(string(tx.Execer)) &&
if types.IsMyParaExecName(string(tx.Execer)) &&
bytes.HasSuffix(tx.Execer, []byte(pt.ParaX)) {
crossTxHashs = append(crossTxHashs, tx.Hash())
}
......
......@@ -87,7 +87,7 @@ func crossTxGroupProc(txs []*types.Transaction, index int) ([]*types.Transaction
//cross asset transfer in tx group
var transfers []*types.Transaction
for i := headIdx; i < endIdx; i++ {
if types.IsParaExecName(string(txs[i].Execer)) &&
if types.IsMyParaExecName(string(txs[i].Execer)) &&
bytes.HasSuffix(txs[i].Execer, []byte(pt.ParaX)) {
transfers = append(transfers, txs[i])
......
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