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
02830e68
Commit
02830e68
authored
Oct 10, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify dapp commands global config
parent
af0be445
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
609 additions
and
175 deletions
+609
-175
para.go
plugin/consensus/para/para.go
+8
-7
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+23
-18
paracreate.go
plugin/consensus/para/paracreate.go
+18
-10
paramultidownload.go
plugin/consensus/para/paramultidownload.go
+19
-12
parasync.go
plugin/consensus/para/parasync.go
+13
-9
proposal_board.go
plugin/dapp/autonomy/commands/proposal_board.go
+29
-4
proposal_change.go
plugin/dapp/autonomy/commands/proposal_change.go
+29
-4
proposal_project.go
plugin/dapp/autonomy/commands/proposal_project.go
+36
-5
proposal_rule.go
plugin/dapp/autonomy/commands/proposal_rule.go
+43
-6
vote.go
plugin/dapp/dposvote/commands/vote.go
+56
-8
evm.go
plugin/dapp/evm/commands/evm.go
+34
-10
exec.go
plugin/dapp/evm/executor/exec.go
+2
-2
exec_del_local.go
plugin/dapp/evm/executor/exec_del_local.go
+2
-2
exec_local.go
plugin/dapp/evm/executor/exec_local.go
+2
-1
query.go
plugin/dapp/evm/executor/query.go
+6
-4
evm.go
plugin/dapp/evm/executor/vm/runtime/evm.go
+4
-2
interface.go
plugin/dapp/evm/executor/vm/state/interface.go
+4
-0
statedb.go
plugin/dapp/evm/executor/vm/state/statedb.go
+6
-0
game.go
plugin/dapp/guess/commands/game.go
+35
-5
hashlock.go
plugin/dapp/hashlock/commands/hashlock.go
+14
-2
js.go
plugin/dapp/js/types/js.go
+1
-1
oracle.go
plugin/dapp/oracle/commands/oracle.go
+35
-5
paracross.go
plugin/dapp/paracross/commands/paracross.go
+99
-45
game.go
plugin/dapp/pokerbull/cmd/game.go
+28
-4
retrieve.go
plugin/dapp/retrieve/cmd/retrieve.go
+21
-3
ticket.go
plugin/dapp/ticket/commands/ticket.go
+7
-1
unfreeze.go
plugin/dapp/unfreeze/commands/unfreeze.go
+28
-4
valnode.go
plugin/dapp/valnode/commands/valnode.go
+7
-1
No files found.
plugin/consensus/para/para.go
View file @
02830e68
...
@@ -156,14 +156,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -156,14 +156,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
panic
(
err
)
panic
(
err
)
}
}
grpcCli
,
err
:=
grpcclient
.
NewMainChainClient
(
""
)
if
err
!=
nil
{
panic
(
err
)
}
para
:=
&
client
{
para
:=
&
client
{
BaseClient
:
c
,
BaseClient
:
c
,
grpcClient
:
grpcCli
,
authAccount
:
subcfg
.
AuthAccount
,
authAccount
:
subcfg
.
AuthAccount
,
privateKey
:
priKey
,
privateKey
:
priKey
,
subCfg
:
&
subcfg
,
subCfg
:
&
subcfg
,
...
@@ -286,6 +280,12 @@ func (client *client) InitBlock() {
...
@@ -286,6 +280,12 @@ func (client *client) InitBlock() {
var
err
error
var
err
error
client
.
execAPI
=
api
.
New
(
client
.
BaseClient
.
GetAPI
(),
client
.
grpcClient
)
client
.
execAPI
=
api
.
New
(
client
.
BaseClient
.
GetAPI
(),
client
.
grpcClient
)
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
grpcCli
,
err
:=
grpcclient
.
NewMainChainClient
(
cfg
,
""
)
if
err
!=
nil
{
panic
(
err
)
}
client
.
grpcClient
=
grpcCli
block
,
err
:=
client
.
RequestLastBlock
()
block
,
err
:=
client
.
RequestLastBlock
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -364,7 +364,8 @@ func (client *client) GetStartMainHash(height int64) []byte {
...
@@ -364,7 +364,8 @@ func (client *client) GetStartMainHash(height int64) []byte {
func
(
client
*
client
)
CreateGenesisTx
()
(
ret
[]
*
types
.
Transaction
)
{
func
(
client
*
client
)
CreateGenesisTx
()
(
ret
[]
*
types
.
Transaction
)
{
var
tx
types
.
Transaction
var
tx
types
.
Transaction
tx
.
Execer
=
[]
byte
(
types
.
ExecName
(
cty
.
CoinsX
))
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
tx
.
Execer
=
[]
byte
(
cfg
.
ExecName
(
cty
.
CoinsX
))
tx
.
To
=
client
.
Cfg
.
Genesis
tx
.
To
=
client
.
Cfg
.
Genesis
//gen payload
//gen payload
g
:=
&
cty
.
CoinsAction_Genesis
{}
g
:=
&
cty
.
CoinsAction_Genesis
{}
...
...
plugin/consensus/para/paracommitmsg.go
View file @
02830e68
...
@@ -373,13 +373,13 @@ func (client *commitMsgClient) getTxsGroup(txsArr *types.Transactions) (*types.T
...
@@ -373,13 +373,13 @@ func (client *commitMsgClient) getTxsGroup(txsArr *types.Transactions) (*types.T
tx
.
Sign
(
types
.
SECP256K1
,
client
.
privateKey
)
tx
.
Sign
(
types
.
SECP256K1
,
client
.
privateKey
)
return
tx
,
nil
return
tx
,
nil
}
}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
group
,
err
:=
types
.
CreateTxGroup
(
txsArr
.
Txs
,
types
.
GInt
(
"MinFee"
))
group
,
err
:=
types
.
CreateTxGroup
(
txsArr
.
Txs
,
cfg
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"para CreateTxGroup"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"para CreateTxGroup"
,
"err"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
}
}
err
=
group
.
Check
(
0
,
types
.
GInt
(
"MinFee"
),
types
.
GInt
(
"MaxFee"
))
err
=
group
.
Check
(
cfg
,
0
,
cfg
.
GInt
(
"MinFee"
),
cfg
.
GInt
(
"MaxFee"
))
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"para CheckTxGroup"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"para CheckTxGroup"
,
"err"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
...
@@ -394,12 +394,13 @@ func (client *commitMsgClient) getTxsGroup(txsArr *types.Transactions) (*types.T
...
@@ -394,12 +394,13 @@ func (client *commitMsgClient) getTxsGroup(txsArr *types.Transactions) (*types.T
func
(
client
*
commitMsgClient
)
batchCalcTxGroup
(
notifications
[]
*
pt
.
ParacrossNodeStatus
,
feeRate
int64
)
(
*
types
.
Transaction
,
int
,
error
)
{
func
(
client
*
commitMsgClient
)
batchCalcTxGroup
(
notifications
[]
*
pt
.
ParacrossNodeStatus
,
feeRate
int64
)
(
*
types
.
Transaction
,
int
,
error
)
{
var
rawTxs
types
.
Transactions
var
rawTxs
types
.
Transactions
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
for
_
,
status
:=
range
notifications
{
for
_
,
status
:=
range
notifications
{
execName
:=
pt
.
ParaX
execName
:=
pt
.
ParaX
if
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
)
{
if
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
)
{
execName
=
paracross
.
GetExecName
()
execName
=
paracross
.
GetExecName
(
cfg
)
}
}
tx
,
err
:=
paracross
.
CreateRawCommitTx4MainChain
(
status
,
execName
,
feeRate
)
tx
,
err
:=
paracross
.
CreateRawCommitTx4MainChain
(
cfg
,
status
,
execName
,
feeRate
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"para get commit tx"
,
"block height"
,
status
.
Height
)
plog
.
Error
(
"para get commit tx"
,
"block height"
,
status
.
Height
)
return
nil
,
0
,
err
return
nil
,
0
,
err
...
@@ -416,10 +417,11 @@ func (client *commitMsgClient) batchCalcTxGroup(notifications []*pt.ParacrossNod
...
@@ -416,10 +417,11 @@ func (client *commitMsgClient) batchCalcTxGroup(notifications []*pt.ParacrossNod
func
(
client
*
commitMsgClient
)
singleCalcTx
(
status
*
pt
.
ParacrossNodeStatus
,
feeRate
int64
)
(
*
types
.
Transaction
,
error
)
{
func
(
client
*
commitMsgClient
)
singleCalcTx
(
status
*
pt
.
ParacrossNodeStatus
,
feeRate
int64
)
(
*
types
.
Transaction
,
error
)
{
execName
:=
pt
.
ParaX
execName
:=
pt
.
ParaX
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
if
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
)
{
if
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
)
{
execName
=
paracross
.
GetExecName
()
execName
=
paracross
.
GetExecName
(
cfg
)
}
}
tx
,
err
:=
paracross
.
CreateRawCommitTx4MainChain
(
status
,
execName
,
feeRate
)
tx
,
err
:=
paracross
.
CreateRawCommitTx4MainChain
(
cfg
,
status
,
execName
,
feeRate
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"para get commit tx"
,
"block height"
,
status
.
Height
)
plog
.
Error
(
"para get commit tx"
,
"block height"
,
status
.
Height
)
return
nil
,
err
return
nil
,
err
...
@@ -521,8 +523,9 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
...
@@ -521,8 +523,9 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
count
:=
req
.
End
-
req
.
Start
+
1
count
:=
req
.
End
-
req
.
Start
+
1
nodeList
:=
make
(
map
[
int64
]
*
pt
.
ParacrossNodeStatus
,
count
+
1
)
nodeList
:=
make
(
map
[
int64
]
*
pt
.
ParacrossNodeStatus
,
count
+
1
)
keys
:=
&
types
.
LocalDBGet
{}
keys
:=
&
types
.
LocalDBGet
{}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
for
i
:=
0
;
i
<
int
(
count
);
i
++
{
for
i
:=
0
;
i
<
int
(
count
);
i
++
{
key
:=
paracross
.
CalcMinerHeightKey
(
types
.
GetTitle
(),
req
.
Start
+
int64
(
i
))
key
:=
paracross
.
CalcMinerHeightKey
(
cfg
.
GetTitle
(),
req
.
Start
+
int64
(
i
))
keys
.
Keys
=
append
(
keys
.
Keys
,
key
)
keys
.
Keys
=
append
(
keys
.
Keys
,
key
)
}
}
...
@@ -568,8 +571,8 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
...
@@ -568,8 +571,8 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
plog
.
Error
(
"paracommitmsg get node status block"
,
"height"
,
block
.
Block
.
Height
,
"expect start"
,
req
.
Start
,
"end"
,
req
.
End
)
plog
.
Error
(
"paracommitmsg get node status block"
,
"height"
,
block
.
Block
.
Height
,
"expect start"
,
req
.
Start
,
"end"
,
req
.
End
)
return
nil
,
errors
.
New
(
"paracommitmsg wrong block result"
)
return
nil
,
errors
.
New
(
"paracommitmsg wrong block result"
)
}
}
nodeList
[
block
.
Block
.
Height
]
.
BlockHash
=
block
.
Block
.
Hash
()
nodeList
[
block
.
Block
.
Height
]
.
BlockHash
=
block
.
Block
.
Hash
(
cfg
)
if
!
paracross
.
IsParaForkHeight
(
nodeList
[
block
.
Block
.
Height
]
.
MainBlockHeight
,
paracross
.
ForkLoopCheckCommitTxDone
)
{
if
!
paracross
.
IsParaForkHeight
(
cfg
,
nodeList
[
block
.
Block
.
Height
]
.
MainBlockHeight
,
paracross
.
ForkLoopCheckCommitTxDone
)
{
nodeList
[
block
.
Block
.
Height
]
.
StateHash
=
block
.
Block
.
StateHash
nodeList
[
block
.
Block
.
Height
]
.
StateHash
=
block
.
Block
.
StateHash
}
}
}
}
...
@@ -608,9 +611,10 @@ func (client *commitMsgClient) getGenesisNodeStatus() (*pt.ParacrossNodeStatus,
...
@@ -608,9 +611,10 @@ func (client *commitMsgClient) getGenesisNodeStatus() (*pt.ParacrossNodeStatus,
if
block
.
Height
!=
0
{
if
block
.
Height
!=
0
{
return
nil
,
errors
.
New
(
"block chain not return 0 height block"
)
return
nil
,
errors
.
New
(
"block chain not return 0 height block"
)
}
}
status
.
Title
=
types
.
GetTitle
()
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
status
.
Title
=
cfg
.
GetTitle
()
status
.
Height
=
block
.
Height
status
.
Height
=
block
.
Height
status
.
BlockHash
=
block
.
Hash
()
status
.
BlockHash
=
block
.
Hash
(
cfg
)
return
&
status
,
nil
return
&
status
,
nil
}
}
...
@@ -703,13 +707,13 @@ func (client *commitMsgClient) getSelfConsensusStatus() (*pt.ParacrossStatus, er
...
@@ -703,13 +707,13 @@ func (client *commitMsgClient) getSelfConsensusStatus() (*pt.ParacrossStatus, er
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
if
client
.
paraClient
.
isParaSelfConsensusForked
(
block
.
MainHeight
)
{
if
client
.
paraClient
.
isParaSelfConsensusForked
(
block
.
MainHeight
)
{
//从本地查询共识高度
//从本地查询共识高度
ret
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
ret
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
Driver
:
"paracross"
,
FuncName
:
"GetTitle"
,
FuncName
:
"GetTitle"
,
Param
:
types
.
Encode
(
&
types
.
ReqString
{
Data
:
types
.
GetTitle
()}),
Param
:
types
.
Encode
(
&
types
.
ReqString
{
Data
:
cfg
.
GetTitle
()}),
})
})
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"getSelfConsensusStatus "
,
"err"
,
err
.
Error
())
plog
.
Error
(
"getSelfConsensusStatus "
,
"err"
,
err
.
Error
())
...
@@ -723,7 +727,7 @@ func (client *commitMsgClient) getSelfConsensusStatus() (*pt.ParacrossStatus, er
...
@@ -723,7 +727,7 @@ func (client *commitMsgClient) getSelfConsensusStatus() (*pt.ParacrossStatus, er
//开启自共识后也要等到自共识真正切换之后再使用,如果本地区块已经过了自共识高度,但自共识的高度还没达成,就会导致共识机制出错
//开启自共识后也要等到自共识真正切换之后再使用,如果本地区块已经过了自共识高度,但自共识的高度还没达成,就会导致共识机制出错
if
resp
.
Height
>
-
1
{
if
resp
.
Height
>
-
1
{
var
statusMainHeight
int64
var
statusMainHeight
int64
if
pt
.
IsParaForkHeight
(
resp
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
IsParaForkHeight
(
cfg
,
resp
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
statusMainHeight
=
resp
.
MainHeight
statusMainHeight
=
resp
.
MainHeight
}
else
{
}
else
{
block
,
err
:=
client
.
paraClient
.
GetBlockByHeight
(
resp
.
Height
)
block
,
err
:=
client
.
paraClient
.
GetBlockByHeight
(
resp
.
Height
)
...
@@ -749,12 +753,12 @@ func (client *commitMsgClient) getMainConsensusStatus() (*pt.ParacrossStatus, er
...
@@ -749,12 +753,12 @@ func (client *commitMsgClient) getMainConsensusStatus() (*pt.ParacrossStatus, er
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
//去主链获取共识高度
//去主链获取共识高度
reply
,
err
:=
client
.
paraClient
.
grpcClient
.
QueryChain
(
context
.
Background
(),
&
types
.
ChainExecutor
{
reply
,
err
:=
client
.
paraClient
.
grpcClient
.
QueryChain
(
context
.
Background
(),
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
Driver
:
"paracross"
,
FuncName
:
"GetTitleByHash"
,
FuncName
:
"GetTitleByHash"
,
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossTitleHash
{
Title
:
types
.
GetTitle
(),
BlockHash
:
block
.
MainHash
}),
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossTitleHash
{
Title
:
cfg
.
GetTitle
(),
BlockHash
:
block
.
MainHash
}),
})
})
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"getMainConsensusStatus"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"getMainConsensusStatus"
,
"err"
,
err
.
Error
())
...
@@ -776,10 +780,11 @@ func (client *commitMsgClient) getMainConsensusStatus() (*pt.ParacrossStatus, er
...
@@ -776,10 +780,11 @@ func (client *commitMsgClient) getMainConsensusStatus() (*pt.ParacrossStatus, er
//node group会在主链和平行链都同时配置,只本地查询就可以
//node group会在主链和平行链都同时配置,只本地查询就可以
func
(
client
*
commitMsgClient
)
getNodeGroupAddrs
()
(
string
,
error
)
{
func
(
client
*
commitMsgClient
)
getNodeGroupAddrs
()
(
string
,
error
)
{
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
ret
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
ret
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
Driver
:
"paracross"
,
FuncName
:
"GetNodeGroupAddrs"
,
FuncName
:
"GetNodeGroupAddrs"
,
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
types
.
GetTitle
()}),
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
cfg
.
GetTitle
()}),
})
})
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"commitmsg.getNodeGroupAddrs "
,
"err"
,
err
.
Error
())
plog
.
Error
(
"commitmsg.getNodeGroupAddrs "
,
"err"
,
err
.
Error
())
...
...
plugin/consensus/para/paracreate.go
View file @
02830e68
...
@@ -22,14 +22,15 @@ import (
...
@@ -22,14 +22,15 @@ import (
)
)
func
(
client
*
client
)
addLocalBlock
(
height
int64
,
block
*
pt
.
ParaLocalDbBlock
)
error
{
func
(
client
*
client
)
addLocalBlock
(
height
int64
,
block
*
pt
.
ParaLocalDbBlock
)
error
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
//两个key原子操作
//两个key原子操作
key
=
calcTitleLastHeightKey
(
types
.
GetTitle
())
key
=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
kv
=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
height
})}
kv
=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
height
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
@@ -59,13 +60,14 @@ func (client *client) createLocalGenesisBlock(genesis *types.Block) error {
...
@@ -59,13 +60,14 @@ func (client *client) createLocalGenesisBlock(genesis *types.Block) error {
}
}
func
(
client
*
client
)
delLocalBlock
(
height
int64
)
error
{
func
(
client
*
client
)
delLocalBlock
(
height
int64
)
error
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
//两个key原子操作
//两个key原子操作
key
=
calcTitleLastHeightKey
(
types
.
GetTitle
())
key
=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
kv
=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
height
-
1
})}
kv
=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
height
-
1
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
@@ -74,9 +76,10 @@ func (client *client) delLocalBlock(height int64) error {
...
@@ -74,9 +76,10 @@ func (client *client) delLocalBlock(height int64) error {
// localblock 设置到当前高度,当前高度后面block会被新的区块覆盖
// localblock 设置到当前高度,当前高度后面block会被新的区块覆盖
func
(
client
*
client
)
removeLocalBlocks
(
curHeight
int64
)
error
{
func
(
client
*
client
)
removeLocalBlocks
(
curHeight
int64
)
error
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleLastHeightKey
(
types
.
GetTitle
())
key
:=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
curHeight
})}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
curHeight
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
@@ -84,7 +87,8 @@ func (client *client) removeLocalBlocks(curHeight int64) error {
...
@@ -84,7 +87,8 @@ func (client *client) removeLocalBlocks(curHeight int64) error {
}
}
func
(
client
*
client
)
getLastLocalHeight
()
(
int64
,
error
)
{
func
(
client
*
client
)
getLastLocalHeight
()
(
int64
,
error
)
{
key
:=
calcTitleLastHeightKey
(
types
.
GetTitle
())
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
key
:=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
value
,
err
:=
client
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
value
,
err
:=
client
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -104,7 +108,8 @@ func (client *client) getLastLocalHeight() (int64, error) {
...
@@ -104,7 +108,8 @@ func (client *client) getLastLocalHeight() (int64, error) {
}
}
func
(
client
*
client
)
getLocalBlockByHeight
(
height
int64
)
(
*
pt
.
ParaLocalDbBlock
,
error
)
{
func
(
client
*
client
)
getLocalBlockByHeight
(
height
int64
)
(
*
pt
.
ParaLocalDbBlock
,
error
)
{
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
height
)
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
value
,
err
:=
client
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
value
,
err
:=
client
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
...
@@ -395,12 +400,13 @@ func validMainBlocks(txs *types.ParaTxDetails) *types.ParaTxDetails {
...
@@ -395,12 +400,13 @@ func validMainBlocks(txs *types.ParaTxDetails) *types.ParaTxDetails {
}
}
func
(
client
*
client
)
requestTxsFromBlock
(
currSeq
int64
,
preMainBlockHash
[]
byte
)
(
*
types
.
ParaTxDetails
,
error
)
{
func
(
client
*
client
)
requestTxsFromBlock
(
currSeq
int64
,
preMainBlockHash
[]
byte
)
(
*
types
.
ParaTxDetails
,
error
)
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
blockSeq
,
err
:=
client
.
GetBlockOnMainBySeq
(
currSeq
)
blockSeq
,
err
:=
client
.
GetBlockOnMainBySeq
(
currSeq
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
txDetail
:=
blockSeq
.
Detail
.
FilterParaTxsByTitle
(
types
.
GetTitle
())
txDetail
:=
blockSeq
.
Detail
.
FilterParaTxsByTitle
(
cfg
,
cfg
.
GetTitle
())
txDetail
.
Type
=
blockSeq
.
Seq
.
Type
txDetail
.
Type
=
blockSeq
.
Seq
.
Type
if
!
isValidSeqType
(
txDetail
.
Type
)
{
if
!
isValidSeqType
(
txDetail
.
Type
)
{
...
@@ -416,7 +422,8 @@ func (client *client) requestTxsFromBlock(currSeq int64, preMainBlockHash []byte
...
@@ -416,7 +422,8 @@ func (client *client) requestTxsFromBlock(currSeq int64, preMainBlockHash []byte
}
}
func
(
client
*
client
)
requestFilterParaTxs
(
currSeq
int64
,
count
int64
,
preMainBlockHash
[]
byte
)
(
*
types
.
ParaTxDetails
,
error
)
{
func
(
client
*
client
)
requestFilterParaTxs
(
currSeq
int64
,
count
int64
,
preMainBlockHash
[]
byte
)
(
*
types
.
ParaTxDetails
,
error
)
{
req
:=
&
types
.
ReqParaTxByTitle
{
IsSeq
:
true
,
Start
:
currSeq
,
End
:
currSeq
+
count
,
Title
:
types
.
GetTitle
()}
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
req
:=
&
types
.
ReqParaTxByTitle
{
IsSeq
:
true
,
Start
:
currSeq
,
End
:
currSeq
+
count
,
Title
:
cfg
.
GetTitle
()}
details
,
err
:=
client
.
GetParaTxByTitle
(
req
)
details
,
err
:=
client
.
GetParaTxByTitle
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -459,6 +466,7 @@ func (client *client) getEmptyInterval(lastBlock *pt.ParaLocalDbBlock) int64 {
...
@@ -459,6 +466,7 @@ func (client *client) getEmptyInterval(lastBlock *pt.ParaLocalDbBlock) int64 {
}
}
func
(
client
*
client
)
procLocalBlock
(
mainBlock
*
types
.
ParaTxDetail
)
(
bool
,
error
)
{
func
(
client
*
client
)
procLocalBlock
(
mainBlock
*
types
.
ParaTxDetail
)
(
bool
,
error
)
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
lastSeqMainHeight
:=
mainBlock
.
Header
.
Height
lastSeqMainHeight
:=
mainBlock
.
Header
.
Height
lastBlock
,
err
:=
client
.
getLastLocalBlock
()
lastBlock
,
err
:=
client
.
getLastLocalBlock
()
...
@@ -468,7 +476,7 @@ func (client *client) procLocalBlock(mainBlock *types.ParaTxDetail) (bool, error
...
@@ -468,7 +476,7 @@ func (client *client) procLocalBlock(mainBlock *types.ParaTxDetail) (bool, error
}
}
emptyInterval
:=
client
.
getEmptyInterval
(
lastBlock
)
emptyInterval
:=
client
.
getEmptyInterval
(
lastBlock
)
txs
:=
paraexec
.
FilterTxsForPara
(
mainBlock
)
txs
:=
paraexec
.
FilterTxsForPara
(
cfg
,
mainBlock
)
plog
.
Info
(
"Parachain process block"
,
"lastBlockHeight"
,
lastBlock
.
Height
,
"lastBlockMainHeight"
,
lastBlock
.
MainHeight
,
plog
.
Info
(
"Parachain process block"
,
"lastBlockHeight"
,
lastBlock
.
Height
,
"lastBlockMainHeight"
,
lastBlock
.
MainHeight
,
"lastBlockMainHash"
,
common
.
ToHex
(
lastBlock
.
MainHash
),
"currMainHeight"
,
lastSeqMainHeight
,
"lastBlockMainHash"
,
common
.
ToHex
(
lastBlock
.
MainHash
),
"currMainHeight"
,
lastSeqMainHeight
,
...
...
plugin/consensus/para/paramultidownload.go
View file @
02830e68
...
@@ -93,8 +93,9 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
...
@@ -93,8 +93,9 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
recv
:=
make
(
chan
bool
,
1
)
recv
:=
make
(
chan
bool
,
1
)
testInv
:=
&
inventory
{
start
:
inv
.
start
,
end
:
inv
.
end
,
curHeight
:
inv
.
start
,
connCli
:
conn
}
testInv
:=
&
inventory
{
start
:
inv
.
start
,
end
:
inv
.
end
,
curHeight
:
inv
.
start
,
connCli
:
conn
}
cfg
:=
m
.
paraClient
.
GetAPI
()
.
GetConfig
()
go
func
()
{
go
func
()
{
_
,
err
:=
requestMainBlocks
(
testInv
)
_
,
err
:=
requestMainBlocks
(
cfg
,
testInv
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Info
(
"multiServerDownload.testconn ip error"
,
"ip"
,
conn
.
ip
,
"err"
,
err
.
Error
())
plog
.
Info
(
"multiServerDownload.testconn ip error"
,
"ip"
,
conn
.
ip
,
"err"
,
err
.
Error
())
recv
<-
false
recv
<-
false
...
@@ -120,11 +121,12 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
...
@@ -120,11 +121,12 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
}
}
func
(
m
*
multiDldClient
)
getConns
(
inv
*
inventory
)
error
{
func
(
m
*
multiDldClient
)
getConns
(
inv
*
inventory
)
error
{
paraRemoteGrpcIps
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
cfg
:=
m
.
paraClient
.
GetAPI
()
.
GetConfig
()
paraRemoteGrpcIps
:=
types
.
Conf
(
cfg
,
"config.consensus.sub.para"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
ips
:=
strings
.
Split
(
paraRemoteGrpcIps
,
","
)
ips
:=
strings
.
Split
(
paraRemoteGrpcIps
,
","
)
var
conns
[]
*
connectCli
var
conns
[]
*
connectCli
for
_
,
ip
:=
range
ips
{
for
_
,
ip
:=
range
ips
{
conn
,
err
:=
grpcclient
.
NewMainChainClient
(
ip
)
conn
,
err
:=
grpcclient
.
NewMainChainClient
(
cfg
,
ip
)
if
err
==
nil
{
if
err
==
nil
{
conns
=
append
(
conns
,
&
connectCli
{
conn
:
conn
,
ip
:
ip
,
timeout
:
m
.
serverTimeout
})
conns
=
append
(
conns
,
&
connectCli
{
conn
:
conn
,
ip
:
ip
,
timeout
:
m
.
serverTimeout
})
}
}
...
@@ -326,9 +328,10 @@ func (d *downloadJob) verifyDownloadBlock(inv *inventory, blocks *types.ParaTxDe
...
@@ -326,9 +328,10 @@ func (d *downloadJob) verifyDownloadBlock(inv *inventory, blocks *types.ParaTxDe
}
}
func
(
d
*
downloadJob
)
saveMainBlock
(
height
int64
,
block
*
types
.
ParaTxDetail
)
error
{
func
(
d
*
downloadJob
)
saveMainBlock
(
height
int64
,
block
*
types
.
ParaTxDetail
)
error
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleMainHeightKey
(
types
.
GetTitle
(),
height
)
key
:=
calcTitleMainHeightKey
(
cfg
.
GetTitle
(),
height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
@@ -336,10 +339,11 @@ func (d *downloadJob) saveMainBlock(height int64, block *types.ParaTxDetail) err
...
@@ -336,10 +339,11 @@ func (d *downloadJob) saveMainBlock(height int64, block *types.ParaTxDetail) err
}
}
func
(
d
*
downloadJob
)
saveBatchMainBlocks
(
txs
*
types
.
ParaTxDetails
)
error
{
func
(
d
*
downloadJob
)
saveBatchMainBlocks
(
txs
*
types
.
ParaTxDetails
)
error
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
for
_
,
block
:=
range
txs
.
Items
{
for
_
,
block
:=
range
txs
.
Items
{
key
:=
calcTitleMainHeightKey
(
types
.
GetTitle
(),
block
.
Header
.
Height
)
key
:=
calcTitleMainHeightKey
(
cfg
.
GetTitle
(),
block
.
Header
.
Height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
}
}
...
@@ -348,10 +352,11 @@ func (d *downloadJob) saveBatchMainBlocks(txs *types.ParaTxDetails) error {
...
@@ -348,10 +352,11 @@ func (d *downloadJob) saveBatchMainBlocks(txs *types.ParaTxDetails) error {
}
}
func
(
d
*
downloadJob
)
rmvBatchMainBlocks
(
inv
*
inventory
)
error
{
func
(
d
*
downloadJob
)
rmvBatchMainBlocks
(
inv
*
inventory
)
error
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
for
i
:=
inv
.
start
;
i
<
inv
.
curHeight
;
i
++
{
for
i
:=
inv
.
start
;
i
<
inv
.
curHeight
;
i
++
{
key
:=
calcTitleMainHeightKey
(
types
.
GetTitle
(),
i
)
key
:=
calcTitleMainHeightKey
(
cfg
.
GetTitle
(),
i
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
}
}
...
@@ -360,7 +365,8 @@ func (d *downloadJob) rmvBatchMainBlocks(inv *inventory) error {
...
@@ -360,7 +365,8 @@ func (d *downloadJob) rmvBatchMainBlocks(inv *inventory) error {
}
}
func
(
d
*
downloadJob
)
getBlockFromDb
(
height
int64
)
(
*
types
.
ParaTxDetail
,
error
)
{
func
(
d
*
downloadJob
)
getBlockFromDb
(
height
int64
)
(
*
types
.
ParaTxDetail
,
error
)
{
key
:=
calcTitleMainHeightKey
(
types
.
GetTitle
(),
height
)
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
key
:=
calcTitleMainHeightKey
(
cfg
.
GetTitle
(),
height
)
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
value
,
err
:=
d
.
mDldCli
.
paraClient
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
value
,
err
:=
d
.
mDldCli
.
paraClient
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
...
@@ -438,8 +444,8 @@ func (d *downloadJob) checkDownLoadRate() {
...
@@ -438,8 +444,8 @@ func (d *downloadJob) checkDownLoadRate() {
}
}
func
requestMainBlocks
(
inv
*
inventory
)
(
*
types
.
ParaTxDetails
,
error
)
{
func
requestMainBlocks
(
cfg
*
types
.
Chain33Config
,
inv
*
inventory
)
(
*
types
.
ParaTxDetails
,
error
)
{
req
:=
&
types
.
ReqParaTxByTitle
{
IsSeq
:
false
,
Start
:
inv
.
curHeight
,
End
:
inv
.
end
,
Title
:
types
.
GetTitle
()}
req
:=
&
types
.
ReqParaTxByTitle
{
IsSeq
:
false
,
Start
:
inv
.
curHeight
,
End
:
inv
.
end
,
Title
:
cfg
.
GetTitle
()}
txs
,
err
:=
inv
.
connCli
.
conn
.
GetParaTxByTitle
(
context
.
Background
(),
req
)
txs
,
err
:=
inv
.
connCli
.
conn
.
GetParaTxByTitle
(
context
.
Background
(),
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -456,10 +462,10 @@ func requestMainBlocks(inv *inventory) (*types.ParaTxDetails, error) {
...
@@ -456,10 +462,10 @@ func requestMainBlocks(inv *inventory) (*types.ParaTxDetails, error) {
return
validMainBlocks
(
txs
),
nil
return
validMainBlocks
(
txs
),
nil
}
}
func
requestMainBlockWithTime
(
inv
*
inventory
)
*
types
.
ParaTxDetails
{
func
requestMainBlockWithTime
(
cfg
*
types
.
Chain33Config
,
inv
*
inventory
)
*
types
.
ParaTxDetails
{
retCh
:=
make
(
chan
*
types
.
ParaTxDetails
,
1
)
retCh
:=
make
(
chan
*
types
.
ParaTxDetails
,
1
)
go
func
()
{
go
func
()
{
tx
,
err
:=
requestMainBlocks
(
inv
)
tx
,
err
:=
requestMainBlocks
(
cfg
,
inv
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"requestMainBlockWithTime err"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
,
"err"
,
err
.
Error
())
plog
.
Error
(
"requestMainBlockWithTime err"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
,
"err"
,
err
.
Error
())
close
(
retCh
)
close
(
retCh
)
...
@@ -483,6 +489,7 @@ func requestMainBlockWithTime(inv *inventory) *types.ParaTxDetails {
...
@@ -483,6 +489,7 @@ func requestMainBlockWithTime(inv *inventory) *types.ParaTxDetails {
}
}
func
(
d
*
downloadJob
)
getInvBlocks
(
inv
*
inventory
,
connPool
chan
*
connectCli
)
{
func
(
d
*
downloadJob
)
getInvBlocks
(
inv
*
inventory
,
connPool
chan
*
connectCli
)
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
connPool
<-
inv
.
connCli
connPool
<-
inv
.
connCli
...
@@ -492,7 +499,7 @@ func (d *downloadJob) getInvBlocks(inv *inventory, connPool chan *connectCli) {
...
@@ -492,7 +499,7 @@ func (d *downloadJob) getInvBlocks(inv *inventory, connPool chan *connectCli) {
inv
.
curHeight
=
inv
.
start
inv
.
curHeight
=
inv
.
start
plog
.
Debug
(
"getInvBlocks begin"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
)
plog
.
Debug
(
"getInvBlocks begin"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
)
for
{
for
{
txs
:=
requestMainBlockWithTime
(
inv
)
txs
:=
requestMainBlockWithTime
(
cfg
,
inv
)
if
txs
==
nil
||
len
(
txs
.
Items
)
==
0
{
if
txs
==
nil
||
len
(
txs
.
Items
)
==
0
{
d
.
resetInv
(
inv
)
d
.
resetInv
(
inv
)
plog
.
Error
(
"getInvBlocks reqMainBlock nil"
,
"ip"
,
inv
.
connCli
.
ip
)
plog
.
Error
(
"getInvBlocks reqMainBlock nil"
,
"ip"
,
inv
.
connCli
.
ip
)
...
...
plugin/consensus/para/parasync.go
View file @
02830e68
...
@@ -272,19 +272,20 @@ func (client *blockSyncClient) delLocalBlocks(startHeight int64, endHeight int64
...
@@ -272,19 +272,20 @@ func (client *blockSyncClient) delLocalBlocks(startHeight int64, endHeight int64
index
:=
startHeight
index
:=
startHeight
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
for
{
for
{
if
index
>
endHeight
{
if
index
>
endHeight
{
break
break
}
}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
index
)
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
index
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
index
++
index
++
}
}
key
:=
calcTitleFirstHeightKey
(
types
.
GetTitle
())
key
:=
calcTitleFirstHeightKey
(
cfg
.
GetTitle
())
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
endHeight
+
1
})}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
endHeight
+
1
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
@@ -296,10 +297,10 @@ func (client *blockSyncClient) delLocalBlocks(startHeight int64, endHeight int64
...
@@ -296,10 +297,10 @@ func (client *blockSyncClient) delLocalBlocks(startHeight int64, endHeight int64
//最低高度没有设置的时候设置一下最低高度
//最低高度没有设置的时候设置一下最低高度
func
(
client
*
blockSyncClient
)
initFirstLocalHeightIfNeed
()
error
{
func
(
client
*
blockSyncClient
)
initFirstLocalHeightIfNeed
()
error
{
height
,
err
:=
client
.
getFirstLocalHeight
()
height
,
err
:=
client
.
getFirstLocalHeight
()
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
if
err
!=
nil
||
height
<
0
{
if
err
!=
nil
||
height
<
0
{
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleFirstHeightKey
(
types
.
GetTitle
())
key
:=
calcTitleFirstHeightKey
(
cfg
.
GetTitle
())
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
0
})}
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
0
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
@@ -311,7 +312,8 @@ func (client *blockSyncClient) initFirstLocalHeightIfNeed() error {
...
@@ -311,7 +312,8 @@ func (client *blockSyncClient) initFirstLocalHeightIfNeed() error {
//获取下载层缓冲数据的区块最低高度
//获取下载层缓冲数据的区块最低高度
func
(
client
*
blockSyncClient
)
getFirstLocalHeight
()
(
int64
,
error
)
{
func
(
client
*
blockSyncClient
)
getFirstLocalHeight
()
(
int64
,
error
)
{
key
:=
calcTitleFirstHeightKey
(
types
.
GetTitle
())
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
key
:=
calcTitleFirstHeightKey
(
cfg
.
GetTitle
())
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
value
,
err
:=
client
.
paraClient
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
value
,
err
:=
client
.
paraClient
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -356,8 +358,9 @@ func (client *blockSyncClient) clearLocalOldBlocks() (bool, error) {
...
@@ -356,8 +358,9 @@ func (client *blockSyncClient) clearLocalOldBlocks() (bool, error) {
// miner tx need all para node create, but not all node has auth account, here just not sign to keep align
// miner tx need all para node create, but not all node has auth account, here just not sign to keep align
func
(
client
*
blockSyncClient
)
addMinerTx
(
preStateHash
[]
byte
,
block
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
func
(
client
*
blockSyncClient
)
addMinerTx
(
preStateHash
[]
byte
,
block
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
status
:=
&
pt
.
ParacrossNodeStatus
{
status
:=
&
pt
.
ParacrossNodeStatus
{
Title
:
types
.
GetTitle
(),
Title
:
cfg
.
GetTitle
(),
Height
:
block
.
Height
,
Height
:
block
.
Height
,
PreBlockHash
:
block
.
ParentHash
,
PreBlockHash
:
block
.
ParentHash
,
PreStateHash
:
preStateHash
,
PreStateHash
:
preStateHash
,
...
@@ -365,7 +368,7 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
...
@@ -365,7 +368,7 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
MainBlockHeight
:
localBlock
.
MainHeight
,
MainBlockHeight
:
localBlock
.
MainHeight
,
}
}
tx
,
err
:=
pt
.
CreateRawMinerTx
(
&
pt
.
ParacrossMinerAction
{
tx
,
err
:=
pt
.
CreateRawMinerTx
(
cfg
,
&
pt
.
ParacrossMinerAction
{
Status
:
status
,
Status
:
status
,
IsSelfConsensus
:
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
),
IsSelfConsensus
:
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
),
})
})
...
@@ -381,8 +384,9 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
...
@@ -381,8 +384,9 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
//添加一个区块
//添加一个区块
func
(
client
*
blockSyncClient
)
addBlock
(
lastBlock
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
func
(
client
*
blockSyncClient
)
addBlock
(
lastBlock
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
var
newBlock
types
.
Block
var
newBlock
types
.
Block
newBlock
.
ParentHash
=
lastBlock
.
Hash
()
newBlock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newBlock
.
Height
=
lastBlock
.
Height
+
1
newBlock
.
Height
=
lastBlock
.
Height
+
1
newBlock
.
Txs
=
localBlock
.
Txs
newBlock
.
Txs
=
localBlock
.
Txs
err
:=
client
.
addMinerTx
(
lastBlock
.
StateHash
,
&
newBlock
,
localBlock
)
err
:=
client
.
addMinerTx
(
lastBlock
.
StateHash
,
&
newBlock
,
localBlock
)
...
@@ -390,7 +394,7 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
...
@@ -390,7 +394,7 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
return
err
return
err
}
}
//挖矿固定难度
//挖矿固定难度
newBlock
.
Difficulty
=
types
.
GetP
(
0
)
.
PowLimitBits
newBlock
.
Difficulty
=
cfg
.
GetP
(
0
)
.
PowLimitBits
newBlock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newBlock
.
Txs
)
newBlock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newBlock
.
Txs
)
newBlock
.
BlockTime
=
localBlock
.
BlockTime
newBlock
.
BlockTime
=
localBlock
.
BlockTime
newBlock
.
MainHash
=
localBlock
.
MainHash
newBlock
.
MainHash
=
localBlock
.
MainHash
...
...
plugin/dapp/autonomy/commands/proposal_board.go
View file @
02830e68
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"fmt"
)
)
// AutonomyCmd 自治系统命令行
// AutonomyCmd 自治系统命令行
...
@@ -99,6 +100,12 @@ func addProposalBoardFlags(cmd *cobra.Command) {
...
@@ -99,6 +100,12 @@ func addProposalBoardFlags(cmd *cobra.Command) {
}
}
func
proposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
proposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
@@ -126,7 +133,7 @@ func proposalBoard(cmd *cobra.Command, args []string) {
...
@@ -126,7 +133,7 @@ func proposalBoard(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropBoard"
,
ActionName
:
"PropBoard"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -153,6 +160,12 @@ func addRevokeProposalBoardFlags(cmd *cobra.Command) {
...
@@ -153,6 +160,12 @@ func addRevokeProposalBoardFlags(cmd *cobra.Command) {
}
}
func
revokeProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
revokeProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -164,7 +177,7 @@ func revokeProposalBoard(cmd *cobra.Command, args []string) {
...
@@ -164,7 +177,7 @@ func revokeProposalBoard(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropBoard"
,
ActionName
:
"RvkPropBoard"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -192,6 +205,12 @@ func addVoteProposalBoardFlags(cmd *cobra.Command) {
...
@@ -192,6 +205,12 @@ func addVoteProposalBoardFlags(cmd *cobra.Command) {
}
}
func
voteProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
voteProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
@@ -218,7 +237,7 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
...
@@ -218,7 +237,7 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropBoard"
,
ActionName
:
"VotePropBoard"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -245,6 +264,12 @@ func addTerminateProposalBoardFlags(cmd *cobra.Command) {
...
@@ -245,6 +264,12 @@ func addTerminateProposalBoardFlags(cmd *cobra.Command) {
}
}
func
terminateProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
terminateProposalBoard
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -256,7 +281,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) {
...
@@ -256,7 +281,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropBoard"
,
ActionName
:
"TmintPropBoard"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
...
plugin/dapp/autonomy/commands/proposal_change.go
View file @
02830e68
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"fmt"
)
)
// ProposalChangeCmd 创建提案命令
// ProposalChangeCmd 创建提案命令
...
@@ -41,6 +42,12 @@ func addProposalChangeFlags(cmd *cobra.Command) {
...
@@ -41,6 +42,12 @@ func addProposalChangeFlags(cmd *cobra.Command) {
}
}
func
proposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
proposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
@@ -85,7 +92,7 @@ func proposalChange(cmd *cobra.Command, args []string) {
...
@@ -85,7 +92,7 @@ func proposalChange(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropChange"
,
ActionName
:
"PropChange"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -112,6 +119,12 @@ func addRevokeProposalChangeFlags(cmd *cobra.Command) {
...
@@ -112,6 +119,12 @@ func addRevokeProposalChangeFlags(cmd *cobra.Command) {
}
}
func
revokeProposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
revokeProposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -123,7 +136,7 @@ func revokeProposalChange(cmd *cobra.Command, args []string) {
...
@@ -123,7 +136,7 @@ func revokeProposalChange(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropChange"
,
ActionName
:
"RvkPropChange"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -150,6 +163,12 @@ func addVoteProposalChangeFlags(cmd *cobra.Command) {
...
@@ -150,6 +163,12 @@ func addVoteProposalChangeFlags(cmd *cobra.Command) {
}
}
func
voteProposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
voteProposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
@@ -170,7 +189,7 @@ func voteProposalChange(cmd *cobra.Command, args []string) {
...
@@ -170,7 +189,7 @@ func voteProposalChange(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropChange"
,
ActionName
:
"VotePropChange"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -197,6 +216,12 @@ func addTerminateProposalChangeFlags(cmd *cobra.Command) {
...
@@ -197,6 +216,12 @@ func addTerminateProposalChangeFlags(cmd *cobra.Command) {
}
}
func
terminateProposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
terminateProposalChange
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -208,7 +233,7 @@ func terminateProposalChange(cmd *cobra.Command, args []string) {
...
@@ -208,7 +233,7 @@ func terminateProposalChange(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropChange"
,
ActionName
:
"TmintPropChange"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
...
plugin/dapp/autonomy/commands/proposal_project.go
View file @
02830e68
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"fmt"
)
)
// ProposalProjectCmd 创建提案命令
// ProposalProjectCmd 创建提案命令
...
@@ -53,6 +54,12 @@ func addProposalProjectFlags(cmd *cobra.Command) {
...
@@ -53,6 +54,12 @@ func addProposalProjectFlags(cmd *cobra.Command) {
}
}
func
proposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
proposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
@@ -95,7 +102,7 @@ func proposalProject(cmd *cobra.Command, args []string) {
...
@@ -95,7 +102,7 @@ func proposalProject(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropProject"
,
ActionName
:
"PropProject"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -122,6 +129,12 @@ func addRevokeProposalProjectFlags(cmd *cobra.Command) {
...
@@ -122,6 +129,12 @@ func addRevokeProposalProjectFlags(cmd *cobra.Command) {
}
}
func
revokeProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
revokeProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -133,7 +146,7 @@ func revokeProposalProject(cmd *cobra.Command, args []string) {
...
@@ -133,7 +146,7 @@ func revokeProposalProject(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropProject"
,
ActionName
:
"RvkPropProject"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -160,6 +173,12 @@ func addVoteProposalProjectFlags(cmd *cobra.Command) {
...
@@ -160,6 +173,12 @@ func addVoteProposalProjectFlags(cmd *cobra.Command) {
}
}
func
voteProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
voteProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
@@ -179,7 +198,7 @@ func voteProposalProject(cmd *cobra.Command, args []string) {
...
@@ -179,7 +198,7 @@ func voteProposalProject(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropProject"
,
ActionName
:
"VotePropProject"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -207,6 +226,12 @@ func addPubVoteProposalProjectFlags(cmd *cobra.Command) {
...
@@ -207,6 +226,12 @@ func addPubVoteProposalProjectFlags(cmd *cobra.Command) {
}
}
func
pubVoteProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
pubVoteProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
oppose
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"oppose"
)
oppose
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"oppose"
)
...
@@ -234,7 +259,7 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
...
@@ -234,7 +259,7 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PubVotePropProject"
,
ActionName
:
"PubVotePropProject"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -260,6 +285,12 @@ func addTerminateProposalProjectFlags(cmd *cobra.Command) {
...
@@ -260,6 +285,12 @@ func addTerminateProposalProjectFlags(cmd *cobra.Command) {
}
}
func
terminateProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
terminateProposalProject
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -271,7 +302,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) {
...
@@ -271,7 +302,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropProject"
,
ActionName
:
"TmintPropProject"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
...
plugin/dapp/autonomy/commands/proposal_rule.go
View file @
02830e68
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"fmt"
)
)
// ProposalRuleCmd 创建提案命令
// ProposalRuleCmd 创建提案命令
...
@@ -45,6 +46,12 @@ func addProposalRuleFlags(cmd *cobra.Command) {
...
@@ -45,6 +46,12 @@ func addProposalRuleFlags(cmd *cobra.Command) {
}
}
func
proposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
proposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
@@ -79,7 +86,7 @@ func proposalRule(cmd *cobra.Command, args []string) {
...
@@ -79,7 +86,7 @@ func proposalRule(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropRule"
,
ActionName
:
"PropRule"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -106,6 +113,12 @@ func addRevokeProposalRuleFlags(cmd *cobra.Command) {
...
@@ -106,6 +113,12 @@ func addRevokeProposalRuleFlags(cmd *cobra.Command) {
}
}
func
revokeProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
revokeProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -117,7 +130,7 @@ func revokeProposalRule(cmd *cobra.Command, args []string) {
...
@@ -117,7 +130,7 @@ func revokeProposalRule(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropRule"
,
ActionName
:
"RvkPropRule"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -145,6 +158,12 @@ func addVoteProposalRuleFlags(cmd *cobra.Command) {
...
@@ -145,6 +158,12 @@ func addVoteProposalRuleFlags(cmd *cobra.Command) {
}
}
func
voteProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
voteProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
@@ -171,7 +190,7 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
...
@@ -171,7 +190,7 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropRule"
,
ActionName
:
"VotePropRule"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -197,6 +216,12 @@ func addTerminateProposalRuleFlags(cmd *cobra.Command) {
...
@@ -197,6 +216,12 @@ func addTerminateProposalRuleFlags(cmd *cobra.Command) {
}
}
func
terminateProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
terminateProposalRule
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
@@ -208,7 +233,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) {
...
@@ -208,7 +233,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropRule"
,
ActionName
:
"TmintPropRule"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -321,6 +346,12 @@ func addTransferFundflags(cmd *cobra.Command) {
...
@@ -321,6 +346,12 @@ func addTransferFundflags(cmd *cobra.Command) {
}
}
func
transferFund
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
transferFund
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
...
@@ -334,7 +365,7 @@ func transferFund(cmd *cobra.Command, args []string) {
...
@@ -334,7 +365,7 @@ func transferFund(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"Transfer"
,
ActionName
:
"Transfer"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
@@ -363,6 +394,12 @@ func addCommentProposalflags(cmd *cobra.Command) {
...
@@ -363,6 +394,12 @@ func addCommentProposalflags(cmd *cobra.Command) {
}
}
func
commentProposal
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
commentProposal
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
proposalID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
proposalID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
repHash
,
_
:=
cmd
.
Flags
()
.
GetString
(
"repHash"
)
repHash
,
_
:=
cmd
.
Flags
()
.
GetString
(
"repHash"
)
...
@@ -378,7 +415,7 @@ func commentProposal(cmd *cobra.Command, args []string) {
...
@@ -378,7 +415,7 @@ func commentProposal(cmd *cobra.Command, args []string) {
return
return
}
}
pm
:=
&
rpctypes
.
CreateTxIn
{
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"CommentProp"
,
ActionName
:
"CommentProp"
,
Payload
:
payLoad
,
Payload
:
payLoad
,
}
}
...
...
plugin/dapp/dposvote/commands/vote.go
View file @
02830e68
...
@@ -86,6 +86,12 @@ func addRegistFlags(cmd *cobra.Command) {
...
@@ -86,6 +86,12 @@ func addRegistFlags(cmd *cobra.Command) {
}
}
func
regist
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
regist
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
...
@@ -93,7 +99,7 @@ func regist(cmd *cobra.Command, args []string) {
...
@@ -93,7 +99,7 @@ func regist(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
,
\"
IP
\"
:
\"
%s
\"
}"
,
pubkey
,
address
,
ip
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
,
\"
IP
\"
:
\"
%s
\"
}"
,
pubkey
,
address
,
ip
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRegistTx
,
ActionName
:
dty
.
CreateRegistTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -124,13 +130,19 @@ func addCancelRegistFlags(cmd *cobra.Command) {
...
@@ -124,13 +130,19 @@ func addCancelRegistFlags(cmd *cobra.Command) {
}
}
func
cancelRegist
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
cancelRegist
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
}"
,
pubkey
,
address
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
}"
,
pubkey
,
address
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateCancelRegistTx
,
ActionName
:
dty
.
CreateCancelRegistTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -161,6 +173,12 @@ func addVoteFlags(cmd *cobra.Command) {
...
@@ -161,6 +173,12 @@ func addVoteFlags(cmd *cobra.Command) {
}
}
func
vote
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
vote
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
votes
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"votes"
)
votes
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"votes"
)
...
@@ -168,7 +186,7 @@ func vote(cmd *cobra.Command, args []string) {
...
@@ -168,7 +186,7 @@ func vote(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
votes
\"
:
\"
%d
\"
,
\"
fromAddr
\"
:
\"
%s
\"
}"
,
pubkey
,
votes
,
addr
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
votes
\"
:
\"
%d
\"
,
\"
fromAddr
\"
:
\"
%s
\"
}"
,
pubkey
,
votes
,
addr
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateVoteTx
,
ActionName
:
dty
.
CreateVoteTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -198,13 +216,19 @@ func addCancelVoteFlags(cmd *cobra.Command) {
...
@@ -198,13 +216,19 @@ func addCancelVoteFlags(cmd *cobra.Command) {
}
}
func
cancelVote
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
cancelVote
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
index
\"
:
\"
%d
\"
}"
,
pubkey
,
index
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
index
\"
:
\"
%d
\"
}"
,
pubkey
,
index
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateCancelVoteTx
,
ActionName
:
dty
.
CreateCancelVoteTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -237,6 +261,12 @@ func addReRegistFlags(cmd *cobra.Command) {
...
@@ -237,6 +261,12 @@ func addReRegistFlags(cmd *cobra.Command) {
}
}
func
reRegist
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
reRegist
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
...
@@ -244,7 +274,7 @@ func reRegist(cmd *cobra.Command, args []string) {
...
@@ -244,7 +274,7 @@ func reRegist(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
,
\"
IP
\"
:
\"
%s
\"
}"
,
pubkey
,
address
,
ip
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
,
\"
IP
\"
:
\"
%s
\"
}"
,
pubkey
,
address
,
ip
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateReRegistTx
,
ActionName
:
dty
.
CreateReRegistTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -369,6 +399,12 @@ func addVrfMFlags(cmd *cobra.Command) {
...
@@ -369,6 +399,12 @@ func addVrfMFlags(cmd *cobra.Command) {
}
}
func
vrfM
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
vrfM
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
...
@@ -376,7 +412,7 @@ func vrfM(cmd *cobra.Command, args []string) {
...
@@ -376,7 +412,7 @@ func vrfM(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
cycle
\"
:
\"
%d
\"
,
\"
m
\"
:
\"
%s
\"
}"
,
pubkey
,
cycle
,
m
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
cycle
\"
:
\"
%d
\"
,
\"
m
\"
:
\"
%s
\"
}"
,
pubkey
,
cycle
,
m
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRegistVrfMTx
,
ActionName
:
dty
.
CreateRegistVrfMTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -412,6 +448,12 @@ func addVrfRPRegistFlags(cmd *cobra.Command) {
...
@@ -412,6 +448,12 @@ func addVrfRPRegistFlags(cmd *cobra.Command) {
}
}
func
vrfRP
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
vrfRP
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
...
@@ -420,7 +462,7 @@ func vrfRP(cmd *cobra.Command, args []string) {
...
@@ -420,7 +462,7 @@ func vrfRP(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
cycle
\"
:
\"
%d
\"
,
\"
r
\"
:
\"
%s
\"
,
\"
p
\"
:
\"
%s
\"
}"
,
pubkey
,
cycle
,
hash
,
proof
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
cycle
\"
:
\"
%d
\"
,
\"
r
\"
:
\"
%s
\"
,
\"
p
\"
:
\"
%s
\"
}"
,
pubkey
,
cycle
,
hash
,
proof
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRegistVrfRPTx
,
ActionName
:
dty
.
CreateRegistVrfRPTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -805,6 +847,12 @@ func recordCB(cmd *cobra.Command, args []string) {
...
@@ -805,6 +847,12 @@ func recordCB(cmd *cobra.Command, args []string) {
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"privKey"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"privKey"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
...
@@ -851,7 +899,7 @@ func recordCB(cmd *cobra.Command, args []string) {
...
@@ -851,7 +899,7 @@ func recordCB(cmd *cobra.Command, args []string) {
cycle
,
height
,
hash
,
hex
.
EncodeToString
(
privKey
.
PubKey
()
.
Bytes
()),
sig
)
cycle
,
height
,
hash
,
hex
.
EncodeToString
(
privKey
.
PubKey
()
.
Bytes
()),
sig
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRecordCBTx
,
ActionName
:
dty
.
CreateRecordCBTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
...
plugin/dapp/evm/commands/evm.go
View file @
02830e68
...
@@ -214,6 +214,12 @@ func addCreateContractFlags(cmd *cobra.Command) {
...
@@ -214,6 +214,12 @@ func addCreateContractFlags(cmd *cobra.Command) {
}
}
func
createContract
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createContract
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
code
,
_
:=
cmd
.
Flags
()
.
GetString
(
"input"
)
code
,
_
:=
cmd
.
Flags
()
.
GetString
(
"input"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
...
@@ -268,7 +274,7 @@ func createContract(cmd *cobra.Command, args []string) {
...
@@ -268,7 +274,7 @@ func createContract(cmd *cobra.Command, args []string) {
action
=
evmtypes
.
EVMContractAction
{
Amount
:
0
,
Code
:
bCode
,
GasLimit
:
0
,
GasPrice
:
0
,
Note
:
note
,
Alias
:
alias
,
Abi
:
abi
}
action
=
evmtypes
.
EVMContractAction
{
Amount
:
0
,
Code
:
bCode
,
GasLimit
:
0
,
GasPrice
:
0
,
Note
:
note
,
Alias
:
alias
,
Abi
:
abi
}
}
}
data
,
err
:=
createEvmTx
(
&
action
,
types
.
ExecName
(
paraName
+
"evm"
),
caller
,
address
.
ExecAddress
(
types
.
ExecName
(
paraName
+
"evm"
)),
expire
,
rpcLaddr
,
feeInt64
)
data
,
err
:=
createEvmTx
(
cfg
,
&
action
,
cfg
.
ExecName
(
paraName
+
"evm"
),
caller
,
address
.
ExecAddress
(
cfg
.
ExecName
(
paraName
+
"evm"
)),
expire
,
rpcLaddr
,
feeInt64
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract error:"
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract error:"
,
err
)
...
@@ -283,10 +289,10 @@ func createContract(cmd *cobra.Command, args []string) {
...
@@ -283,10 +289,10 @@ func createContract(cmd *cobra.Command, args []string) {
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
func
createEvmTx
(
action
proto
.
Message
,
execer
,
caller
,
addr
,
expire
,
rpcLaddr
string
,
fee
uint64
)
(
string
,
error
)
{
func
createEvmTx
(
cfg
*
types
.
Chain33Config
,
action
proto
.
Message
,
execer
,
caller
,
addr
,
expire
,
rpcLaddr
string
,
fee
uint64
)
(
string
,
error
)
{
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
execer
),
Payload
:
types
.
Encode
(
action
),
Fee
:
0
,
To
:
addr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
execer
),
Payload
:
types
.
Encode
(
action
),
Fee
:
0
,
To
:
addr
}
tx
.
Fee
,
_
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
tx
.
Fee
,
_
=
tx
.
GetRealFee
(
cfg
.
GInt
(
"MinFee"
))
if
tx
.
Fee
<
int64
(
fee
)
{
if
tx
.
Fee
<
int64
(
fee
)
{
tx
.
Fee
+=
int64
(
fee
)
tx
.
Fee
+=
int64
(
fee
)
}
}
...
@@ -318,7 +324,7 @@ func createEvmTx(action proto.Message, execer, caller, addr, expire, rpcLaddr st
...
@@ -318,7 +324,7 @@ func createEvmTx(action proto.Message, execer, caller, addr, expire, rpcLaddr st
return
res
,
nil
return
res
,
nil
}
}
func
createEvmTransferTx
(
cmd
*
cobra
.
Command
,
caller
,
execName
,
expire
,
rpcLaddr
string
,
amountInt64
int64
,
isWithdraw
bool
)
(
string
,
error
)
{
func
createEvmTransferTx
(
c
fg
*
types
.
Chain33Config
,
c
md
*
cobra
.
Command
,
caller
,
execName
,
expire
,
rpcLaddr
string
,
amountInt64
int64
,
isWithdraw
bool
)
(
string
,
error
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
var
tx
*
types
.
Transaction
var
tx
*
types
.
Transaction
transfer
:=
&
cty
.
CoinsAction
{}
transfer
:=
&
cty
.
CoinsAction
{}
...
@@ -331,13 +337,13 @@ func createEvmTransferTx(cmd *cobra.Command, caller, execName, expire, rpcLaddr
...
@@ -331,13 +337,13 @@ func createEvmTransferTx(cmd *cobra.Command, caller, execName, expire, rpcLaddr
transfer
.
Ty
=
cty
.
CoinsActionTransferToExec
transfer
.
Ty
=
cty
.
CoinsActionTransferToExec
}
}
if
paraName
==
""
{
if
paraName
==
""
{
tx
=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
paraName
+
"coins"
)),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
execName
)}
tx
=
&
types
.
Transaction
{
Execer
:
[]
byte
(
cfg
.
ExecName
(
paraName
+
"coins"
)),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
execName
)}
}
else
{
}
else
{
tx
=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
paraName
+
"coins"
)),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
types
.
ExecName
(
paraName
+
"coins"
))}
tx
=
&
types
.
Transaction
{
Execer
:
[]
byte
(
cfg
.
ExecName
(
paraName
+
"coins"
)),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
cfg
.
ExecName
(
paraName
+
"coins"
))}
}
}
var
err
error
var
err
error
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
cfg
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -381,6 +387,12 @@ func callContractCmd() *cobra.Command {
...
@@ -381,6 +387,12 @@ func callContractCmd() *cobra.Command {
}
}
func
callContract
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
callContract
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
code
,
_
:=
cmd
.
Flags
()
.
GetString
(
"input"
)
code
,
_
:=
cmd
.
Flags
()
.
GetString
(
"input"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
...
@@ -404,7 +416,7 @@ func callContract(cmd *cobra.Command, args []string) {
...
@@ -404,7 +416,7 @@ func callContract(cmd *cobra.Command, args []string) {
action
:=
evmtypes
.
EVMContractAction
{
Amount
:
amountInt64
,
Code
:
bCode
,
GasLimit
:
0
,
GasPrice
:
0
,
Note
:
note
,
Abi
:
abi
}
action
:=
evmtypes
.
EVMContractAction
{
Amount
:
amountInt64
,
Code
:
bCode
,
GasLimit
:
0
,
GasPrice
:
0
,
Note
:
note
,
Abi
:
abi
}
//name表示发给哪个执行器
//name表示发给哪个执行器
data
,
err
:=
createEvmTx
(
&
action
,
name
,
caller
,
toAddr
,
expire
,
rpcLaddr
,
feeInt64
)
data
,
err
:=
createEvmTx
(
cfg
,
&
action
,
name
,
caller
,
toAddr
,
expire
,
rpcLaddr
,
feeInt64
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"call contract error"
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
"call contract error"
,
err
)
...
@@ -701,6 +713,12 @@ func addEvmTransferFlags(cmd *cobra.Command) {
...
@@ -701,6 +713,12 @@ func addEvmTransferFlags(cmd *cobra.Command) {
}
}
func
evmTransfer
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
evmTransfer
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
...
@@ -709,7 +727,7 @@ func evmTransfer(cmd *cobra.Command, args []string) {
...
@@ -709,7 +727,7 @@ func evmTransfer(cmd *cobra.Command, args []string) {
amountInt64
:=
int64
(
amount
*
1e4
)
*
1e4
amountInt64
:=
int64
(
amount
*
1e4
)
*
1e4
data
,
err
:=
createEvmTransferTx
(
cmd
,
caller
,
to
,
expire
,
rpcLaddr
,
amountInt64
,
false
)
data
,
err
:=
createEvmTransferTx
(
c
fg
,
c
md
,
caller
,
to
,
expire
,
rpcLaddr
,
amountInt64
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract transfer error:"
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract transfer error:"
,
err
)
...
@@ -749,6 +767,12 @@ func addEvmWithdrawFlags(cmd *cobra.Command) {
...
@@ -749,6 +767,12 @@ func addEvmWithdrawFlags(cmd *cobra.Command) {
}
}
func
evmWithdraw
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
evmWithdraw
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
...
@@ -757,7 +781,7 @@ func evmWithdraw(cmd *cobra.Command, args []string) {
...
@@ -757,7 +781,7 @@ func evmWithdraw(cmd *cobra.Command, args []string) {
amountInt64
:=
int64
(
amount
*
1e4
)
*
1e4
amountInt64
:=
int64
(
amount
*
1e4
)
*
1e4
data
,
err
:=
createEvmTransferTx
(
cmd
,
caller
,
from
,
expire
,
rpcLaddr
,
amountInt64
,
true
)
data
,
err
:=
createEvmTransferTx
(
c
fg
,
c
md
,
caller
,
from
,
expire
,
rpcLaddr
,
amountInt64
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract transfer error:"
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract transfer error:"
,
err
)
...
...
plugin/dapp/evm/executor/exec.go
View file @
02830e68
...
@@ -74,7 +74,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
...
@@ -74,7 +74,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
return
receipt
,
err
return
receipt
,
err
}
}
}
}
ret
,
snapshot
,
leftOverGas
,
vmerr
=
env
.
Create
(
cfg
,
runtime
.
AccountRef
(
msg
.
From
()),
contractAddr
,
msg
.
Data
(),
context
.
GasLimit
,
execName
,
msg
.
Alias
(),
msg
.
ABI
())
ret
,
snapshot
,
leftOverGas
,
vmerr
=
env
.
Create
(
runtime
.
AccountRef
(
msg
.
From
()),
contractAddr
,
msg
.
Data
(),
context
.
GasLimit
,
execName
,
msg
.
Alias
(),
msg
.
ABI
())
}
else
{
}
else
{
inData
:=
msg
.
Data
()
inData
:=
msg
.
Data
()
// 在这里进行ABI和十六进制的调用参数转换
// 在这里进行ABI和十六进制的调用参数转换
...
@@ -86,7 +86,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
...
@@ -86,7 +86,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
inData
=
packData
inData
=
packData
methodName
=
funcName
methodName
=
funcName
}
}
ret
,
snapshot
,
leftOverGas
,
vmerr
=
env
.
Call
(
cfg
,
runtime
.
AccountRef
(
msg
.
From
()),
*
msg
.
To
(),
inData
,
context
.
GasLimit
,
msg
.
Value
())
ret
,
snapshot
,
leftOverGas
,
vmerr
=
env
.
Call
(
runtime
.
AccountRef
(
msg
.
From
()),
*
msg
.
To
(),
inData
,
context
.
GasLimit
,
msg
.
Value
())
}
}
log
.
Debug
(
"call(create) contract "
,
"input"
,
common
.
Bytes2Hex
(
msg
.
Data
()))
log
.
Debug
(
"call(create) contract "
,
"input"
,
common
.
Bytes2Hex
(
msg
.
Data
()))
...
...
plugin/dapp/evm/executor/exec_del_local.go
View file @
02830e68
...
@@ -18,8 +18,8 @@ func (evm *EVMExecutor) ExecDelLocal(tx *types.Transaction, receipt *types.Recei
...
@@ -18,8 +18,8 @@ func (evm *EVMExecutor) ExecDelLocal(tx *types.Transaction, receipt *types.Recei
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
set
,
nil
return
set
,
nil
}
}
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
if
types
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
if
cfg
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
// 需要将Exec中生成的合约状态变更信息从localdb中恢复
// 需要将Exec中生成的合约状态变更信息从localdb中恢复
for
_
,
logItem
:=
range
receipt
.
Logs
{
for
_
,
logItem
:=
range
receipt
.
Logs
{
if
evmtypes
.
TyLogEVMStateChangeItem
==
logItem
.
Ty
{
if
evmtypes
.
TyLogEVMStateChangeItem
==
logItem
.
Ty
{
...
...
plugin/dapp/evm/executor/exec_local.go
View file @
02830e68
...
@@ -20,7 +20,8 @@ func (evm *EVMExecutor) ExecLocal(tx *types.Transaction, receipt *types.ReceiptD
...
@@ -20,7 +20,8 @@ func (evm *EVMExecutor) ExecLocal(tx *types.Transaction, receipt *types.ReceiptD
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
set
,
nil
return
set
,
nil
}
}
if
types
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsDappFork
(
evm
.
GetHeight
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
// 需要将Exec中生成的合约状态变更信息写入localdb
// 需要将Exec中生成的合约状态变更信息写入localdb
for
_
,
logItem
:=
range
receipt
.
Logs
{
for
_
,
logItem
:=
range
receipt
.
Logs
{
if
evmtypes
.
TyLogEVMStateChangeItem
==
logItem
.
Ty
{
if
evmtypes
.
TyLogEVMStateChangeItem
==
logItem
.
Ty
{
...
...
plugin/dapp/evm/executor/query.go
View file @
02830e68
...
@@ -27,7 +27,8 @@ func (evm *EVMExecutor) Query_CheckAddrExists(in *evmtypes.CheckEVMAddrReq) (typ
...
@@ -27,7 +27,8 @@ func (evm *EVMExecutor) Query_CheckAddrExists(in *evmtypes.CheckEVMAddrReq) (typ
var
addr
common
.
Address
var
addr
common
.
Address
// 合约名称
// 合约名称
if
strings
.
HasPrefix
(
addrStr
,
types
.
ExecName
(
evmtypes
.
EvmPrefix
))
{
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
if
strings
.
HasPrefix
(
addrStr
,
cfg
.
ExecName
(
evmtypes
.
EvmPrefix
))
{
addr
=
common
.
ExecAddress
(
addrStr
)
addr
=
common
.
ExecAddress
(
addrStr
)
}
else
{
}
else
{
// 合约地址
// 合约地址
...
@@ -57,7 +58,7 @@ func (evm *EVMExecutor) Query_EstimateGas(in *evmtypes.EstimateEVMGasReq) (types
...
@@ -57,7 +58,7 @@ func (evm *EVMExecutor) Query_EstimateGas(in *evmtypes.EstimateEVMGasReq) (types
var
(
var
(
caller
common
.
Address
caller
common
.
Address
)
)
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
// 如果未指定调用地址,则直接使用一个虚拟的地址发起调用
// 如果未指定调用地址,则直接使用一个虚拟的地址发起调用
if
len
(
in
.
Caller
)
>
0
{
if
len
(
in
.
Caller
)
>
0
{
callAddr
:=
common
.
StringToAddress
(
in
.
Caller
)
callAddr
:=
common
.
StringToAddress
(
in
.
Caller
)
...
@@ -65,7 +66,7 @@ func (evm *EVMExecutor) Query_EstimateGas(in *evmtypes.EstimateEVMGasReq) (types
...
@@ -65,7 +66,7 @@ func (evm *EVMExecutor) Query_EstimateGas(in *evmtypes.EstimateEVMGasReq) (types
caller
=
*
callAddr
caller
=
*
callAddr
}
}
}
else
{
}
else
{
caller
=
common
.
ExecAddress
(
types
.
ExecName
(
evmtypes
.
ExecutorName
))
caller
=
common
.
ExecAddress
(
cfg
.
ExecName
(
evmtypes
.
ExecutorName
))
}
}
to
:=
common
.
StringToAddress
(
in
.
To
)
to
:=
common
.
StringToAddress
(
in
.
To
)
...
@@ -143,13 +144,14 @@ func (evm *EVMExecutor) Query_Query(in *evmtypes.EvmQueryReq) (types.Message, er
...
@@ -143,13 +144,14 @@ func (evm *EVMExecutor) Query_Query(in *evmtypes.EvmQueryReq) (types.Message, er
}
}
// 如果未指定调用地址,则直接使用一个虚拟的地址发起调用
// 如果未指定调用地址,则直接使用一个虚拟的地址发起调用
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
if
len
(
in
.
Caller
)
>
0
{
if
len
(
in
.
Caller
)
>
0
{
callAddr
:=
common
.
StringToAddress
(
in
.
Caller
)
callAddr
:=
common
.
StringToAddress
(
in
.
Caller
)
if
callAddr
!=
nil
{
if
callAddr
!=
nil
{
caller
=
*
callAddr
caller
=
*
callAddr
}
}
}
else
{
}
else
{
caller
=
common
.
ExecAddress
(
types
.
ExecName
(
evmtypes
.
ExecutorName
))
caller
=
common
.
ExecAddress
(
cfg
.
ExecName
(
evmtypes
.
ExecutorName
))
}
}
msg
:=
common
.
NewMessage
(
caller
,
common
.
StringToAddress
(
in
.
Address
),
0
,
0
,
evmtypes
.
MaxGasLimit
,
1
,
nil
,
"estimateGas"
,
in
.
Input
)
msg
:=
common
.
NewMessage
(
caller
,
common
.
StringToAddress
(
in
.
Address
),
0
,
0
,
evmtypes
.
MaxGasLimit
,
1
,
nil
,
"estimateGas"
,
in
.
Input
)
...
...
plugin/dapp/evm/executor/vm/runtime/evm.go
View file @
02830e68
...
@@ -169,7 +169,7 @@ func (evm *EVM) preCheck(caller ContractRef, recipient common.Address, value uin
...
@@ -169,7 +169,7 @@ func (evm *EVM) preCheck(caller ContractRef, recipient common.Address, value uin
// Call 此方法提供合约外部调用入口
// Call 此方法提供合约外部调用入口
// 根据合约地址调用已经存在的合约,input为合约调用参数
// 根据合约地址调用已经存在的合约,input为合约调用参数
// 合约调用逻辑支持在合约调用的同时进行向合约转账的操作
// 合约调用逻辑支持在合约调用的同时进行向合约转账的操作
func
(
evm
*
EVM
)
Call
(
c
fg
*
types
.
Chain33Config
,
c
aller
ContractRef
,
addr
common
.
Address
,
input
[]
byte
,
gas
uint64
,
value
uint64
)
(
ret
[]
byte
,
snapshot
int
,
leftOverGas
uint64
,
err
error
)
{
func
(
evm
*
EVM
)
Call
(
caller
ContractRef
,
addr
common
.
Address
,
input
[]
byte
,
gas
uint64
,
value
uint64
)
(
ret
[]
byte
,
snapshot
int
,
leftOverGas
uint64
,
err
error
)
{
pass
,
err
:=
evm
.
preCheck
(
caller
,
addr
,
value
)
pass
,
err
:=
evm
.
preCheck
(
caller
,
addr
,
value
)
if
!
pass
{
if
!
pass
{
return
nil
,
-
1
,
gas
,
err
return
nil
,
-
1
,
gas
,
err
...
@@ -223,6 +223,7 @@ func (evm *EVM) Call(cfg *types.Chain33Config, caller ContractRef, addr common.A
...
@@ -223,6 +223,7 @@ func (evm *EVM) Call(cfg *types.Chain33Config, caller ContractRef, addr common.A
}
}
// 从ForkV20EVMState开始,状态数据存储发生变更,需要做数据迁移
// 从ForkV20EVMState开始,状态数据存储发生变更,需要做数据迁移
cfg
:=
evm
.
StateDB
.
GetConfig
()
if
cfg
.
IsDappFork
(
evm
.
BlockNumber
.
Int64
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
if
cfg
.
IsDappFork
(
evm
.
BlockNumber
.
Int64
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
evm
.
StateDB
.
TransferStateData
(
addr
.
String
())
evm
.
StateDB
.
TransferStateData
(
addr
.
String
())
}
}
...
@@ -357,7 +358,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
...
@@ -357,7 +358,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
// 使用传入的部署代码创建新的合约;
// 使用传入的部署代码创建新的合约;
// 目前chain33为了保证账户安全,不允许合约中涉及到外部账户的转账操作,
// 目前chain33为了保证账户安全,不允许合约中涉及到外部账户的转账操作,
// 所以,本步骤不接收转账金额参数
// 所以,本步骤不接收转账金额参数
func
(
evm
*
EVM
)
Create
(
c
fg
*
types
.
Chain33Config
,
c
aller
ContractRef
,
contractAddr
common
.
Address
,
code
[]
byte
,
gas
uint64
,
execName
,
alias
,
abi
string
)
(
ret
[]
byte
,
snapshot
int
,
leftOverGas
uint64
,
err
error
)
{
func
(
evm
*
EVM
)
Create
(
caller
ContractRef
,
contractAddr
common
.
Address
,
code
[]
byte
,
gas
uint64
,
execName
,
alias
,
abi
string
)
(
ret
[]
byte
,
snapshot
int
,
leftOverGas
uint64
,
err
error
)
{
pass
,
err
:=
evm
.
preCheck
(
caller
,
contractAddr
,
0
)
pass
,
err
:=
evm
.
preCheck
(
caller
,
contractAddr
,
0
)
if
!
pass
{
if
!
pass
{
return
nil
,
-
1
,
gas
,
err
return
nil
,
-
1
,
gas
,
err
...
@@ -382,6 +383,7 @@ func (evm *EVM) Create(cfg *types.Chain33Config, caller ContractRef, contractAdd
...
@@ -382,6 +383,7 @@ func (evm *EVM) Create(cfg *types.Chain33Config, caller ContractRef, contractAdd
// 检查部署后的合约代码大小是否超限
// 检查部署后的合约代码大小是否超限
maxCodeSizeExceeded
:=
len
(
ret
)
>
evm
.
maxCodeSize
maxCodeSizeExceeded
:=
len
(
ret
)
>
evm
.
maxCodeSize
cfg
:=
evm
.
StateDB
.
GetConfig
()
// 如果执行成功,计算存储合约代码需要花费的Gas
// 如果执行成功,计算存储合约代码需要花费的Gas
if
err
==
nil
&&
!
maxCodeSizeExceeded
{
if
err
==
nil
&&
!
maxCodeSizeExceeded
{
createDataGas
:=
uint64
(
len
(
ret
))
*
params
.
CreateDataGas
createDataGas
:=
uint64
(
len
(
ret
))
*
params
.
CreateDataGas
...
...
plugin/dapp/evm/executor/vm/state/interface.go
View file @
02830e68
...
@@ -7,6 +7,7 @@ package state
...
@@ -7,6 +7,7 @@ package state
import
(
import
(
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/model"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/model"
"github.com/33cn/chain33/types"
)
)
// EVMStateDB 状态数据库封装,面向EVM业务执行逻辑;
// EVMStateDB 状态数据库封装,面向EVM业务执行逻辑;
...
@@ -81,4 +82,7 @@ type EVMStateDB interface {
...
@@ -81,4 +82,7 @@ type EVMStateDB interface {
// GetBlockHeight 返回当前区块高度
// GetBlockHeight 返回当前区块高度
GetBlockHeight
()
int64
GetBlockHeight
()
int64
// GetConfig 获取系统配置
GetConfig
()
*
types
.
Chain33Config
}
}
plugin/dapp/evm/executor/vm/state/statedb.go
View file @
02830e68
...
@@ -738,3 +738,8 @@ func (mdb *MemoryStateDB) ResetDatas() {
...
@@ -738,3 +738,8 @@ func (mdb *MemoryStateDB) ResetDatas() {
func
(
mdb
*
MemoryStateDB
)
GetBlockHeight
()
int64
{
func
(
mdb
*
MemoryStateDB
)
GetBlockHeight
()
int64
{
return
mdb
.
blockHeight
return
mdb
.
blockHeight
}
}
// GetConfig 获取系统配置
func
(
mdb
*
MemoryStateDB
)
GetConfig
()
*
types
.
Chain33Config
{
return
mdb
.
api
.
GetConfig
()
}
\ No newline at end of file
plugin/dapp/guess/commands/game.go
View file @
02830e68
...
@@ -65,6 +65,12 @@ func addGuessStartFlags(cmd *cobra.Command) {
...
@@ -65,6 +65,12 @@ func addGuessStartFlags(cmd *cobra.Command) {
}
}
func
guessStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
topic
,
_
:=
cmd
.
Flags
()
.
GetString
(
"topic"
)
topic
,
_
:=
cmd
.
Flags
()
.
GetString
(
"topic"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
...
@@ -80,7 +86,7 @@ func guessStart(cmd *cobra.Command, args []string) {
...
@@ -80,7 +86,7 @@ func guessStart(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
topic
\"
:
\"
%s
\"
,
\"
options
\"
:
\"
%s
\"
,
\"
category
\"
:
\"
%s
\"
,
\"
maxBetHeight
\"
:%d,
\"
maxBetsOneTime
\"
:%d,
\"
maxBetsNumber
\"
:%d,
\"
devFeeFactor
\"
:%d,
\"
platFeeFactor
\"
:%d,
\"
expireHeight
\"
:%d,
\"
devFeeAddr
\"
:
\"
%s
\"
,
\"
platFeeAddr
\"
:
\"
%s
\"
}"
,
topic
,
options
,
category
,
maxBetHeight
,
maxBetsOneTime
,
maxBetsNumber
,
devFeeFactor
,
platFeeFactor
,
expireHeight
,
devFeeAddr
,
platFeeAddr
)
payload
:=
fmt
.
Sprintf
(
"{
\"
topic
\"
:
\"
%s
\"
,
\"
options
\"
:
\"
%s
\"
,
\"
category
\"
:
\"
%s
\"
,
\"
maxBetHeight
\"
:%d,
\"
maxBetsOneTime
\"
:%d,
\"
maxBetsNumber
\"
:%d,
\"
devFeeFactor
\"
:%d,
\"
platFeeFactor
\"
:%d,
\"
expireHeight
\"
:%d,
\"
devFeeAddr
\"
:
\"
%s
\"
,
\"
platFeeAddr
\"
:
\"
%s
\"
}"
,
topic
,
options
,
category
,
maxBetHeight
,
maxBetsOneTime
,
maxBetsNumber
,
devFeeFactor
,
platFeeFactor
,
expireHeight
,
devFeeAddr
,
platFeeAddr
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateStartTx
,
ActionName
:
gty
.
CreateStartTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -112,6 +118,12 @@ func addGuessBetFlags(cmd *cobra.Command) {
...
@@ -112,6 +118,12 @@ func addGuessBetFlags(cmd *cobra.Command) {
}
}
func
guessBet
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessBet
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
option
,
_
:=
cmd
.
Flags
()
.
GetString
(
"option"
)
option
,
_
:=
cmd
.
Flags
()
.
GetString
(
"option"
)
...
@@ -119,7 +131,7 @@ func guessBet(cmd *cobra.Command, args []string) {
...
@@ -119,7 +131,7 @@ func guessBet(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
option
\"
:
\"
%s
\"
,
\"
betsNum
\"
:%d}"
,
gameID
,
option
,
betsNumber
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
option
\"
:
\"
%s
\"
,
\"
betsNum
\"
:%d}"
,
gameID
,
option
,
betsNumber
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateBetTx
,
ActionName
:
gty
.
CreateBetTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -147,12 +159,18 @@ func addGuessStopBetFlags(cmd *cobra.Command) {
...
@@ -147,12 +159,18 @@ func addGuessStopBetFlags(cmd *cobra.Command) {
}
}
func
guessStopBet
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessStopBet
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateStopBetTx
,
ActionName
:
gty
.
CreateStopBetTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -179,12 +197,18 @@ func addGuessAbortFlags(cmd *cobra.Command) {
...
@@ -179,12 +197,18 @@ func addGuessAbortFlags(cmd *cobra.Command) {
}
}
func
guessAbort
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessAbort
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateAbortTx
,
ActionName
:
gty
.
CreateAbortTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
@@ -214,13 +238,19 @@ func addGuessPublishFlags(cmd *cobra.Command) {
...
@@ -214,13 +238,19 @@ func addGuessPublishFlags(cmd *cobra.Command) {
}
}
func
guessPublish
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessPublish
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
result
,
_
:=
cmd
.
Flags
()
.
GetString
(
"result"
)
result
,
_
:=
cmd
.
Flags
()
.
GetString
(
"result"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
gameID
,
result
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
gameID
,
result
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreatePublishTx
,
ActionName
:
gty
.
CreatePublishTx
,
Payload
:
[]
byte
(
payload
),
Payload
:
[]
byte
(
payload
),
}
}
...
...
plugin/dapp/hashlock/commands/hashlock.go
View file @
02830e68
...
@@ -44,6 +44,12 @@ func HashlockLockCmd() *cobra.Command {
...
@@ -44,6 +44,12 @@ func HashlockLockCmd() *cobra.Command {
}
}
func
addHashlockLockCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addHashlockLockCmdFlags
(
cmd
*
cobra
.
Command
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
cmd
.
Flags
()
.
StringP
(
"secret"
,
"s"
,
""
,
"secret information"
)
cmd
.
Flags
()
.
StringP
(
"secret"
,
"s"
,
""
,
"secret information"
)
cmd
.
MarkFlagRequired
(
"secret"
)
cmd
.
MarkFlagRequired
(
"secret"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"locking amount"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"locking amount"
)
...
@@ -55,7 +61,7 @@ func addHashlockLockCmdFlags(cmd *cobra.Command) {
...
@@ -55,7 +61,7 @@ func addHashlockLockCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"return"
,
"r"
,
""
,
"return address"
)
cmd
.
Flags
()
.
StringP
(
"return"
,
"r"
,
""
,
"return address"
)
cmd
.
MarkFlagRequired
(
"return"
)
cmd
.
MarkFlagRequired
(
"return"
)
defaultFee
:=
float64
(
types
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
defaultFee
:=
float64
(
cfg
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"transaction fee"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"transaction fee"
)
}
}
...
@@ -109,10 +115,16 @@ func HashlockUnlockCmd() *cobra.Command {
...
@@ -109,10 +115,16 @@ func HashlockUnlockCmd() *cobra.Command {
}
}
func
addHashlockCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addHashlockCmdFlags
(
cmd
*
cobra
.
Command
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
cmd
.
Flags
()
.
StringP
(
"secret"
,
"s"
,
""
,
"secret information"
)
cmd
.
Flags
()
.
StringP
(
"secret"
,
"s"
,
""
,
"secret information"
)
cmd
.
MarkFlagRequired
(
"secret"
)
cmd
.
MarkFlagRequired
(
"secret"
)
defaultFee
:=
float64
(
types
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
defaultFee
:=
float64
(
cfg
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"transaction fee"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"transaction fee"
)
}
}
...
...
plugin/dapp/js/types/js.go
View file @
02830e68
...
@@ -65,7 +65,7 @@ func InitFork(cfg *types.Chain33Config) {
...
@@ -65,7 +65,7 @@ func InitFork(cfg *types.Chain33Config) {
}
}
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
types
.
RegistorExecutor
(
"coins"
,
NewType
(
cfg
))
types
.
RegistorExecutor
(
JsX
,
NewType
(
cfg
))
}
}
//JsType 类型
//JsType 类型
...
...
plugin/dapp/oracle/commands/oracle.go
View file @
02830e68
...
@@ -88,6 +88,12 @@ func addPublishEventFlags(cmd *cobra.Command) {
...
@@ -88,6 +88,12 @@ func addPublishEventFlags(cmd *cobra.Command) {
}
}
func
publishEvent
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
publishEvent
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"publishEvent get rpc addr Error: %v"
,
err
)
fmt
.
Printf
(
"publishEvent get rpc addr Error: %v"
,
err
)
...
@@ -127,7 +133,7 @@ func publishEvent(cmd *cobra.Command, args []string) {
...
@@ -127,7 +133,7 @@ func publishEvent(cmd *cobra.Command, args []string) {
}
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateEventPublishTx
,
ActionName
:
oraclety
.
CreateEventPublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
type
\"
:
\"
%s
\"
,
\"
subType
\"
:
\"
%s
\"
,
\"
time
\"
:%d,
\"
content
\"
:
\"
%s
\"
,
\"
introduction
\"
:
\"
%s
\"
}"
,
ty
,
subType
,
t
.
Unix
(),
content
,
introduction
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
type
\"
:
\"
%s
\"
,
\"
subType
\"
:
\"
%s
\"
,
\"
time
\"
:%d,
\"
content
\"
:
\"
%s
\"
,
\"
introduction
\"
:
\"
%s
\"
}"
,
ty
,
subType
,
t
.
Unix
(),
content
,
introduction
)),
}
}
...
@@ -157,6 +163,12 @@ func addAbortPublishEventFlags(cmd *cobra.Command) {
...
@@ -157,6 +163,12 @@ func addAbortPublishEventFlags(cmd *cobra.Command) {
}
}
func
abortPublishEvent
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
abortPublishEvent
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"abortPublishEvent rpc_addr Error: %v"
,
err
)
fmt
.
Printf
(
"abortPublishEvent rpc_addr Error: %v"
,
err
)
...
@@ -169,7 +181,7 @@ func abortPublishEvent(cmd *cobra.Command, args []string) {
...
@@ -169,7 +181,7 @@ func abortPublishEvent(cmd *cobra.Command, args []string) {
}
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateAbortEventPublishTx
,
ActionName
:
oraclety
.
CreateAbortEventPublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
}"
,
eventID
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
}"
,
eventID
)),
}
}
...
@@ -213,6 +225,12 @@ func addPrePublishResultFlags(cmd *cobra.Command) {
...
@@ -213,6 +225,12 @@ func addPrePublishResultFlags(cmd *cobra.Command) {
}
}
func
prePublishResult
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
prePublishResult
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"prePublishResult rpc_laddr Error: %v"
,
err
)
fmt
.
Printf
(
"prePublishResult rpc_laddr Error: %v"
,
err
)
...
@@ -235,7 +253,7 @@ func prePublishResult(cmd *cobra.Command, args []string) {
...
@@ -235,7 +253,7 @@ func prePublishResult(cmd *cobra.Command, args []string) {
}
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreatePrePublishResultTx
,
ActionName
:
oraclety
.
CreatePrePublishResultTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
,
\"
source
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
eventID
,
source
,
result
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
,
\"
source
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
eventID
,
source
,
result
)),
}
}
...
@@ -265,6 +283,12 @@ func addAbortPrePubResultFlags(cmd *cobra.Command) {
...
@@ -265,6 +283,12 @@ func addAbortPrePubResultFlags(cmd *cobra.Command) {
}
}
func
abortPrePubResult
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
abortPrePubResult
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"abortPrePubResult rpc_laddr Error: %v"
,
err
)
fmt
.
Printf
(
"abortPrePubResult rpc_laddr Error: %v"
,
err
)
...
@@ -277,7 +301,7 @@ func abortPrePubResult(cmd *cobra.Command, args []string) {
...
@@ -277,7 +301,7 @@ func abortPrePubResult(cmd *cobra.Command, args []string) {
}
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateAbortResultPrePublishTx
,
ActionName
:
oraclety
.
CreateAbortResultPrePublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
}"
,
eventID
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
}"
,
eventID
)),
}
}
...
@@ -321,6 +345,12 @@ func addPublishResultFlags(cmd *cobra.Command) {
...
@@ -321,6 +345,12 @@ func addPublishResultFlags(cmd *cobra.Command) {
}
}
func
publishResult
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
publishResult
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
err
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"publishResult rpc_laddr Error: %v"
,
err
)
fmt
.
Printf
(
"publishResult rpc_laddr Error: %v"
,
err
)
...
@@ -343,7 +373,7 @@ func publishResult(cmd *cobra.Command, args []string) {
...
@@ -343,7 +373,7 @@ func publishResult(cmd *cobra.Command, args []string) {
}
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateResultPublishTx
,
ActionName
:
oraclety
.
CreateResultPublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
,
\"
source
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
eventID
,
source
,
result
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
,
\"
source
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
eventID
,
source
,
result
)),
}
}
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
02830e68
...
@@ -64,8 +64,8 @@ func addCreateAssetTransferFlags(cmd *cobra.Command) {
...
@@ -64,8 +64,8 @@ func addCreateAssetTransferFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transaction note info"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transaction note info"
)
cmd
.
Flags
()
.
StringP
(
"title"
,
""
,
""
,
"the title of para chain, like `user.p.guodun.`"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
""
,
""
,
"the title of para chain, like `user.p.guodun.`"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
""
,
"default for bty, symbol for token"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
""
,
"default for bty, symbol for token"
)
}
}
...
@@ -96,8 +96,8 @@ func addCreateAssetWithdrawFlags(cmd *cobra.Command) {
...
@@ -96,8 +96,8 @@ func addCreateAssetWithdrawFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transaction note info"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transaction note info"
)
cmd
.
Flags
()
.
StringP
(
"title"
,
""
,
""
,
"the title of para chain, like `user.p.guodun.`"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
""
,
""
,
"the title of para chain, like `user.p.guodun.`"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"receiver account address"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"receiver account address"
)
cmd
.
MarkFlagRequired
(
"to"
)
cmd
.
MarkFlagRequired
(
"to"
)
...
@@ -115,6 +115,12 @@ func createAssetWithdraw(cmd *cobra.Command, args []string) {
...
@@ -115,6 +115,12 @@ func createAssetWithdraw(cmd *cobra.Command, args []string) {
}
}
func
createAssetTx
(
cmd
*
cobra
.
Command
,
isWithdraw
bool
)
(
string
,
error
)
{
func
createAssetTx
(
cmd
*
cobra
.
Command
,
isWithdraw
bool
)
(
string
,
error
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
if
amount
<
0
{
if
amount
<
0
{
return
""
,
types
.
ErrAmount
return
""
,
types
.
ErrAmount
...
@@ -125,12 +131,12 @@ func createAssetTx(cmd *cobra.Command, isWithdraw bool) (string, error) {
...
@@ -125,12 +131,12 @@ func createAssetTx(cmd *cobra.Command, isWithdraw bool) (string, error) {
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
if
!
strings
.
HasPrefix
(
title
,
"user.p"
)
{
if
!
strings
.
HasPrefix
(
p
title
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"title is not right, title format like `user.p.guodun.`"
)
fmt
.
Fprintln
(
os
.
Stderr
,
"
p
title is not right, title format like `user.p.guodun.`"
)
return
""
,
types
.
ErrInvalidParam
return
""
,
types
.
ErrInvalidParam
}
}
execName
:=
title
+
pt
.
ParaX
execName
:=
p
title
+
pt
.
ParaX
param
:=
types
.
CreateTx
{
param
:=
types
.
CreateTx
{
To
:
toAddr
,
To
:
toAddr
,
...
@@ -142,7 +148,7 @@ func createAssetTx(cmd *cobra.Command, isWithdraw bool) (string, error) {
...
@@ -142,7 +148,7 @@ func createAssetTx(cmd *cobra.Command, isWithdraw bool) (string, error) {
TokenSymbol
:
symbol
,
TokenSymbol
:
symbol
,
ExecName
:
execName
,
ExecName
:
execName
,
}
}
tx
,
err
:=
pt
.
CreateRawAssetTransferTx
(
&
param
)
tx
,
err
:=
pt
.
CreateRawAssetTransferTx
(
cfg
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -260,12 +266,18 @@ func addNodeJoinFlags(cmd *cobra.Command) {
...
@@ -260,12 +266,18 @@ func addNodeJoinFlags(cmd *cobra.Command) {
}
}
func
createNodeJoinTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createNodeJoinTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
1
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
1
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
ActionName
:
"NodeConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -294,12 +306,18 @@ func addNodeVoteFlags(cmd *cobra.Command) {
...
@@ -294,12 +306,18 @@ func addNodeVoteFlags(cmd *cobra.Command) {
}
}
func
createNodeVoteTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createNodeVoteTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
val
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"value"
)
val
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"value"
)
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
2
,
Id
:
id
,
Value
:
val
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
2
,
Id
:
id
,
Value
:
val
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
ActionName
:
"NodeConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -326,11 +344,17 @@ func addNodeQuitFlags(cmd *cobra.Command) {
...
@@ -326,11 +344,17 @@ func addNodeQuitFlags(cmd *cobra.Command) {
}
}
func
createNodeQuitTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createNodeQuitTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
3
,
Addr
:
opAddr
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
3
,
Addr
:
opAddr
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
ActionName
:
"NodeConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -357,11 +381,17 @@ func addNodeCancelFlags(cmd *cobra.Command) {
...
@@ -357,11 +381,17 @@ func addNodeCancelFlags(cmd *cobra.Command) {
}
}
func
createNodeCancelTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createNodeCancelTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
4
,
Id
:
id
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
4
,
Id
:
id
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
ActionName
:
"NodeConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -394,8 +424,8 @@ func getNodeInfoCmd() *cobra.Command {
...
@@ -394,8 +424,8 @@ func getNodeInfoCmd() *cobra.Command {
}
}
func
addNodeBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"addr apply for super user"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"addr apply for super user"
)
cmd
.
MarkFlagRequired
(
"addr"
)
cmd
.
MarkFlagRequired
(
"addr"
)
...
@@ -404,11 +434,11 @@ func addNodeBodyCmdFlags(cmd *cobra.Command) {
...
@@ -404,11 +434,11 @@ func addNodeBodyCmdFlags(cmd *cobra.Command) {
func
nodeInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
params
:=
pt
.
ReqParacrossNodeInfo
{
params
:=
pt
.
ReqParacrossNodeInfo
{
Title
:
title
,
Title
:
p
title
,
Addr
:
addr
,
Addr
:
addr
,
}
}
var
res
pt
.
ParaNodeAddrIdStatus
var
res
pt
.
ParaNodeAddrIdStatus
...
@@ -428,8 +458,8 @@ func getNodeIDInfoCmd() *cobra.Command {
...
@@ -428,8 +458,8 @@ func getNodeIDInfoCmd() *cobra.Command {
}
}
func
addNodeIDBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeIDBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"id apply for super user"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"id apply for super user"
)
cmd
.
MarkFlagRequired
(
"id"
)
cmd
.
MarkFlagRequired
(
"id"
)
...
@@ -438,11 +468,11 @@ func addNodeIDBodyCmdFlags(cmd *cobra.Command) {
...
@@ -438,11 +468,11 @@ func addNodeIDBodyCmdFlags(cmd *cobra.Command) {
func
nodeIDInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeIDInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
params
:=
pt
.
ReqParacrossNodeInfo
{
params
:=
pt
.
ReqParacrossNodeInfo
{
Title
:
title
,
Title
:
p
title
,
Id
:
id
,
Id
:
id
,
}
}
var
res
pt
.
ParaNodeIdStatus
var
res
pt
.
ParaNodeIdStatus
...
@@ -462,8 +492,8 @@ func getNodeListCmd() *cobra.Command {
...
@@ -462,8 +492,8 @@ func getNodeListCmd() *cobra.Command {
}
}
func
addNodeListCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeListCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status:0:all,1:joining,2:quiting,3:closed,4:canceled"
)
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status:0:all,1:joining,2:quiting,3:closed,4:canceled"
)
cmd
.
MarkFlagRequired
(
"status"
)
cmd
.
MarkFlagRequired
(
"status"
)
...
@@ -472,11 +502,11 @@ func addNodeListCmdFlags(cmd *cobra.Command) {
...
@@ -472,11 +502,11 @@ func addNodeListCmdFlags(cmd *cobra.Command) {
func
nodeList
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeList
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
status
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"status"
)
status
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"status"
)
params
:=
pt
.
ReqParacrossNodeInfo
{
params
:=
pt
.
ReqParacrossNodeInfo
{
Title
:
title
,
Title
:
p
title
,
Status
:
status
,
Status
:
status
,
}
}
var
res
pt
.
RespParacrossNodeAddrs
var
res
pt
.
RespParacrossNodeAddrs
...
@@ -511,12 +541,18 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
...
@@ -511,12 +541,18 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
}
}
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
1
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
1
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
ActionName
:
"NodeGroupConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -546,12 +582,18 @@ func addNodeGroupApproveCmdFlags(cmd *cobra.Command) {
...
@@ -546,12 +582,18 @@ func addNodeGroupApproveCmdFlags(cmd *cobra.Command) {
}
}
func
nodeGroupApprove
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupApprove
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
2
,
Id
:
id
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
2
,
Id
:
id
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
ActionName
:
"NodeGroupConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -578,11 +620,17 @@ func addNodeGroupQuitCmdFlags(cmd *cobra.Command) {
...
@@ -578,11 +620,17 @@ func addNodeGroupQuitCmdFlags(cmd *cobra.Command) {
}
}
func
nodeGroupQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
3
,
Id
:
id
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
3
,
Id
:
id
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
ActionName
:
"NodeGroupConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -608,11 +656,17 @@ func addNodeGroupModifyCmdFlags(cmd *cobra.Command) {
...
@@ -608,11 +656,17 @@ func addNodeGroupModifyCmdFlags(cmd *cobra.Command) {
}
}
func
nodeGroupModify
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupModify
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
4
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
4
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
cfg
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
ActionName
:
"NodeGroupConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
@@ -650,16 +704,16 @@ func isSync(cmd *cobra.Command, args []string) {
...
@@ -650,16 +704,16 @@ func isSync(cmd *cobra.Command, args []string) {
}
}
func
addTitleFlags
(
cmd
*
cobra
.
Command
)
{
func
addTitleFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title, default null in para chain"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title, default null in para chain"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
}
}
func
consusHeight
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
consusHeight
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
var
res
pt
.
ParacrossConsensusStatus
var
res
pt
.
ParacrossConsensusStatus
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetHeight"
,
&
types
.
ReqString
{
Data
:
title
},
&
res
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetHeight"
,
&
types
.
ReqString
{
Data
:
p
title
},
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -739,8 +793,8 @@ func GetLocalBlockInfoCmd() *cobra.Command {
...
@@ -739,8 +793,8 @@ func GetLocalBlockInfoCmd() *cobra.Command {
}
}
func
addParaBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addParaBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
cmd
.
Flags
()
.
Int64P
(
"height"
,
"g"
,
0
,
"height to para chain"
)
cmd
.
Flags
()
.
Int64P
(
"height"
,
"g"
,
0
,
"height to para chain"
)
cmd
.
MarkFlagRequired
(
"height"
)
cmd
.
MarkFlagRequired
(
"height"
)
...
@@ -749,11 +803,11 @@ func addParaBodyCmdFlags(cmd *cobra.Command) {
...
@@ -749,11 +803,11 @@ func addParaBodyCmdFlags(cmd *cobra.Command) {
func
paraInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
paraInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
params
:=
pt
.
ReqParacrossTitleHeight
{
params
:=
pt
.
ReqParacrossTitleHeight
{
Title
:
title
,
Title
:
p
title
,
Height
:
height
,
Height
:
height
,
}
}
var
res
pt
.
ParacrossHeightStatusRsp
var
res
pt
.
ParacrossHeightStatusRsp
...
@@ -803,16 +857,16 @@ func getNodeGroupAddrsCmd() *cobra.Command {
...
@@ -803,16 +857,16 @@ func getNodeGroupAddrsCmd() *cobra.Command {
}
}
func
addNodeGroupCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeGroupCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
}
}
func
nodeGroup
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroup
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
var
res
types
.
ReplyConfig
var
res
types
.
ReplyConfig
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeGroupAddrs"
,
pt
.
ReqParacrossNodeInfo
{
Title
:
title
},
&
res
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeGroupAddrs"
,
pt
.
ReqParacrossNodeInfo
{
Title
:
p
title
},
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -828,17 +882,17 @@ func nodeGroupStatusCmd() *cobra.Command {
...
@@ -828,17 +882,17 @@ func nodeGroupStatusCmd() *cobra.Command {
}
}
func
getNodeGroupStatusCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
getNodeGroupStatusCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
Flags
()
.
StringP
(
"
p
title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"
p
title"
)
}
}
func
nodeGroupStatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupStatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
title"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"p
title"
)
params
:=
pt
.
ReqParacrossNodeInfo
{
params
:=
pt
.
ReqParacrossNodeInfo
{
Title
:
title
,
Title
:
p
title
,
}
}
var
res
pt
.
ParaNodeGroupStatus
var
res
pt
.
ParaNodeGroupStatus
...
...
plugin/dapp/pokerbull/cmd/game.go
View file @
02830e68
...
@@ -54,12 +54,18 @@ func addPokerbullStartFlags(cmd *cobra.Command) {
...
@@ -54,12 +54,18 @@ func addPokerbullStartFlags(cmd *cobra.Command) {
}
}
func
pokerbullStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
pokerbullStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
playerCount
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"playerCount"
)
playerCount
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"playerCount"
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreateStartTx
,
ActionName
:
pkt
.
CreateStartTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
value
\"
:%d,
\"
playerNum
\"
:%d}"
,
int64
(
value
)
*
types
.
Coin
,
int32
(
playerCount
))),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
value
\"
:%d,
\"
playerNum
\"
:%d}"
,
int64
(
value
)
*
types
.
Coin
,
int32
(
playerCount
))),
}
}
...
@@ -86,11 +92,17 @@ func addPokerbullContinueFlags(cmd *cobra.Command) {
...
@@ -86,11 +92,17 @@ func addPokerbullContinueFlags(cmd *cobra.Command) {
}
}
func
pokerbullContinue
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
pokerbullContinue
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreateContinueTx
,
ActionName
:
pkt
.
CreateContinueTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
}
}
...
@@ -117,11 +129,17 @@ func addPokerbullQuitFlags(cmd *cobra.Command) {
...
@@ -117,11 +129,17 @@ func addPokerbullQuitFlags(cmd *cobra.Command) {
}
}
func
pokerbullQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
pokerbullQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreateQuitTx
,
ActionName
:
pkt
.
CreateQuitTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
}
}
...
@@ -154,6 +172,12 @@ func addPokerbullPlayFlags(cmd *cobra.Command) {
...
@@ -154,6 +172,12 @@ func addPokerbullPlayFlags(cmd *cobra.Command) {
}
}
func
pokerbullPlay
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
pokerbullPlay
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
round
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"round"
)
round
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"round"
)
...
@@ -169,7 +193,7 @@ func pokerbullPlay(cmd *cobra.Command, args []string) {
...
@@ -169,7 +193,7 @@ func pokerbullPlay(cmd *cobra.Command, args []string) {
copy
(
payload
.
Address
,
address
)
copy
(
payload
.
Address
,
address
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreatePlayTx
,
ActionName
:
pkt
.
CreatePlayTx
,
Payload
:
types
.
MustPBToJSON
(
payload
),
Payload
:
types
.
MustPBToJSON
(
payload
),
}
}
...
...
plugin/dapp/retrieve/cmd/retrieve.go
View file @
02830e68
...
@@ -53,6 +53,12 @@ func BackupCmd() *cobra.Command {
...
@@ -53,6 +53,12 @@ func BackupCmd() *cobra.Command {
}
}
func
addBakupCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addBakupCmdFlags
(
cmd
*
cobra
.
Command
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
cmd
.
Flags
()
.
StringP
(
"backup"
,
"b"
,
""
,
"backup address"
)
cmd
.
Flags
()
.
StringP
(
"backup"
,
"b"
,
""
,
"backup address"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
...
@@ -60,7 +66,7 @@ func addBakupCmdFlags(cmd *cobra.Command) {
...
@@ -60,7 +66,7 @@ func addBakupCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
Int64P
(
"delay"
,
"d"
,
60
,
"delay period (minimum 60 seconds)"
)
cmd
.
Flags
()
.
Int64P
(
"delay"
,
"d"
,
60
,
"delay period (minimum 60 seconds)"
)
cmd
.
MarkFlagRequired
(
"delay"
)
cmd
.
MarkFlagRequired
(
"delay"
)
defaultFee
:=
float64
(
types
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
defaultFee
:=
float64
(
cfg
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"transaction fee"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"transaction fee"
)
}
}
...
@@ -98,16 +104,28 @@ func PrepareCmd() *cobra.Command {
...
@@ -98,16 +104,28 @@ func PrepareCmd() *cobra.Command {
}
}
func
addRetrieveCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addRetrieveCmdFlags
(
cmd
*
cobra
.
Command
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
cmd
.
Flags
()
.
StringP
(
"backup"
,
"b"
,
""
,
"backup address"
)
cmd
.
Flags
()
.
StringP
(
"backup"
,
"b"
,
""
,
"backup address"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
cmd
.
MarkFlagRequired
(
"default"
)
cmd
.
MarkFlagRequired
(
"default"
)
defaultFee
:=
float64
(
types
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
defaultFee
:=
float64
(
cfg
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"sign address"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"sign address"
)
}
}
func
addPerformCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addPerformCmdFlags
(
cmd
*
cobra
.
Command
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
cmd
.
Flags
()
.
StringP
(
"backup"
,
"b"
,
""
,
"backup address"
)
cmd
.
Flags
()
.
StringP
(
"backup"
,
"b"
,
""
,
"backup address"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
...
@@ -116,7 +134,7 @@ func addPerformCmdFlags(cmd *cobra.Command) {
...
@@ -116,7 +134,7 @@ func addPerformCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringArrayP
(
"exec"
,
"e"
,
[]
string
{},
"asset exec"
)
cmd
.
Flags
()
.
StringArrayP
(
"exec"
,
"e"
,
[]
string
{},
"asset exec"
)
cmd
.
Flags
()
.
StringArrayP
(
"symbol"
,
"s"
,
[]
string
{},
"asset symbol"
)
cmd
.
Flags
()
.
StringArrayP
(
"symbol"
,
"s"
,
[]
string
{},
"asset symbol"
)
defaultFee
:=
float64
(
types
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
defaultFee
:=
float64
(
cfg
.
GInt
(
"MinFee"
))
/
float64
(
types
.
Coin
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"sign address"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
defaultFee
,
"sign address"
)
}
}
...
...
plugin/dapp/ticket/commands/ticket.go
View file @
02830e68
...
@@ -54,6 +54,12 @@ func addBindMinerFlags(cmd *cobra.Command) {
...
@@ -54,6 +54,12 @@ func addBindMinerFlags(cmd *cobra.Command) {
}
}
func
bindMiner
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
bindMiner
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
bindAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"bind_addr"
)
bindAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"bind_addr"
)
originAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"origin_addr"
)
originAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"origin_addr"
)
//c, _ := crypto.New(types.GetSignName(wallet.SignType))
//c, _ := crypto.New(types.GetSignName(wallet.SignType))
...
@@ -68,7 +74,7 @@ func bindMiner(cmd *cobra.Command, args []string) {
...
@@ -68,7 +74,7 @@ func bindMiner(cmd *cobra.Command, args []string) {
ta
.
Value
=
&
ty
.
TicketAction_Tbind
{
Tbind
:
tBind
}
ta
.
Value
=
&
ty
.
TicketAction_Tbind
{
Tbind
:
tBind
}
ta
.
Ty
=
ty
.
TicketActionBind
ta
.
Ty
=
ty
.
TicketActionBind
tx
,
err
:=
types
.
CreateFormatTx
(
"ticket"
,
types
.
Encode
(
ta
))
tx
,
err
:=
types
.
CreateFormatTx
(
cfg
,
"ticket"
,
types
.
Encode
(
ta
))
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
...
...
plugin/dapp/unfreeze/commands/unfreeze.go
View file @
02830e68
...
@@ -112,6 +112,12 @@ func fixAmountCmd() *cobra.Command {
...
@@ -112,6 +112,12 @@ func fixAmountCmd() *cobra.Command {
}
}
func
fixAmount
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
fixAmount
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
create
,
err
:=
getCreateFlags
(
cmd
)
create
,
err
:=
getCreateFlags
(
cmd
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
@@ -140,7 +146,7 @@ func fixAmount(cmd *cobra.Command, args []string) {
...
@@ -140,7 +146,7 @@ func fixAmount(cmd *cobra.Command, args []string) {
create
.
MeansOpt
=
&
pty
.
UnfreezeCreate_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
period
,
Amount
:
amountInt64
}}
create
.
MeansOpt
=
&
pty
.
UnfreezeCreate_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
period
,
Amount
:
amountInt64
}}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
"createUnfreeze"
,
ActionName
:
"createUnfreeze"
,
Payload
:
types
.
MustPBToJSON
(
create
),
Payload
:
types
.
MustPBToJSON
(
create
),
}
}
...
@@ -166,6 +172,12 @@ func leftCmd() *cobra.Command {
...
@@ -166,6 +172,12 @@ func leftCmd() *cobra.Command {
}
}
func
left
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
left
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
create
,
err
:=
getCreateFlags
(
cmd
)
create
,
err
:=
getCreateFlags
(
cmd
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
@@ -189,7 +201,7 @@ func left(cmd *cobra.Command, args []string) {
...
@@ -189,7 +201,7 @@ func left(cmd *cobra.Command, args []string) {
}
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
pty
.
Action_CreateUnfreeze
,
ActionName
:
pty
.
Action_CreateUnfreeze
,
Payload
:
types
.
MustPBToJSON
(
create
),
Payload
:
types
.
MustPBToJSON
(
create
),
}
}
...
@@ -248,10 +260,16 @@ func queryWithdrawCmd() *cobra.Command {
...
@@ -248,10 +260,16 @@ func queryWithdrawCmd() *cobra.Command {
}
}
func
withdraw
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
withdraw
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
pty
.
Action_WithdrawUnfreeze
,
ActionName
:
pty
.
Action_WithdrawUnfreeze
,
Payload
:
types
.
MustPBToJSON
(
&
pty
.
UnfreezeWithdraw
{
UnfreezeID
:
id
}),
Payload
:
types
.
MustPBToJSON
(
&
pty
.
UnfreezeWithdraw
{
UnfreezeID
:
id
}),
}
}
...
@@ -262,10 +280,16 @@ func withdraw(cmd *cobra.Command, args []string) {
...
@@ -262,10 +280,16 @@ func withdraw(cmd *cobra.Command, args []string) {
}
}
func
terminate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
terminate
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
pty
.
Action_TerminateUnfreeze
,
ActionName
:
pty
.
Action_TerminateUnfreeze
,
Payload
:
types
.
MustPBToJSON
(
&
pty
.
UnfreezeTerminate
{
UnfreezeID
:
id
}),
Payload
:
types
.
MustPBToJSON
(
&
pty
.
UnfreezeTerminate
{
UnfreezeID
:
id
}),
}
}
...
...
plugin/dapp/valnode/commands/valnode.go
View file @
02830e68
...
@@ -147,6 +147,12 @@ func addNodeFlags(cmd *cobra.Command) {
...
@@ -147,6 +147,12 @@ func addNodeFlags(cmd *cobra.Command) {
}
}
func
addNode
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
addNode
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
if
cfg
==
nil
{
panic
(
fmt
.
Sprintln
(
"can not find CliSysParam title"
,
title
))
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
power
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"power"
)
power
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"power"
)
...
@@ -164,7 +170,7 @@ func addNode(cmd *cobra.Command, args []string) {
...
@@ -164,7 +170,7 @@ func addNode(cmd *cobra.Command, args []string) {
value
:=
&
vt
.
ValNodeAction_Node
{
Node
:
&
vt
.
ValNode
{
PubKey
:
pubkeybyte
,
Power
:
power
}}
value
:=
&
vt
.
ValNodeAction_Node
{
Node
:
&
vt
.
ValNode
{
PubKey
:
pubkeybyte
,
Power
:
power
}}
action
:=
&
vt
.
ValNodeAction
{
Value
:
value
,
Ty
:
vt
.
ValNodeActionUpdate
}
action
:=
&
vt
.
ValNodeAction
{
Value
:
value
,
Ty
:
vt
.
ValNodeActionUpdate
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
vt
.
ValNodeX
),
Payload
:
types
.
Encode
(
action
),
Fee
:
0
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
vt
.
ValNodeX
),
Payload
:
types
.
Encode
(
action
),
Fee
:
0
}
err
=
tx
.
SetRealFee
(
types
.
GInt
(
"MinFee"
))
err
=
tx
.
SetRealFee
(
cfg
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
...
...
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