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
76218c42
Commit
76218c42
authored
Nov 21, 2019
by
mdj33
Committed by
vipwzw
Nov 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linter
parent
e6607ff5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
34 deletions
+36
-34
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+11
-1
action.go
plugin/dapp/paracross/executor/action.go
+25
-33
No files found.
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
76218c42
...
@@ -302,7 +302,17 @@ function paracross_txgroupex() {
...
@@ -302,7 +302,17 @@ function paracross_txgroupex() {
local
trade_exec_name
=
"user.p.para.trade"
local
trade_exec_name
=
"user.p.para.trade"
# 资产从主链转移到平行链
# 资产从主链转移到平行链
tx_hash_asset
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"ParacrossAssetTransfer","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
$para_test_addr
"
'","amount":'
${
amount_transfer
}
'}}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"ParacrossAssetTransfer","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
$para_test_addr
"
'","amount":'
${
amount_transfer
}
'}}]'
echo
"
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
# echo "$resp"
err
=
$(
jq
'(.error)'
<<<
"
$resp
"
)
if
[
"
$err
"
!=
null
]
;
then
echo
"
$resp
"
exit
1
fi
tx_hash_asset
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
# tx_hash_asset=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${paracross_execer_name}"'","actionName":"ParacrossAssetTransfer","payload":{"execName":"'"${paracross_execer_name}"'","to":"'"$para_test_addr"'","amount":'${amount_transfer}'}}]}' "${para_ip}" | jq -r ".result")
# 资产从平行链转移到平行链合约
# 资产从平行链转移到平行链合约
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"TransferToExec","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
${
trade_exec_addr
}
"
'","amount":'
${
amount_trade
}
', "cointoken":"coins.bty"}}]'
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"TransferToExec","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
${
trade_exec_addr
}
"
'","amount":'
${
amount_trade
}
', "cointoken":"coins.bty"}}]'
...
...
plugin/dapp/paracross/executor/action.go
View file @
76218c42
...
@@ -748,7 +748,7 @@ func (a *action) isAllowConsensJump(commit *pt.ParacrossCommitAction, titleStatu
...
@@ -748,7 +748,7 @@ func (a *action) isAllowConsensJump(commit *pt.ParacrossCommitAction, titleStatu
}
}
func
(
a
*
action
)
execCrossTx
(
tx
*
types
.
TransactionDetail
,
crossTxHash
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
func
execCrossTx
(
a
*
action
,
tx
*
types
.
TransactionDetail
,
crossTxHash
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
if
!
bytes
.
HasSuffix
(
tx
.
Tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
{
if
!
bytes
.
HasSuffix
(
tx
.
Tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -773,7 +773,7 @@ func (a *action) execCrossTx(tx *types.TransactionDetail, crossTxHash []byte) (*
...
@@ -773,7 +773,7 @@ func (a *action) execCrossTx(tx *types.TransactionDetail, crossTxHash []byte) (*
}
}
func
(
a
*
action
)
rollbackCrossTx
(
tx
*
types
.
TransactionDetail
,
crossTxHash
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
func
rollbackCrossTx
(
a
*
action
,
tx
*
types
.
TransactionDetail
,
crossTxHash
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
if
!
bytes
.
HasSuffix
(
tx
.
Tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
{
if
!
bytes
.
HasSuffix
(
tx
.
Tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -886,6 +886,24 @@ func getCrossTxHashs(api client.QueueProtocolAPI, status *pt.ParacrossNodeStatus
...
@@ -886,6 +886,24 @@ func getCrossTxHashs(api client.QueueProtocolAPI, status *pt.ParacrossNodeStatus
}
}
func
crossTxProc
(
a
*
action
,
txHash
[]
byte
,
fn
func
(
*
action
,
*
types
.
TransactionDetail
,
[]
byte
)
(
*
types
.
Receipt
,
error
))
(
*
types
.
Receipt
,
error
)
{
tx
,
err
:=
GetTx
(
a
.
api
,
txHash
)
if
err
!=
nil
{
clog
.
Crit
(
"paracross.Commit Load Tx failed"
,
"error"
,
err
,
"txHash"
,
hex
.
EncodeToString
(
txHash
))
return
nil
,
err
}
if
tx
==
nil
{
clog
.
Error
(
"paracross.Commit Load Tx nil"
,
"error"
,
err
,
"txHash"
,
hex
.
EncodeToString
(
txHash
))
return
nil
,
types
.
ErrHashNotExist
}
receiptCross
,
err
:=
fn
(
a
,
tx
,
txHash
)
if
err
!=
nil
{
clog
.
Error
(
"paracross.Commit execCrossTx"
,
"error"
,
err
)
return
nil
,
errors
.
Cause
(
err
)
}
return
receiptCross
,
nil
}
func
(
a
*
action
)
execCrossTxs
(
status
*
pt
.
ParacrossNodeStatus
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
execCrossTxs
(
status
*
pt
.
ParacrossNodeStatus
)
(
*
types
.
Receipt
,
error
)
{
var
receipt
types
.
Receipt
var
receipt
types
.
Receipt
...
@@ -894,28 +912,14 @@ func (a *action) execCrossTxs(status *pt.ParacrossNodeStatus) (*types.Receipt, e
...
@@ -894,28 +912,14 @@ func (a *action) execCrossTxs(status *pt.ParacrossNodeStatus) (*types.Receipt, e
clog
.
Error
(
"paracross.Commit getCrossTxHashs"
,
"err"
,
err
.
Error
())
clog
.
Error
(
"paracross.Commit getCrossTxHashs"
,
"err"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
}
}
if
len
(
crossTxHashs
)
==
0
{
return
&
receipt
,
nil
}
for
i
:=
0
;
i
<
len
(
crossTxHashs
);
i
++
{
for
i
:=
0
;
i
<
len
(
crossTxHashs
);
i
++
{
clog
.
Debug
(
"paracross.Commit commitDone"
,
"do cross number"
,
i
,
"hash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]),
clog
.
Debug
(
"paracross.Commit commitDone"
,
"do cross number"
,
i
,
"hash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]),
"res"
,
util
.
BitMapBit
(
crossTxResult
,
uint32
(
i
)))
"res"
,
util
.
BitMapBit
(
crossTxResult
,
uint32
(
i
)))
if
util
.
BitMapBit
(
crossTxResult
,
uint32
(
i
))
{
if
util
.
BitMapBit
(
crossTxResult
,
uint32
(
i
))
{
tx
,
err
:=
GetTx
(
a
.
api
,
crossTxHashs
[
i
]
)
receiptCross
,
err
:=
crossTxProc
(
a
,
crossTxHashs
[
i
],
execCrossTx
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Crit
(
"paracross.Commit Load Tx failed"
,
"para title"
,
title
,
"para height"
,
status
.
Height
,
clog
.
Error
(
"paracross.Commit execCrossTx"
,
"para title"
,
status
.
Title
,
"para height"
,
status
.
Height
,
"para tx index"
,
i
,
"error"
,
err
,
"txHash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]))
return
nil
,
err
}
if
tx
==
nil
{
clog
.
Error
(
"paracross.Commit Load Tx nil"
,
"para title"
,
title
,
"para height"
,
status
.
Height
,
"para tx index"
,
i
,
"error"
,
err
,
"txHash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]))
return
nil
,
types
.
ErrHashNotExist
}
receiptCross
,
err
:=
a
.
execCrossTx
(
tx
,
crossTxHashs
[
i
])
if
err
!=
nil
{
clog
.
Error
(
"paracross.Commit execCrossTx"
,
"para title"
,
title
,
"para height"
,
status
.
Height
,
"para tx index"
,
i
,
"error"
,
err
)
"para tx index"
,
i
,
"error"
,
err
)
return
nil
,
errors
.
Cause
(
err
)
return
nil
,
errors
.
Cause
(
err
)
}
}
...
@@ -926,24 +930,12 @@ func (a *action) execCrossTxs(status *pt.ParacrossNodeStatus) (*types.Receipt, e
...
@@ -926,24 +930,12 @@ func (a *action) execCrossTxs(status *pt.ParacrossNodeStatus) (*types.Receipt, e
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptCross
.
Logs
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptCross
.
Logs
...
)
}
else
{
}
else
{
clog
.
Error
(
"paracross.Commit commitDone"
,
"do cross number"
,
i
,
"hash"
,
clog
.
Error
(
"paracross.Commit commitDone"
,
"do cross number"
,
i
,
"hash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]),
hex
.
EncodeToString
(
crossTxHashs
[
i
]),
"para res"
,
util
.
BitMapBit
(
crossTxResult
,
uint32
(
i
)))
"para res"
,
util
.
BitMapBit
(
crossTxResult
,
uint32
(
i
)))
cfg
:=
a
.
api
.
GetConfig
()
cfg
:=
a
.
api
.
GetConfig
()
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
tx
,
err
:=
GetTx
(
a
.
api
,
crossTxHashs
[
i
])
receiptCross
,
err
:=
crossTxProc
(
a
,
crossTxHashs
[
i
],
rollbackCrossTx
)
if
err
!=
nil
{
clog
.
Crit
(
"paracross.Commit rbk Load Tx failed"
,
"para title"
,
title
,
"para height"
,
status
.
Height
,
"para tx index"
,
i
,
"error"
,
err
,
"txHash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]))
return
nil
,
err
}
if
tx
==
nil
{
clog
.
Error
(
"paracross.Commit rbk Load Tx nil"
,
"para title"
,
title
,
"para height"
,
status
.
Height
,
"para tx index"
,
i
,
"error"
,
err
,
"txHash"
,
hex
.
EncodeToString
(
crossTxHashs
[
i
]))
return
nil
,
types
.
ErrHashNotExist
}
receiptCross
,
err
:=
a
.
rollbackCrossTx
(
tx
,
crossTxHashs
[
i
])
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"paracross.Commit rollbackCrossTx"
,
"para title"
,
t
itle
,
"para height"
,
status
.
Height
,
clog
.
Error
(
"paracross.Commit rollbackCrossTx"
,
"para title"
,
status
.
T
itle
,
"para height"
,
status
.
Height
,
"para tx index"
,
i
,
"error"
,
err
)
"para tx index"
,
i
,
"error"
,
err
)
return
nil
,
errors
.
Cause
(
err
)
return
nil
,
errors
.
Cause
(
err
)
}
}
...
...
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