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
5728f60e
Commit
5728f60e
authored
May 08, 2019
by
mdj33
Committed by
vipwzw
May 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ut
parent
703449dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
para.go
plugin/consensus/para/para.go
+8
-2
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+6
-1
paranode_test.go
plugin/consensus/para/paranode_test.go
+11
-13
No files found.
plugin/consensus/para/para.go
View file @
5728f60e
...
...
@@ -817,7 +817,10 @@ func checkMinerTx(current *types.BlockDetail) error {
// Query_CreateNewAccount 通知para共识模块钱包创建了一个新的账户
func
(
client
*
client
)
Query_CreateNewAccount
(
acc
*
types
.
Account
)
(
types
.
Message
,
error
)
{
plog
.
Info
(
"Query_CreateNewAccount"
,
"acc"
,
acc
)
if
acc
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
plog
.
Info
(
"Query_CreateNewAccount"
,
"acc"
,
acc
.
Addr
)
// 需要para共识这边处理新创建的账户是否是超级节点发送commit共识交易的账户
client
.
commitMsgClient
.
onWalletAccount
(
acc
)
return
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
[]
byte
(
"OK"
)},
nil
...
...
@@ -825,7 +828,10 @@ func (client *client) Query_CreateNewAccount(acc *types.Account) (types.Message,
// Query_WalletStatus 通知para共识模块钱包锁状态有变化
func
(
client
*
client
)
Query_WalletStatus
(
walletStatus
*
types
.
WalletStatus
)
(
types
.
Message
,
error
)
{
plog
.
Info
(
"Query_WalletStatus"
,
"walletStatus"
,
walletStatus
)
if
walletStatus
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
plog
.
Info
(
"Query_WalletStatus"
,
"walletStatus"
,
walletStatus
.
IsWalletLock
)
// 需要para共识这边根据walletStatus.IsWalletLock锁的状态开启/关闭发送共识交易
client
.
commitMsgClient
.
onWalletStatus
(
walletStatus
)
return
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
[]
byte
(
"OK"
)},
nil
...
...
plugin/consensus/para/paracommitmsg.go
View file @
5728f60e
...
...
@@ -205,7 +205,7 @@ out:
continue
}
//开启挖矿
if
client
.
privateKey
!=
nil
&&
readTick
==
nil
{
if
readTick
==
nil
{
ticker
=
time
.
NewTicker
(
time
.
Second
*
time
.
Duration
(
minerInterval
))
readTick
=
ticker
.
C
plog
.
Info
(
"para consensus start mining"
)
...
...
@@ -593,6 +593,11 @@ func (client *commitMsgClient) onWalletStatus(status *types.WalletStatus) {
plog
.
Info
(
"para commit fetchPriKey"
)
}
if
client
.
privateKey
==
nil
{
plog
.
Info
(
"para commit wallet status prikey null"
,
"status"
,
status
.
IsWalletLock
)
return
}
select
{
case
client
.
minerSwitch
<-
!
status
.
IsWalletLock
:
case
<-
client
.
quit
:
...
...
plugin/consensus/para/paranode_test.go
View file @
5728f60e
...
...
@@ -50,42 +50,40 @@ func TestParaNode(t *testing.T) {
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
detail
.
Receipt
.
Ty
,
int32
(
types
.
ExecOk
))
testParaQuery
(
para
)
for
i
:=
0
;
i
<
3
;
i
++
{
tx
=
util
.
CreateTxWithExecer
(
para
.
Para
.
GetGenesisKey
(),
"user.p.guodun.none"
)
para
.
Para
.
SendTxRPC
(
tx
)
para
.
Para
.
WaitHeight
(
int64
(
i
)
+
1
)
}
testParaQuery
(
para
)
}
func
testParaQuery
(
para
*
node
.
ParaNode
)
{
var
param
types
.
ReqWalletImportPrivkey
param
.
Label
=
"Importprivkey"
param
.
Privkey
=
"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
var
acc
types
.
Account
acc
.
Addr
=
"1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF"
para
.
Para
.
GetAPI
()
.
Notify
(
"consensus"
,
types
.
EventConsensusQuery
,
&
types
.
ChainExecutor
{
Driver
:
"para"
,
FuncName
:
"CreateNewAccount"
,
Param
:
types
.
Encode
(
&
param
),
Param
:
types
.
Encode
(
&
acc
),
})
var
param1
types
.
ReqNewAccount
param1
.
Label
=
"NewAccount"
var
walletsatus
types
.
WalletStatus
walletsatus
.
IsWalletLock
=
true
para
.
Para
.
GetAPI
()
.
Notify
(
"consensus"
,
types
.
EventConsensusQuery
,
&
types
.
ChainExecutor
{
Driver
:
"para"
,
FuncName
:
"
CreateNewAccount
"
,
Param
:
types
.
Encode
(
&
param1
),
FuncName
:
"
WalletStatus
"
,
Param
:
types
.
Encode
(
&
walletsatus
),
})
var
walletsatus
types
.
WalletStatus
walletsatus
.
IsWalletLock
=
true
walletsatus
.
IsWalletLock
=
false
para
.
Para
.
GetAPI
()
.
Notify
(
"consensus"
,
types
.
EventConsensusQuery
,
&
types
.
ChainExecutor
{
Driver
:
"para"
,
FuncName
:
"WalletStatus"
,
Param
:
types
.
Encode
(
&
walletsatus
),
})
}
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