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
f500379f
Commit
f500379f
authored
Jul 26, 2019
by
mdj33
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit msg get local consens height
parent
c6fa4e0b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
92 deletions
+133
-92
para.go
plugin/consensus/para/para.go
+2
-2
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+103
-59
paracreate.go
plugin/consensus/para/paracreate.go
+2
-5
paratxrequest_test.go
plugin/consensus/para/paratxrequest_test.go
+26
-26
No files found.
plugin/consensus/para/para.go
View file @
f500379f
...
...
@@ -162,7 +162,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
quitCreate
:
make
(
chan
struct
{}),
}
waitBlocks
:=
int32
(
2
)
//最小是2
waitBlocks
:=
int32
(
3
)
//最小是2
if
subcfg
.
WaitBlocks4CommitMsg
>
0
{
if
subcfg
.
WaitBlocks4CommitMsg
<
waitBlocks
{
panic
(
"config WaitBlocks4CommitMsg should not less 2"
)
...
...
@@ -181,7 +181,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
waitConsensStopTimes
:
waitConsensTimes
,
commitCh
:
make
(
chan
int64
,
1
),
resetCh
:
make
(
chan
int64
,
1
),
verifyCh
:
make
(
chan
[]
byte
,
1
),
verifyCh
:
make
(
chan
bool
,
1
),
consensHeight
:
-
2
,
sendingHeight
:
-
1
,
quit
:
make
(
chan
struct
{}),
...
...
plugin/consensus/para/paracommitmsg.go
View file @
f500379f
This diff is collapsed.
Click to expand it.
plugin/consensus/para/paracreate.go
View file @
f500379f
...
...
@@ -59,11 +59,8 @@ func (client *client) checkCommitTxSuccess(txs []*pt.TxDetail) {
}
}
if
txMap
[
string
(
curTx
.
Hash
())]
{
client
.
commitMsgClient
.
verifyNotify
(
curTx
.
Hash
())
}
else
{
client
.
commitMsgClient
.
verifyNotify
(
nil
)
}
client
.
commitMsgClient
.
verifyNotify
(
txMap
[
string
(
curTx
.
Hash
())])
}
func
(
client
*
client
)
createLocalBlock
(
lastBlock
*
pt
.
ParaLocalDbBlock
,
txs
[]
*
types
.
Transaction
,
mainBlock
*
pt
.
ParaTxDetail
)
error
{
...
...
plugin/consensus/para/paratxrequest_test.go
View file @
f500379f
...
...
@@ -69,32 +69,32 @@ func TestCalcCommitMsgTxs(t *testing.T) {
}
func
TestGetConsensusStatus
(
t
*
testing
.
T
)
{
para
:=
new
(
client
)
grpcClient
:=
&
typesmocks
.
Chain33Client
{}
//grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
para
.
grpcClient
=
grpcClient
commitCli
:=
new
(
commitMsgClient
)
commitCli
.
paraClient
=
para
block
:=
&
types
.
Block
{
Height
:
1
,
MainHeight
:
10
,
}
status
:=
&
pt
.
ParacrossStatus
{
Height
:
1
,
}
reply
:=
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
types
.
Encode
(
status
),
}
grpcClient
.
On
(
"QueryChain"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
reply
,
nil
)
.
Once
()
ret
,
err
:=
commitCli
.
getConsensusStatus
(
block
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
1
),
ret
.
Height
)
}
//
func TestGetConsensusStatus(t *testing.T) {
//
para := new(client)
//
grpcClient := &typesmocks.Chain33Client{}
//
//grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
//
para.grpcClient = grpcClient
//
commitCli := new(commitMsgClient)
//
commitCli.paraClient = para
//
//
block := &types.Block{
//
Height: 1,
//
MainHeight: 10,
//
}
//
//
status := &pt.ParacrossStatus{
//
Height: 1,
//
}
//
reply := &types.Reply{
//
IsOk: true,
//
Msg: types.Encode(status),
//
}
//
grpcClient.On("QueryChain", mock.Anything, mock.Anything).Return(reply, nil).Once()
// ret, err := commitCli.getSelfConsensusStatus(
)
//
//
assert.Nil(t, err)
//
assert.Equal(t, int64(1), ret.Height)
//
}
func
TestSendCommitMsg
(
t
*
testing
.
T
)
{
para
:=
new
(
client
)
...
...
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