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
c9ffd835
Commit
c9ffd835
authored
Mar 26, 2019
by
mdj33
Committed by
33cn
Mar 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add lock to isCaughtup
parent
fa8b1676
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
para.go
plugin/consensus/para/para.go
+8
-2
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+9
-2
No files found.
plugin/consensus/para/para.go
View file @
c9ffd835
...
...
@@ -68,6 +68,7 @@ type client struct {
privateKey
crypto
.
PrivKey
wg
sync
.
WaitGroup
subCfg
*
subConfig
mtx
sync
.
Mutex
}
type
subConfig
struct
{
...
...
@@ -139,7 +140,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
grpcClient
:
grpcCli
,
authAccount
:
subcfg
.
AuthAccount
,
privateKey
:
priKey
,
isCaughtUp
:
false
,
subCfg
:
&
subcfg
,
}
if
subcfg
.
WaitBlocks4CommitMsg
<
2
{
...
...
@@ -473,11 +473,13 @@ func (client *client) RequestTx(currSeq int64, preMainBlockHash []byte) ([]*type
txs
:=
client
.
FilterTxsForPara
(
blockSeq
.
Detail
)
plog
.
Info
(
"GetCurrentSeq"
,
"Len of txs"
,
len
(
txs
),
"seqTy"
,
blockSeq
.
Seq
.
Type
)
client
.
mtx
.
Lock
()
if
lastSeq
-
currSeq
>
emptyBlockInterval
{
client
.
isCaughtUp
=
false
}
else
{
client
.
isCaughtUp
=
true
}
client
.
mtx
.
Unlock
()
if
client
.
authAccount
!=
""
{
client
.
commitMsgClient
.
onMainBlockAdded
(
blockSeq
.
Detail
)
...
...
@@ -808,7 +810,11 @@ func (client *client) Query_IsCaughtUp(req *types.ReqNil) (types.Message, error)
if
client
==
nil
{
return
nil
,
fmt
.
Errorf
(
"%s"
,
"client not bind message queue."
)
}
return
&
types
.
IsCaughtUp
{
Iscaughtup
:
client
.
isCaughtUp
},
nil
client
.
mtx
.
Lock
()
caughtUp
:=
client
.
isCaughtUp
client
.
mtx
.
Unlock
()
return
&
types
.
IsCaughtUp
{
Iscaughtup
:
caughtUp
},
nil
}
func
checkMinerTx
(
current
*
types
.
BlockDetail
)
error
{
...
...
plugin/consensus/para/paracommitmsg.go
View file @
c9ffd835
...
...
@@ -97,7 +97,10 @@ out:
plog
.
Debug
(
"para del block"
,
"delHeight"
,
height
)
case
block
:=
<-
client
.
mainBlockAdd
:
if
client
.
currentTx
!=
nil
&&
client
.
paraClient
.
isCaughtUp
{
client
.
paraClient
.
mtx
.
Lock
()
isCaughtUp
:=
client
.
paraClient
.
isCaughtUp
client
.
paraClient
.
mtx
.
Unlock
()
if
client
.
currentTx
!=
nil
&&
isCaughtUp
{
exist
:=
checkTxInMainBlock
(
client
.
currentTx
,
block
)
if
exist
{
finishHeight
=
sendingHeight
...
...
@@ -487,6 +490,7 @@ func (client *commitMsgClient) mainSync() error {
func
(
client
*
commitMsgClient
)
getConsensusHeight
(
consensusRst
chan
*
pt
.
ParacrossStatus
)
{
ticker
:=
time
.
NewTicker
(
time
.
Second
*
time
.
Duration
(
consensusInterval
))
isSync
:=
false
isCaughtUp
:=
false
defer
ticker
.
Stop
()
out
:
...
...
@@ -503,7 +507,10 @@ out:
isSync
=
true
}
if
!
client
.
paraClient
.
isCaughtUp
{
client
.
paraClient
.
mtx
.
Lock
()
isCaughtUp
=
client
.
paraClient
.
isCaughtUp
client
.
paraClient
.
mtx
.
Unlock
()
if
!
isCaughtUp
{
plog
.
Debug
(
"getConsensusHeight para is CatchingUp"
)
continue
}
...
...
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