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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
510 additions
and
130 deletions
+510
-130
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
+0
-0
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 {
panic
(
err
)
}
grpcCli
,
err
:=
grpcclient
.
NewMainChainClient
(
""
)
if
err
!=
nil
{
panic
(
err
)
}
para
:=
&
client
{
BaseClient
:
c
,
grpcClient
:
grpcCli
,
authAccount
:
subcfg
.
AuthAccount
,
privateKey
:
priKey
,
subCfg
:
&
subcfg
,
...
...
@@ -286,6 +280,12 @@ func (client *client) InitBlock() {
var
err
error
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
()
if
err
!=
nil
{
...
...
@@ -364,7 +364,8 @@ func (client *client) GetStartMainHash(height int64) []byte {
func
(
client
*
client
)
CreateGenesisTx
()
(
ret
[]
*
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
//gen payload
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
tx
.
Sign
(
types
.
SECP256K1
,
client
.
privateKey
)
return
tx
,
nil
}
group
,
err
:=
types
.
CreateTxGroup
(
txsArr
.
Txs
,
types
.
GInt
(
"MinFee"
))
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
group
,
err
:=
types
.
CreateTxGroup
(
txsArr
.
Txs
,
cfg
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
plog
.
Error
(
"para CreateTxGroup"
,
"err"
,
err
.
Error
())
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
{
plog
.
Error
(
"para CheckTxGroup"
,
"err"
,
err
.
Error
())
return
nil
,
err
...
...
@@ -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
)
{
var
rawTxs
types
.
Transactions
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
for
_
,
status
:=
range
notifications
{
execName
:=
pt
.
ParaX
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
{
plog
.
Error
(
"para get commit tx"
,
"block height"
,
status
.
Height
)
return
nil
,
0
,
err
...
...
@@ -416,10 +417,11 @@ func (client *commitMsgClient) batchCalcTxGroup(notifications []*pt.ParacrossNod
func
(
client
*
commitMsgClient
)
singleCalcTx
(
status
*
pt
.
ParacrossNodeStatus
,
feeRate
int64
)
(
*
types
.
Transaction
,
error
)
{
execName
:=
pt
.
ParaX
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
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
{
plog
.
Error
(
"para get commit tx"
,
"block height"
,
status
.
Height
)
return
nil
,
err
...
...
@@ -521,8 +523,9 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
count
:=
req
.
End
-
req
.
Start
+
1
nodeList
:=
make
(
map
[
int64
]
*
pt
.
ParacrossNodeStatus
,
count
+
1
)
keys
:=
&
types
.
LocalDBGet
{}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
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
)
}
...
...
@@ -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
)
return
nil
,
errors
.
New
(
"paracommitmsg wrong block result"
)
}
nodeList
[
block
.
Block
.
Height
]
.
BlockHash
=
block
.
Block
.
Hash
()
if
!
paracross
.
IsParaForkHeight
(
nodeList
[
block
.
Block
.
Height
]
.
MainBlockHeight
,
paracross
.
ForkLoopCheckCommitTxDone
)
{
nodeList
[
block
.
Block
.
Height
]
.
BlockHash
=
block
.
Block
.
Hash
(
cfg
)
if
!
paracross
.
IsParaForkHeight
(
cfg
,
nodeList
[
block
.
Block
.
Height
]
.
MainBlockHeight
,
paracross
.
ForkLoopCheckCommitTxDone
)
{
nodeList
[
block
.
Block
.
Height
]
.
StateHash
=
block
.
Block
.
StateHash
}
}
...
...
@@ -608,9 +611,10 @@ func (client *commitMsgClient) getGenesisNodeStatus() (*pt.ParacrossNodeStatus,
if
block
.
Height
!=
0
{
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
.
BlockHash
=
block
.
Hash
()
status
.
BlockHash
=
block
.
Hash
(
cfg
)
return
&
status
,
nil
}
...
...
@@ -703,13 +707,13 @@ func (client *commitMsgClient) getSelfConsensusStatus() (*pt.ParacrossStatus, er
if
err
!=
nil
{
return
nil
,
err
}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
if
client
.
paraClient
.
isParaSelfConsensusForked
(
block
.
MainHeight
)
{
//从本地查询共识高度
ret
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
FuncName
:
"GetTitle"
,
Param
:
types
.
Encode
(
&
types
.
ReqString
{
Data
:
types
.
GetTitle
()}),
Param
:
types
.
Encode
(
&
types
.
ReqString
{
Data
:
cfg
.
GetTitle
()}),
})
if
err
!=
nil
{
plog
.
Error
(
"getSelfConsensusStatus "
,
"err"
,
err
.
Error
())
...
...
@@ -723,7 +727,7 @@ func (client *commitMsgClient) getSelfConsensusStatus() (*pt.ParacrossStatus, er
//开启自共识后也要等到自共识真正切换之后再使用,如果本地区块已经过了自共识高度,但自共识的高度还没达成,就会导致共识机制出错
if
resp
.
Height
>
-
1
{
var
statusMainHeight
int64
if
pt
.
IsParaForkHeight
(
resp
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
IsParaForkHeight
(
cfg
,
resp
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
statusMainHeight
=
resp
.
MainHeight
}
else
{
block
,
err
:=
client
.
paraClient
.
GetBlockByHeight
(
resp
.
Height
)
...
...
@@ -749,12 +753,12 @@ func (client *commitMsgClient) getMainConsensusStatus() (*pt.ParacrossStatus, er
if
err
!=
nil
{
return
nil
,
err
}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
//去主链获取共识高度
reply
,
err
:=
client
.
paraClient
.
grpcClient
.
QueryChain
(
context
.
Background
(),
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
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
{
plog
.
Error
(
"getMainConsensusStatus"
,
"err"
,
err
.
Error
())
...
...
@@ -776,10 +780,11 @@ func (client *commitMsgClient) getMainConsensusStatus() (*pt.ParacrossStatus, er
//node group会在主链和平行链都同时配置,只本地查询就可以
func
(
client
*
commitMsgClient
)
getNodeGroupAddrs
()
(
string
,
error
)
{
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
ret
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
FuncName
:
"GetNodeGroupAddrs"
,
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
types
.
GetTitle
()}),
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
cfg
.
GetTitle
()}),
})
if
err
!=
nil
{
plog
.
Error
(
"commitmsg.getNodeGroupAddrs "
,
"err"
,
err
.
Error
())
...
...
plugin/consensus/para/paracreate.go
View file @
02830e68
...
...
@@ -22,14 +22,15 @@ import (
)
func
(
client
*
client
)
addLocalBlock
(
height
int64
,
block
*
pt
.
ParaLocalDbBlock
)
error
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
set
.
KV
=
append
(
set
.
KV
,
kv
)
//两个key原子操作
key
=
calcTitleLastHeightKey
(
types
.
GetTitle
())
key
=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
kv
=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
height
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
...
@@ -59,13 +60,14 @@ func (client *client) createLocalGenesisBlock(genesis *types.Block) error {
}
func
(
client
*
client
)
delLocalBlock
(
height
int64
)
error
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
set
.
KV
=
append
(
set
.
KV
,
kv
)
//两个key原子操作
key
=
calcTitleLastHeightKey
(
types
.
GetTitle
())
key
=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
kv
=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
height
-
1
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
...
@@ -74,9 +76,10 @@ func (client *client) delLocalBlock(height int64) error {
// localblock 设置到当前高度,当前高度后面block会被新的区块覆盖
func
(
client
*
client
)
removeLocalBlocks
(
curHeight
int64
)
error
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleLastHeightKey
(
types
.
GetTitle
())
key
:=
calcTitleLastHeightKey
(
cfg
.
GetTitle
())
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
curHeight
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
...
@@ -84,7 +87,8 @@ func (client *client) removeLocalBlocks(curHeight 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
}}
value
,
err
:=
client
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
if
err
!=
nil
{
...
...
@@ -104,7 +108,8 @@ func (client *client) getLastLocalHeight() (int64, 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
}}
value
,
err
:=
client
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
...
...
@@ -395,12 +400,13 @@ func validMainBlocks(txs *types.ParaTxDetails) *types.ParaTxDetails {
}
func
(
client
*
client
)
requestTxsFromBlock
(
currSeq
int64
,
preMainBlockHash
[]
byte
)
(
*
types
.
ParaTxDetails
,
error
)
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
blockSeq
,
err
:=
client
.
GetBlockOnMainBySeq
(
currSeq
)
if
err
!=
nil
{
return
nil
,
err
}
txDetail
:=
blockSeq
.
Detail
.
FilterParaTxsByTitle
(
types
.
GetTitle
())
txDetail
:=
blockSeq
.
Detail
.
FilterParaTxsByTitle
(
cfg
,
cfg
.
GetTitle
())
txDetail
.
Type
=
blockSeq
.
Seq
.
Type
if
!
isValidSeqType
(
txDetail
.
Type
)
{
...
...
@@ -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
)
{
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
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -459,6 +466,7 @@ func (client *client) getEmptyInterval(lastBlock *pt.ParaLocalDbBlock) int64 {
}
func
(
client
*
client
)
procLocalBlock
(
mainBlock
*
types
.
ParaTxDetail
)
(
bool
,
error
)
{
cfg
:=
client
.
GetAPI
()
.
GetConfig
()
lastSeqMainHeight
:=
mainBlock
.
Header
.
Height
lastBlock
,
err
:=
client
.
getLastLocalBlock
()
...
...
@@ -468,7 +476,7 @@ func (client *client) procLocalBlock(mainBlock *types.ParaTxDetail) (bool, error
}
emptyInterval
:=
client
.
getEmptyInterval
(
lastBlock
)
txs
:=
paraexec
.
FilterTxsForPara
(
mainBlock
)
txs
:=
paraexec
.
FilterTxsForPara
(
cfg
,
mainBlock
)
plog
.
Info
(
"Parachain process block"
,
"lastBlockHeight"
,
lastBlock
.
Height
,
"lastBlockMainHeight"
,
lastBlock
.
MainHeight
,
"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) {
recv
:=
make
(
chan
bool
,
1
)
testInv
:=
&
inventory
{
start
:
inv
.
start
,
end
:
inv
.
end
,
curHeight
:
inv
.
start
,
connCli
:
conn
}
cfg
:=
m
.
paraClient
.
GetAPI
()
.
GetConfig
()
go
func
()
{
_
,
err
:=
requestMainBlocks
(
testInv
)
_
,
err
:=
requestMainBlocks
(
cfg
,
testInv
)
if
err
!=
nil
{
plog
.
Info
(
"multiServerDownload.testconn ip error"
,
"ip"
,
conn
.
ip
,
"err"
,
err
.
Error
())
recv
<-
false
...
...
@@ -120,11 +121,12 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
}
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
,
","
)
var
conns
[]
*
connectCli
for
_
,
ip
:=
range
ips
{
conn
,
err
:=
grpcclient
.
NewMainChainClient
(
ip
)
conn
,
err
:=
grpcclient
.
NewMainChainClient
(
cfg
,
ip
)
if
err
==
nil
{
conns
=
append
(
conns
,
&
connectCli
{
conn
:
conn
,
ip
:
ip
,
timeout
:
m
.
serverTimeout
})
}
...
...
@@ -326,9 +328,10 @@ func (d *downloadJob) verifyDownloadBlock(inv *inventory, blocks *types.ParaTxDe
}
func
(
d
*
downloadJob
)
saveMainBlock
(
height
int64
,
block
*
types
.
ParaTxDetail
)
error
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleMainHeightKey
(
types
.
GetTitle
(),
height
)
key
:=
calcTitleMainHeightKey
(
cfg
.
GetTitle
(),
height
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
block
)}
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
...
@@ -336,10 +339,11 @@ func (d *downloadJob) saveMainBlock(height int64, block *types.ParaTxDetail) err
}
func
(
d
*
downloadJob
)
saveBatchMainBlocks
(
txs
*
types
.
ParaTxDetails
)
error
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
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
)}
set
.
KV
=
append
(
set
.
KV
,
kv
)
}
...
...
@@ -348,10 +352,11 @@ func (d *downloadJob) saveBatchMainBlocks(txs *types.ParaTxDetails) error {
}
func
(
d
*
downloadJob
)
rmvBatchMainBlocks
(
inv
*
inventory
)
error
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
set
:=
&
types
.
LocalDBSet
{}
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
}
set
.
KV
=
append
(
set
.
KV
,
kv
)
}
...
...
@@ -360,7 +365,8 @@ func (d *downloadJob) rmvBatchMainBlocks(inv *inventory) 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
}}
value
,
err
:=
d
.
mDldCli
.
paraClient
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
...
...
@@ -438,8 +444,8 @@ func (d *downloadJob) checkDownLoadRate() {
}
func
requestMainBlocks
(
inv
*
inventory
)
(
*
types
.
ParaTxDetails
,
error
)
{
req
:=
&
types
.
ReqParaTxByTitle
{
IsSeq
:
false
,
Start
:
inv
.
curHeight
,
End
:
inv
.
end
,
Title
:
types
.
GetTitle
()}
func
requestMainBlocks
(
cfg
*
types
.
Chain33Config
,
inv
*
inventory
)
(
*
types
.
ParaTxDetails
,
error
)
{
req
:=
&
types
.
ReqParaTxByTitle
{
IsSeq
:
false
,
Start
:
inv
.
curHeight
,
End
:
inv
.
end
,
Title
:
cfg
.
GetTitle
()}
txs
,
err
:=
inv
.
connCli
.
conn
.
GetParaTxByTitle
(
context
.
Background
(),
req
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -456,10 +462,10 @@ func requestMainBlocks(inv *inventory) (*types.ParaTxDetails, error) {
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
)
go
func
()
{
tx
,
err
:=
requestMainBlocks
(
inv
)
tx
,
err
:=
requestMainBlocks
(
cfg
,
inv
)
if
err
!=
nil
{
plog
.
Error
(
"requestMainBlockWithTime err"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
,
"err"
,
err
.
Error
())
close
(
retCh
)
...
...
@@ -483,6 +489,7 @@ func requestMainBlockWithTime(inv *inventory) *types.ParaTxDetails {
}
func
(
d
*
downloadJob
)
getInvBlocks
(
inv
*
inventory
,
connPool
chan
*
connectCli
)
{
cfg
:=
d
.
mDldCli
.
paraClient
.
GetAPI
()
.
GetConfig
()
start
:=
time
.
Now
()
defer
func
()
{
connPool
<-
inv
.
connCli
...
...
@@ -492,7 +499,7 @@ func (d *downloadJob) getInvBlocks(inv *inventory, connPool chan *connectCli) {
inv
.
curHeight
=
inv
.
start
plog
.
Debug
(
"getInvBlocks begin"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
)
for
{
txs
:=
requestMainBlockWithTime
(
inv
)
txs
:=
requestMainBlockWithTime
(
cfg
,
inv
)
if
txs
==
nil
||
len
(
txs
.
Items
)
==
0
{
d
.
resetInv
(
inv
)
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
index
:=
startHeight
set
:=
&
types
.
LocalDBSet
{}
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
for
{
if
index
>
endHeight
{
break
}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
index
)
key
:=
calcTitleHeightKey
(
cfg
.
GetTitle
(),
index
)
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
}
set
.
KV
=
append
(
set
.
KV
,
kv
)
index
++
}
key
:=
calcTitleFirstHeightKey
(
types
.
GetTitle
())
key
:=
calcTitleFirstHeightKey
(
cfg
.
GetTitle
())
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
endHeight
+
1
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
...
@@ -296,10 +297,10 @@ func (client *blockSyncClient) delLocalBlocks(startHeight int64, endHeight int64
//最低高度没有设置的时候设置一下最低高度
func
(
client
*
blockSyncClient
)
initFirstLocalHeightIfNeed
()
error
{
height
,
err
:=
client
.
getFirstLocalHeight
()
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
if
err
!=
nil
||
height
<
0
{
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleFirstHeightKey
(
types
.
GetTitle
())
key
:=
calcTitleFirstHeightKey
(
cfg
.
GetTitle
())
kv
:=
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
types
.
Int64
{
Data
:
0
})}
set
.
KV
=
append
(
set
.
KV
,
kv
)
...
...
@@ -311,7 +312,8 @@ func (client *blockSyncClient) initFirstLocalHeightIfNeed() 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
}}
value
,
err
:=
client
.
paraClient
.
getLocalDb
(
set
,
len
(
set
.
Keys
))
if
err
!=
nil
{
...
...
@@ -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
func
(
client
*
blockSyncClient
)
addMinerTx
(
preStateHash
[]
byte
,
block
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
status
:=
&
pt
.
ParacrossNodeStatus
{
Title
:
types
.
GetTitle
(),
Title
:
cfg
.
GetTitle
(),
Height
:
block
.
Height
,
PreBlockHash
:
block
.
ParentHash
,
PreStateHash
:
preStateHash
,
...
...
@@ -365,7 +368,7 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
MainBlockHeight
:
localBlock
.
MainHeight
,
}
tx
,
err
:=
pt
.
CreateRawMinerTx
(
&
pt
.
ParacrossMinerAction
{
tx
,
err
:=
pt
.
CreateRawMinerTx
(
cfg
,
&
pt
.
ParacrossMinerAction
{
Status
:
status
,
IsSelfConsensus
:
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
),
})
...
...
@@ -381,8 +384,9 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
//添加一个区块
func
(
client
*
blockSyncClient
)
addBlock
(
lastBlock
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
cfg
:=
client
.
paraClient
.
GetAPI
()
.
GetConfig
()
var
newBlock
types
.
Block
newBlock
.
ParentHash
=
lastBlock
.
Hash
()
newBlock
.
ParentHash
=
lastBlock
.
Hash
(
cfg
)
newBlock
.
Height
=
lastBlock
.
Height
+
1
newBlock
.
Txs
=
localBlock
.
Txs
err
:=
client
.
addMinerTx
(
lastBlock
.
StateHash
,
&
newBlock
,
localBlock
)
...
...
@@ -390,7 +394,7 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
return
err
}
//挖矿固定难度
newBlock
.
Difficulty
=
types
.
GetP
(
0
)
.
PowLimitBits
newBlock
.
Difficulty
=
cfg
.
GetP
(
0
)
.
PowLimitBits
newBlock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newBlock
.
Txs
)
newBlock
.
BlockTime
=
localBlock
.
BlockTime
newBlock
.
MainHash
=
localBlock
.
MainHash
...
...
plugin/dapp/autonomy/commands/proposal_board.go
View file @
02830e68
...
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"fmt"
)
// AutonomyCmd 自治系统命令行
...
...
@@ -99,6 +100,12 @@ func addProposalBoardFlags(cmd *cobra.Command) {
}
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"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
...
@@ -126,7 +133,7 @@ func proposalBoard(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropBoard"
,
Payload
:
payLoad
,
}
...
...
@@ -153,6 +160,12 @@ func addRevokeProposalBoardFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -164,7 +177,7 @@ func revokeProposalBoard(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropBoard"
,
Payload
:
payLoad
,
}
...
...
@@ -192,6 +205,12 @@ func addVoteProposalBoardFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
...
@@ -218,7 +237,7 @@ func voteProposalBoard(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropBoard"
,
Payload
:
payLoad
,
}
...
...
@@ -245,6 +264,12 @@ func addTerminateProposalBoardFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -256,7 +281,7 @@ func terminateProposalBoard(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropBoard"
,
Payload
:
payLoad
,
}
...
...
plugin/dapp/autonomy/commands/proposal_change.go
View file @
02830e68
...
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"fmt"
)
// ProposalChangeCmd 创建提案命令
...
...
@@ -41,6 +42,12 @@ func addProposalChangeFlags(cmd *cobra.Command) {
}
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"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
...
@@ -85,7 +92,7 @@ func proposalChange(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropChange"
,
Payload
:
payLoad
,
}
...
...
@@ -112,6 +119,12 @@ func addRevokeProposalChangeFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -123,7 +136,7 @@ func revokeProposalChange(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropChange"
,
Payload
:
payLoad
,
}
...
...
@@ -150,6 +163,12 @@ func addVoteProposalChangeFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
...
@@ -170,7 +189,7 @@ func voteProposalChange(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropChange"
,
Payload
:
payLoad
,
}
...
...
@@ -197,6 +216,12 @@ func addTerminateProposalChangeFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -208,7 +233,7 @@ func terminateProposalChange(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropChange"
,
Payload
:
payLoad
,
}
...
...
plugin/dapp/autonomy/commands/proposal_project.go
View file @
02830e68
...
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"fmt"
)
// ProposalProjectCmd 创建提案命令
...
...
@@ -53,6 +54,12 @@ func addProposalProjectFlags(cmd *cobra.Command) {
}
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"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
...
@@ -95,7 +102,7 @@ func proposalProject(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropProject"
,
Payload
:
payLoad
,
}
...
...
@@ -122,6 +129,12 @@ func addRevokeProposalProjectFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -133,7 +146,7 @@ func revokeProposalProject(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropProject"
,
Payload
:
payLoad
,
}
...
...
@@ -160,6 +173,12 @@ func addVoteProposalProjectFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
...
@@ -179,7 +198,7 @@ func voteProposalProject(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropProject"
,
Payload
:
payLoad
,
}
...
...
@@ -207,6 +226,12 @@ func addPubVoteProposalProjectFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
oppose
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"oppose"
)
...
...
@@ -234,7 +259,7 @@ func pubVoteProposalProject(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PubVotePropProject"
,
Payload
:
payLoad
,
}
...
...
@@ -260,6 +285,12 @@ func addTerminateProposalProjectFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -271,7 +302,7 @@ func terminateProposalProject(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropProject"
,
Payload
:
payLoad
,
}
...
...
plugin/dapp/autonomy/commands/proposal_rule.go
View file @
02830e68
...
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/types"
auty
"github.com/33cn/plugin/plugin/dapp/autonomy/types"
"github.com/spf13/cobra"
"fmt"
)
// ProposalRuleCmd 创建提案命令
...
...
@@ -45,6 +46,12 @@ func addProposalRuleFlags(cmd *cobra.Command) {
}
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"
)
year
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"year"
)
month
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"month"
)
...
...
@@ -79,7 +86,7 @@ func proposalRule(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"PropRule"
,
Payload
:
payLoad
,
}
...
...
@@ -106,6 +113,12 @@ func addRevokeProposalRuleFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -117,7 +130,7 @@ func revokeProposalRule(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"RvkPropRule"
,
Payload
:
payLoad
,
}
...
...
@@ -145,6 +158,12 @@ func addVoteProposalRuleFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
approve
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"approve"
)
...
...
@@ -171,7 +190,7 @@ func voteProposalRule(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"VotePropRule"
,
Payload
:
payLoad
,
}
...
...
@@ -197,6 +216,12 @@ func addTerminateProposalRuleFlags(cmd *cobra.Command) {
}
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"
)
ID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
...
...
@@ -208,7 +233,7 @@ func terminateProposalRule(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"TmintPropRule"
,
Payload
:
payLoad
,
}
...
...
@@ -321,6 +346,12 @@ func addTransferFundflags(cmd *cobra.Command) {
}
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"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
...
...
@@ -334,7 +365,7 @@ func transferFund(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"Transfer"
,
Payload
:
payLoad
,
}
...
...
@@ -363,6 +394,12 @@ func addCommentProposalflags(cmd *cobra.Command) {
}
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"
)
proposalID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"proposalID"
)
repHash
,
_
:=
cmd
.
Flags
()
.
GetString
(
"repHash"
)
...
...
@@ -378,7 +415,7 @@ func commentProposal(cmd *cobra.Command, args []string) {
return
}
pm
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
auty
.
AutonomyX
),
Execer
:
cfg
.
ExecName
(
auty
.
AutonomyX
),
ActionName
:
"CommentProp"
,
Payload
:
payLoad
,
}
...
...
plugin/dapp/dposvote/commands/vote.go
View file @
02830e68
...
...
@@ -86,6 +86,12 @@ func addRegistFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
...
...
@@ -93,7 +99,7 @@ func regist(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
,
\"
IP
\"
:
\"
%s
\"
}"
,
pubkey
,
address
,
ip
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRegistTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -124,13 +130,19 @@ func addCancelRegistFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
}"
,
pubkey
,
address
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateCancelRegistTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -161,6 +173,12 @@ func addVoteFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
votes
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"votes"
)
...
...
@@ -168,7 +186,7 @@ func vote(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
votes
\"
:
\"
%d
\"
,
\"
fromAddr
\"
:
\"
%s
\"
}"
,
pubkey
,
votes
,
addr
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateVoteTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -198,13 +216,19 @@ func addCancelVoteFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
index
\"
:
\"
%d
\"
}"
,
pubkey
,
index
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateCancelVoteTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -237,6 +261,12 @@ func addReRegistFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"address"
)
...
...
@@ -244,7 +274,7 @@ func reRegist(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
address
\"
:
\"
%s
\"
,
\"
IP
\"
:
\"
%s
\"
}"
,
pubkey
,
address
,
ip
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateReRegistTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -369,6 +399,12 @@ func addVrfMFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
...
...
@@ -376,7 +412,7 @@ func vrfM(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
pubkey
\"
:
\"
%s
\"
,
\"
cycle
\"
:
\"
%d
\"
,
\"
m
\"
:
\"
%s
\"
}"
,
pubkey
,
cycle
,
m
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRegistVrfMTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -412,6 +448,12 @@ func addVrfRPRegistFlags(cmd *cobra.Command) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
...
...
@@ -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
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRegistVrfRPTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -805,6 +847,12 @@ func recordCB(cmd *cobra.Command, args []string) {
if
err
!=
nil
{
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"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"privKey"
)
cycle
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"cycle"
)
...
...
@@ -851,7 +899,7 @@ func recordCB(cmd *cobra.Command, args []string) {
cycle
,
height
,
hash
,
hex
.
EncodeToString
(
privKey
.
PubKey
()
.
Bytes
()),
sig
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
dty
.
DPosX
),
Execer
:
cfg
.
ExecName
(
dty
.
DPosX
),
ActionName
:
dty
.
CreateRecordCBTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
plugin/dapp/evm/commands/evm.go
View file @
02830e68
...
...
@@ -214,6 +214,12 @@ func addCreateContractFlags(cmd *cobra.Command) {
}
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"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
...
...
@@ -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
}
}
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
{
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract error:"
,
err
)
...
...
@@ -283,10 +289,10 @@ func createContract(cmd *cobra.Command, args []string) {
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
.
Fee
,
_
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
tx
.
Fee
,
_
=
tx
.
GetRealFee
(
cfg
.
GInt
(
"MinFee"
))
if
tx
.
Fee
<
int64
(
fee
)
{
tx
.
Fee
+=
int64
(
fee
)
}
...
...
@@ -318,7 +324,7 @@ func createEvmTx(action proto.Message, execer, caller, addr, expire, rpcLaddr st
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"
)
var
tx
*
types
.
Transaction
transfer
:=
&
cty
.
CoinsAction
{}
...
...
@@ -331,13 +337,13 @@ func createEvmTransferTx(cmd *cobra.Command, caller, execName, expire, rpcLaddr
transfer
.
Ty
=
cty
.
CoinsActionTransferToExec
}
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
{
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
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
types
.
GInt
(
"MinFee"
))
tx
.
Fee
,
err
=
tx
.
GetRealFee
(
cfg
.
GInt
(
"MinFee"
))
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -381,6 +387,12 @@ func callContractCmd() *cobra.Command {
}
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"
)
caller
,
_
:=
cmd
.
Flags
()
.
GetString
(
"caller"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
...
...
@@ -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
}
//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
{
fmt
.
Fprintln
(
os
.
Stderr
,
"call contract error"
,
err
)
...
...
@@ -701,6 +713,12 @@ func addEvmTransferFlags(cmd *cobra.Command) {
}
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"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
...
...
@@ -709,7 +727,7 @@ func evmTransfer(cmd *cobra.Command, args []string) {
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
{
fmt
.
Fprintln
(
os
.
Stderr
,
"create contract transfer error:"
,
err
)
...
...
@@ -749,6 +767,12 @@ func addEvmWithdrawFlags(cmd *cobra.Command) {
}
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"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
...
...
@@ -757,7 +781,7 @@ func evmWithdraw(cmd *cobra.Command, args []string) {
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
{
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,
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
{
inData
:=
msg
.
Data
()
// 在这里进行ABI和十六进制的调用参数转换
...
...
@@ -86,7 +86,7 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
inData
=
packData
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
()))
...
...
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
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
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中恢复
for
_
,
logItem
:=
range
receipt
.
Logs
{
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
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
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
for
_
,
logItem
:=
range
receipt
.
Logs
{
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
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
)
}
else
{
// 合约地址
...
...
@@ -57,7 +58,7 @@ func (evm *EVMExecutor) Query_EstimateGas(in *evmtypes.EstimateEVMGasReq) (types
var
(
caller
common
.
Address
)
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
// 如果未指定调用地址,则直接使用一个虚拟的地址发起调用
if
len
(
in
.
Caller
)
>
0
{
callAddr
:=
common
.
StringToAddress
(
in
.
Caller
)
...
...
@@ -65,7 +66,7 @@ func (evm *EVMExecutor) Query_EstimateGas(in *evmtypes.EstimateEVMGasReq) (types
caller
=
*
callAddr
}
}
else
{
caller
=
common
.
ExecAddress
(
types
.
ExecName
(
evmtypes
.
ExecutorName
))
caller
=
common
.
ExecAddress
(
cfg
.
ExecName
(
evmtypes
.
ExecutorName
))
}
to
:=
common
.
StringToAddress
(
in
.
To
)
...
...
@@ -143,13 +144,14 @@ func (evm *EVMExecutor) Query_Query(in *evmtypes.EvmQueryReq) (types.Message, er
}
// 如果未指定调用地址,则直接使用一个虚拟的地址发起调用
cfg
:=
evm
.
GetAPI
()
.
GetConfig
()
if
len
(
in
.
Caller
)
>
0
{
callAddr
:=
common
.
StringToAddress
(
in
.
Caller
)
if
callAddr
!=
nil
{
caller
=
*
callAddr
}
}
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
)
...
...
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
// Call 此方法提供合约外部调用入口
// 根据合约地址调用已经存在的合约,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
)
if
!
pass
{
return
nil
,
-
1
,
gas
,
err
...
...
@@ -223,6 +223,7 @@ func (evm *EVM) Call(cfg *types.Chain33Config, caller ContractRef, addr common.A
}
// 从ForkV20EVMState开始,状态数据存储发生变更,需要做数据迁移
cfg
:=
evm
.
StateDB
.
GetConfig
()
if
cfg
.
IsDappFork
(
evm
.
BlockNumber
.
Int64
(),
"evm"
,
evmtypes
.
ForkEVMState
)
{
evm
.
StateDB
.
TransferStateData
(
addr
.
String
())
}
...
...
@@ -357,7 +358,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
// 使用传入的部署代码创建新的合约;
// 目前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
)
if
!
pass
{
return
nil
,
-
1
,
gas
,
err
...
...
@@ -382,6 +383,7 @@ func (evm *EVM) Create(cfg *types.Chain33Config, caller ContractRef, contractAdd
// 检查部署后的合约代码大小是否超限
maxCodeSizeExceeded
:=
len
(
ret
)
>
evm
.
maxCodeSize
cfg
:=
evm
.
StateDB
.
GetConfig
()
// 如果执行成功,计算存储合约代码需要花费的Gas
if
err
==
nil
&&
!
maxCodeSizeExceeded
{
createDataGas
:=
uint64
(
len
(
ret
))
*
params
.
CreateDataGas
...
...
plugin/dapp/evm/executor/vm/state/interface.go
View file @
02830e68
...
...
@@ -7,6 +7,7 @@ package state
import
(
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/model"
"github.com/33cn/chain33/types"
)
// EVMStateDB 状态数据库封装,面向EVM业务执行逻辑;
...
...
@@ -81,4 +82,7 @@ type EVMStateDB interface {
// GetBlockHeight 返回当前区块高度
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() {
func
(
mdb
*
MemoryStateDB
)
GetBlockHeight
()
int64
{
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) {
}
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"
)
topic
,
_
:=
cmd
.
Flags
()
.
GetString
(
"topic"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
...
...
@@ -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
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateStartTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -112,6 +118,12 @@ func addGuessBetFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
option
,
_
:=
cmd
.
Flags
()
.
GetString
(
"option"
)
...
...
@@ -119,7 +131,7 @@ func guessBet(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
option
\"
:
\"
%s
\"
,
\"
betsNum
\"
:%d}"
,
gameID
,
option
,
betsNumber
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateBetTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -147,12 +159,18 @@ func addGuessStopBetFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateStopBetTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -179,12 +197,18 @@ func addGuessAbortFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateAbortTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -214,13 +238,19 @@ func addGuessPublishFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
result
,
_
:=
cmd
.
Flags
()
.
GetString
(
"result"
)
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
gameID
,
result
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
Execer
:
cfg
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreatePublishTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
plugin/dapp/hashlock/commands/hashlock.go
View file @
02830e68
...
...
@@ -44,6 +44,12 @@ func HashlockLockCmd() *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
.
MarkFlagRequired
(
"secret"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"locking amount"
)
...
...
@@ -55,7 +61,7 @@ func addHashlockLockCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"return"
,
"r"
,
""
,
"return address"
)
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"
)
}
...
...
@@ -109,10 +115,16 @@ func HashlockUnlockCmd() *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
.
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"
)
}
...
...
plugin/dapp/js/types/js.go
View file @
02830e68
...
...
@@ -65,7 +65,7 @@ func InitFork(cfg *types.Chain33Config) {
}
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
types
.
RegistorExecutor
(
"coins"
,
NewType
(
cfg
))
types
.
RegistorExecutor
(
JsX
,
NewType
(
cfg
))
}
//JsType 类型
...
...
plugin/dapp/oracle/commands/oracle.go
View file @
02830e68
...
...
@@ -88,6 +88,12 @@ func addPublishEventFlags(cmd *cobra.Command) {
}
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"
)
if
err
!=
nil
{
fmt
.
Printf
(
"publishEvent get rpc addr Error: %v"
,
err
)
...
...
@@ -127,7 +133,7 @@ func publishEvent(cmd *cobra.Command, args []string) {
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateEventPublishTx
,
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) {
}
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"
)
if
err
!=
nil
{
fmt
.
Printf
(
"abortPublishEvent rpc_addr Error: %v"
,
err
)
...
...
@@ -169,7 +181,7 @@ func abortPublishEvent(cmd *cobra.Command, args []string) {
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateAbortEventPublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
}"
,
eventID
)),
}
...
...
@@ -213,6 +225,12 @@ func addPrePublishResultFlags(cmd *cobra.Command) {
}
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"
)
if
err
!=
nil
{
fmt
.
Printf
(
"prePublishResult rpc_laddr Error: %v"
,
err
)
...
...
@@ -235,7 +253,7 @@ func prePublishResult(cmd *cobra.Command, args []string) {
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreatePrePublishResultTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
,
\"
source
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
eventID
,
source
,
result
)),
}
...
...
@@ -265,6 +283,12 @@ func addAbortPrePubResultFlags(cmd *cobra.Command) {
}
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"
)
if
err
!=
nil
{
fmt
.
Printf
(
"abortPrePubResult rpc_laddr Error: %v"
,
err
)
...
...
@@ -277,7 +301,7 @@ func abortPrePubResult(cmd *cobra.Command, args []string) {
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateAbortResultPrePublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
}"
,
eventID
)),
}
...
...
@@ -321,6 +345,12 @@ func addPublishResultFlags(cmd *cobra.Command) {
}
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"
)
if
err
!=
nil
{
fmt
.
Printf
(
"publishResult rpc_laddr Error: %v"
,
err
)
...
...
@@ -343,7 +373,7 @@ func publishResult(cmd *cobra.Command, args []string) {
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
oraclety
.
OracleX
),
Execer
:
cfg
.
ExecName
(
oraclety
.
OracleX
),
ActionName
:
oraclety
.
CreateResultPublishTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
eventID
\"
:
\"
%s
\"
,
\"
source
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
eventID
,
source
,
result
)),
}
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
02830e68
This diff is collapsed.
Click to expand it.
plugin/dapp/pokerbull/cmd/game.go
View file @
02830e68
...
...
@@ -54,12 +54,18 @@ func addPokerbullStartFlags(cmd *cobra.Command) {
}
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"
)
value
,
_
:=
cmd
.
Flags
()
.
GetUint64
(
"value"
)
playerCount
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"playerCount"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreateStartTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
value
\"
:%d,
\"
playerNum
\"
:%d}"
,
int64
(
value
)
*
types
.
Coin
,
int32
(
playerCount
))),
}
...
...
@@ -86,11 +92,17 @@ func addPokerbullContinueFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreateContinueTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
}
...
...
@@ -117,11 +129,17 @@ func addPokerbullQuitFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreateQuitTx
,
Payload
:
[]
byte
(
fmt
.
Sprintf
(
"{
\"
gameId
\"
:
\"
%s
\"
}"
,
gameID
)),
}
...
...
@@ -154,6 +172,12 @@ func addPokerbullPlayFlags(cmd *cobra.Command) {
}
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"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameID"
)
round
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"round"
)
...
...
@@ -169,7 +193,7 @@ func pokerbullPlay(cmd *cobra.Command, args []string) {
copy
(
payload
.
Address
,
address
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
PokerBullX
),
Execer
:
cfg
.
ExecName
(
pkt
.
PokerBullX
),
ActionName
:
pkt
.
CreatePlayTx
,
Payload
:
types
.
MustPBToJSON
(
payload
),
}
...
...
plugin/dapp/retrieve/cmd/retrieve.go
View file @
02830e68
...
...
@@ -53,6 +53,12 @@ func BackupCmd() *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
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
...
...
@@ -60,7 +66,7 @@ func addBakupCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
Int64P
(
"delay"
,
"d"
,
60
,
"delay period (minimum 60 seconds)"
)
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"
)
}
...
...
@@ -98,16 +104,28 @@ func PrepareCmd() *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
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
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"
)
}
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
.
MarkFlagRequired
(
"backup"
)
cmd
.
Flags
()
.
StringP
(
"default"
,
"t"
,
""
,
"default address"
)
...
...
@@ -116,7 +134,7 @@ func addPerformCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringArrayP
(
"exec"
,
"e"
,
[]
string
{},
"asset exec"
)
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"
)
}
...
...
plugin/dapp/ticket/commands/ticket.go
View file @
02830e68
...
...
@@ -54,6 +54,12 @@ func addBindMinerFlags(cmd *cobra.Command) {
}
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"
)
originAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"origin_addr"
)
//c, _ := crypto.New(types.GetSignName(wallet.SignType))
...
...
@@ -68,7 +74,7 @@ func bindMiner(cmd *cobra.Command, args []string) {
ta
.
Value
=
&
ty
.
TicketAction_Tbind
{
Tbind
:
tBind
}
ta
.
Ty
=
ty
.
TicketActionBind
tx
,
err
:=
types
.
CreateFormatTx
(
"ticket"
,
types
.
Encode
(
ta
))
tx
,
err
:=
types
.
CreateFormatTx
(
cfg
,
"ticket"
,
types
.
Encode
(
ta
))
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
...
...
plugin/dapp/unfreeze/commands/unfreeze.go
View file @
02830e68
...
...
@@ -112,6 +112,12 @@ func fixAmountCmd() *cobra.Command {
}
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
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
...
@@ -140,7 +146,7 @@ func fixAmount(cmd *cobra.Command, args []string) {
create
.
MeansOpt
=
&
pty
.
UnfreezeCreate_FixAmount
{
FixAmount
:
&
pty
.
FixAmount
{
Period
:
period
,
Amount
:
amountInt64
}}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
"createUnfreeze"
,
Payload
:
types
.
MustPBToJSON
(
create
),
}
...
...
@@ -166,6 +172,12 @@ func leftCmd() *cobra.Command {
}
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
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
...
@@ -189,7 +201,7 @@ func left(cmd *cobra.Command, args []string) {
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
pty
.
Action_CreateUnfreeze
,
Payload
:
types
.
MustPBToJSON
(
create
),
}
...
...
@@ -248,10 +260,16 @@ func queryWithdrawCmd() *cobra.Command {
}
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"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
pty
.
Action_WithdrawUnfreeze
,
Payload
:
types
.
MustPBToJSON
(
&
pty
.
UnfreezeWithdraw
{
UnfreezeID
:
id
}),
}
...
...
@@ -262,10 +280,16 @@ func withdraw(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"
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pty
.
UnfreezeX
),
Execer
:
cfg
.
ExecName
(
pty
.
UnfreezeX
),
ActionName
:
pty
.
Action_TerminateUnfreeze
,
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) {
}
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"
)
pubkey
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkey"
)
power
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"power"
)
...
...
@@ -164,7 +170,7 @@ func addNode(cmd *cobra.Command, args []string) {
value
:=
&
vt
.
ValNodeAction_Node
{
Node
:
&
vt
.
ValNode
{
PubKey
:
pubkeybyte
,
Power
:
power
}}
action
:=
&
vt
.
ValNodeAction
{
Value
:
value
,
Ty
:
vt
.
ValNodeActionUpdate
}
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
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
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