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
83fa966c
Commit
83fa966c
authored
Aug 09, 2019
by
yukang
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct code style
parent
5cd041d5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
para.go
plugin/consensus/para/para.go
+6
-6
para_test.go
plugin/consensus/para/para_test.go
+1
-1
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+2
-2
paracreate.go
plugin/consensus/para/paracreate.go
+1
-1
parasync.go
plugin/consensus/para/parasync.go
+0
-0
parasync_test.go
plugin/consensus/para/parasync_test.go
+6
-6
No files found.
plugin/consensus/para/para.go
View file @
83fa966c
...
...
@@ -63,7 +63,7 @@ type client struct {
execAPI
api
.
ExecutorAPI
caughtUp
int32
commitMsgClient
*
commitMsgClient
blockSyncClient
*
B
lockSyncClient
blockSyncClient
*
b
lockSyncClient
authAccount
string
privateKey
crypto
.
PrivKey
wg
sync
.
WaitGroup
...
...
@@ -182,12 +182,12 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
para
.
commitMsgClient
.
consensStartHeight
=
subcfg
.
ParaConsensStartHeight
-
1
}
para
.
blockSyncClient
=
&
B
lockSyncClient
{
para
.
blockSyncClient
=
&
b
lockSyncClient
{
paraClient
:
para
,
notifyChan
:
make
(
chan
bool
,
1
),
quitChan
:
make
(
chan
struct
{}),
maxCacheCount
:
D
efaultMaxCacheCount
,
maxSyncErrCount
:
D
efaultMaxSyncErrCount
,
maxCacheCount
:
d
efaultMaxCacheCount
,
maxSyncErrCount
:
d
efaultMaxSyncErrCount
,
isPrintDebugInfo
:
false
,
}
if
subcfg
.
MaxCacheCount
>
0
{
...
...
@@ -229,7 +229,7 @@ func (client *client) SetQueueClient(c queue.Client) {
client
.
wg
.
Add
(
1
)
go
client
.
CreateBlock
()
client
.
wg
.
Add
(
1
)
go
client
.
blockSyncClient
.
S
yncBlocks
()
go
client
.
blockSyncClient
.
s
yncBlocks
()
}
func
(
client
*
client
)
InitBlock
()
{
...
...
@@ -258,7 +258,7 @@ func (client *client) InitBlock() {
tx
:=
client
.
CreateGenesisTx
()
newblock
.
Txs
=
tx
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
err
:=
client
.
blockSyncClient
.
C
reateGenesisBlock
(
newblock
)
err
:=
client
.
blockSyncClient
.
c
reateGenesisBlock
(
newblock
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"para chain create genesis block,err=%s"
,
err
.
Error
()))
}
...
...
plugin/consensus/para/para_test.go
View file @
83fa966c
...
...
@@ -204,7 +204,7 @@ func TestAddMinerTx(t *testing.T) {
para
.
commitMsgClient
=
new
(
commitMsgClient
)
para
.
commitMsgClient
.
paraClient
=
para
para
.
blockSyncClient
=
new
(
B
lockSyncClient
)
para
.
blockSyncClient
=
new
(
b
lockSyncClient
)
para
.
blockSyncClient
.
paraClient
=
para
para
.
blockSyncClient
.
addMinerTx
(
nil
,
block
,
localBlock
)
assert
.
Equal
(
t
,
1
,
len
(
block
.
Txs
))
...
...
plugin/consensus/para/paracommitmsg.go
View file @
83fa966c
...
...
@@ -314,8 +314,8 @@ func (client *commitMsgClient) isSync() bool {
return
false
}
if
!
client
.
paraClient
.
blockSyncClient
.
S
yncHasCaughtUp
()
{
plog
.
Info
(
"para is not Sync"
,
"syncCaughtUp"
,
client
.
paraClient
.
blockSyncClient
.
S
yncHasCaughtUp
())
if
!
client
.
paraClient
.
blockSyncClient
.
s
yncHasCaughtUp
()
{
plog
.
Info
(
"para is not Sync"
,
"syncCaughtUp"
,
client
.
paraClient
.
blockSyncClient
.
s
yncHasCaughtUp
())
return
false
}
...
...
plugin/consensus/para/paracreate.go
View file @
83fa966c
...
...
@@ -465,7 +465,7 @@ func (client *client) procLocalBlocks(mainBlocks *types.ParaTxDetails) error {
}
}
if
notify
{
client
.
blockSyncClient
.
N
otifyLocalChange
()
client
.
blockSyncClient
.
n
otifyLocalChange
()
}
return
nil
...
...
plugin/consensus/para/parasync.go
View file @
83fa966c
This diff is collapsed.
Click to expand it.
plugin/consensus/para/parasync_test.go
View file @
83fa966c
...
...
@@ -68,7 +68,7 @@ func createParaTestInstance(t *testing.T, q queue.Queue) *client {
para
.
privateKey
=
priKey
//实例化BlockSyncClient
para
.
blockSyncClient
=
&
B
lockSyncClient
{
para
.
blockSyncClient
=
&
b
lockSyncClient
{
paraClient
:
para
,
notifyChan
:
make
(
chan
bool
),
quitChan
:
make
(
chan
struct
{}),
...
...
@@ -333,7 +333,7 @@ func mockMessageReply(q queue.Queue) {
//测试创世区块写入
func
testCreateGenesisBlock
(
t
*
testing
.
T
,
para
*
client
,
testLoopCount
int32
)
{
genesisBlock
:=
makeGenesisBlockInputTestData
()
err
:=
para
.
blockSyncClient
.
C
reateGenesisBlock
(
genesisBlock
)
err
:=
para
.
blockSyncClient
.
c
reateGenesisBlock
(
genesisBlock
)
switch
testLoopCount
{
case
0
:
...
...
@@ -394,9 +394,9 @@ func testSyncBlocksIfNeed(t *testing.T, para *client, testLoopCount int32) {
//测试SyncHasCaughtUp
func
testSyncHasCaughtUp
(
t
*
testing
.
T
,
para
*
client
,
testLoopCount
int32
)
{
oldValue
:=
para
.
blockSyncClient
.
S
yncHasCaughtUp
()
oldValue
:=
para
.
blockSyncClient
.
s
yncHasCaughtUp
()
para
.
blockSyncClient
.
setSyncCaughtUp
(
true
)
isSyncHasCaughtUp
:=
para
.
blockSyncClient
.
S
yncHasCaughtUp
()
isSyncHasCaughtUp
:=
para
.
blockSyncClient
.
s
yncHasCaughtUp
()
para
.
blockSyncClient
.
setSyncCaughtUp
(
oldValue
)
assert
.
Equal
(
t
,
true
,
isSyncHasCaughtUp
)
...
...
@@ -405,11 +405,11 @@ func testSyncHasCaughtUp(t *testing.T, para *client, testLoopCount int32) {
//测试getBlockSyncState
func
testGetBlockSyncState
(
t
*
testing
.
T
,
para
*
client
,
testLoopCount
int32
)
{
oldValue
:=
para
.
blockSyncClient
.
getBlockSyncState
()
para
.
blockSyncClient
.
setBlockSyncState
(
B
lockSyncStateFinished
)
para
.
blockSyncClient
.
setBlockSyncState
(
b
lockSyncStateFinished
)
syncState
:=
para
.
blockSyncClient
.
getBlockSyncState
()
para
.
blockSyncClient
.
setBlockSyncState
(
oldValue
)
assert
.
Equal
(
t
,
true
,
syncState
==
B
lockSyncStateFinished
)
assert
.
Equal
(
t
,
true
,
syncState
==
b
lockSyncStateFinished
)
}
//执行所有函数测试
...
...
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