Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
92a7e7aa
Commit
92a7e7aa
authored
May 20, 2019
by
mdj33
Committed by
vipwzw
May 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rmv user.p.xx.commit tx in commit tx
parent
da5a46c3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
6 deletions
+54
-6
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+28
-5
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+26
-1
No files found.
plugin/dapp/paracross/executor/exec_local.go
View file @
92a7e7aa
...
...
@@ -9,6 +9,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"bytes"
)
//ExecLocal_Commit commit tx local db process
...
...
@@ -125,22 +126,41 @@ func (e *Paracross) ExecLocal_AssetWithdraw(payload *types.AssetsWithdraw, tx *t
return
nil
,
nil
}
func
setMinerTxResult
(
payload
*
pt
.
ParacrossMinerAction
,
txs
[]
*
types
.
Transaction
,
receipts
[]
*
types
.
ReceiptData
)
{
var
curTxHashs
,
paraTxHashs
[][]
byte
func
setMinerTxResult
(
payload
*
pt
.
ParacrossMinerAction
,
txs
[]
*
types
.
Transaction
,
receipts
[]
*
types
.
ReceiptData
)
error
{
isCommitTx
:=
make
(
map
[
string
]
bool
)
var
curTxHashs
,
paraTxHashs
,
crossTxHashs
[][]
byte
for
_
,
tx
:=
range
txs
{
hash
:=
tx
.
Hash
()
curTxHashs
=
append
(
curTxHashs
,
hash
)
//对user.p.xx.paracross ,actionTy==commit 的tx不需要再发回主链
if
types
.
IsMyParaExecName
(
string
(
tx
.
Execer
))
&&
bytes
.
HasSuffix
(
tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
{
var
payload
pt
.
ParacrossAction
err
:=
types
.
Decode
(
tx
.
Payload
,
&
payload
)
if
err
!=
nil
{
clog
.
Error
(
"setMinerTxResult"
,
"txHash"
,
common
.
ToHex
(
hash
))
return
err
}
if
payload
.
Ty
==
pt
.
ParacrossActionCommit
{
isCommitTx
[
string
(
hash
)]
=
true
}
}
//跨链交易包含了主链交易,需要过滤出来
if
types
.
IsMyParaExecName
(
string
(
tx
.
Execer
))
{
if
types
.
IsMyParaExecName
(
string
(
tx
.
Execer
))
&&
!
isCommitTx
[
string
(
hash
)]
{
paraTxHashs
=
append
(
paraTxHashs
,
hash
)
}
}
crossTxHashs
:=
FilterParaMainCrossTxHashes
(
types
.
GetTitle
(),
txs
)
totalCrossTxHashs
:=
FilterParaMainCrossTxHashes
(
types
.
GetTitle
(),
txs
)
for
_
,
crossHash
:=
range
totalCrossTxHashs
{
if
!
isCommitTx
[
string
(
crossHash
)]{
crossTxHashs
=
append
(
crossTxHashs
,
crossHash
)
}
}
payload
.
Status
.
TxHashs
=
paraTxHashs
payload
.
Status
.
TxResult
=
util
.
CalcBitMap
(
paraTxHashs
,
curTxHashs
,
receipts
)
payload
.
Status
.
CrossTxHashs
=
crossTxHashs
payload
.
Status
.
CrossTxResult
=
util
.
CalcBitMap
(
crossTxHashs
,
curTxHashs
,
receipts
)
return
nil
}
func
setMinerTxResultFork
(
payload
*
pt
.
ParacrossMinerAction
,
txs
[]
*
types
.
Transaction
,
receipts
[]
*
types
.
ReceiptData
)
{
...
...
@@ -177,7 +197,10 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
if
payload
.
Status
.
MainBlockHeight
>=
forkHeight
{
setMinerTxResultFork
(
payload
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
}
else
{
setMinerTxResult
(
payload
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
err
:=
setMinerTxResult
(
payload
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
if
err
!=
nil
{
return
nil
,
err
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
92a7e7aa
...
...
@@ -488,10 +488,14 @@ func (s *VoteTestSuite) TestVoteTx() {
tx7
,
err
:=
createAssetTransferTx
(
s
.
Suite
,
PrivKeyC
,
nil
)
s
.
Nil
(
err
)
tx8
,
err
:=
createCrossCommitTx
(
s
.
Suite
)
s
.
Nil
(
err
)
txs
:=
[]
*
types
.
Transaction
{
tx
,
tx1
,
tx2
}
txs
=
append
(
txs
,
txGroup34
...
)
txs
=
append
(
txs
,
txGroup56
...
)
txs
=
append
(
txs
,
tx7
)
txs
=
append
(
txs
,
tx8
)
s
.
exec
.
SetTxs
(
txs
)
//for i,tx := range txs{
...
...
@@ -508,7 +512,8 @@ func (s *VoteTestSuite) TestVoteTx() {
recpt5
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recpt6
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recpt7
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
receipts
:=
[]
*
types
.
ReceiptData
{
recpt0
,
recpt1
,
recpt2
,
recpt3
,
recpt4
,
recpt5
,
recpt6
,
recpt7
}
recpt8
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
receipts
:=
[]
*
types
.
ReceiptData
{
recpt0
,
recpt1
,
recpt2
,
recpt3
,
recpt4
,
recpt5
,
recpt6
,
recpt7
,
recpt8
}
s
.
exec
.
SetReceipt
(
receipts
)
set
,
err
:=
s
.
exec
.
ExecLocal
(
tx
,
recpt0
,
0
)
s
.
Nil
(
err
)
...
...
@@ -697,6 +702,26 @@ func createCrossParaTx(s suite.Suite, to []byte) (*types.Transaction, error) {
return
tx
,
nil
}
func
createCrossCommitTx
(
s
suite
.
Suite
)
(
*
types
.
Transaction
,
error
)
{
status
:=
&
pt
.
ParacrossNodeStatus
{
MainBlockHash
:
[]
byte
(
"hash"
),
MainBlockHeight
:
0
,
Title
:
Title
}
tx
,
err
:=
pt
.
CreateRawCommitTx4MainChain
(
status
,
Title
+
pt
.
ParaX
,
0
)
assert
.
Nil
(
s
.
T
(),
err
,
"create asset transfer failed"
)
if
err
!=
nil
{
return
nil
,
err
}
//tx, err = signTx(s, tx, privFrom)
//assert.Nil(s.T(), err, "sign asset transfer failed")
//if err != nil {
// return nil, err
//}
return
tx
,
nil
}
func
createTxsGroup
(
s
suite
.
Suite
,
txs
[]
*
types
.
Transaction
)
([]
*
types
.
Transaction
,
error
)
{
group
,
err
:=
types
.
CreateTxGroup
(
txs
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment