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
16b9b452
Commit
16b9b452
authored
Dec 26, 2018
by
harrylee2015
Committed by
vipwzw
Jan 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add feature for parachain check is sync..
parent
69aba101
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
6 deletions
+38
-6
para.go
plugin/consensus/para/para.go
+13
-4
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+1
-1
queueprotocol.go
vendor/github.com/33cn/chain33/client/queueprotocol.go
+7
-1
base.go
vendor/github.com/33cn/chain33/system/consensus/base.go
+17
-0
No files found.
plugin/consensus/para/para.go
View file @
16b9b452
...
@@ -60,7 +60,7 @@ type client struct {
...
@@ -60,7 +60,7 @@ type client struct {
conn
*
grpc
.
ClientConn
conn
*
grpc
.
ClientConn
grpcClient
types
.
Chain33Client
grpcClient
types
.
Chain33Client
paraClient
paracross
.
ParacrossClient
paraClient
paracross
.
ParacrossClient
is
CatchingUp
bool
is
caughtup
bool
commitMsgClient
*
commitMsgClient
commitMsgClient
*
commitMsgClient
authAccount
string
authAccount
string
privateKey
crypto
.
PrivKey
privateKey
crypto
.
PrivKey
...
@@ -119,6 +119,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -119,6 +119,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
paraClient
:
paraCli
,
paraClient
:
paraCli
,
authAccount
:
cfg
.
AuthAccount
,
authAccount
:
cfg
.
AuthAccount
,
privateKey
:
priKey
,
privateKey
:
priKey
,
iscaughtup
:
false
,
}
}
if
cfg
.
WaitBlocks4CommitMsg
<
2
{
if
cfg
.
WaitBlocks4CommitMsg
<
2
{
...
@@ -444,9 +445,9 @@ func (client *client) RequestTx(currSeq int64, preMainBlockHash []byte) ([]*type
...
@@ -444,9 +445,9 @@ func (client *client) RequestTx(currSeq int64, preMainBlockHash []byte) ([]*type
plog
.
Info
(
"GetCurrentSeq"
,
"Len of txs"
,
len
(
txs
),
"seqTy"
,
seqTy
)
plog
.
Info
(
"GetCurrentSeq"
,
"Len of txs"
,
len
(
txs
),
"seqTy"
,
seqTy
)
if
lastSeq
-
currSeq
>
emptyBlockInterval
{
if
lastSeq
-
currSeq
>
emptyBlockInterval
{
client
.
is
CatchingUp
=
tru
e
client
.
is
caughtup
=
fals
e
}
else
{
}
else
{
client
.
is
CatchingUp
=
fals
e
client
.
is
caughtup
=
tru
e
}
}
if
client
.
authAccount
!=
""
{
if
client
.
authAccount
!=
""
{
...
@@ -654,7 +655,7 @@ func (client *client) CreateBlock() {
...
@@ -654,7 +655,7 @@ func (client *client) CreateBlock() {
plog
.
Error
(
"Incorrect sequence type"
)
plog
.
Error
(
"Incorrect sequence type"
)
incSeqFlag
=
false
incSeqFlag
=
false
}
}
if
!
client
.
isCatchingU
p
{
if
client
.
iscaughtu
p
{
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
blockSec
))
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
blockSec
))
}
}
}
}
...
@@ -766,6 +767,14 @@ func (client *client) DelBlock(block *types.Block, seq int64) error {
...
@@ -766,6 +767,14 @@ func (client *client) DelBlock(block *types.Block, seq int64) error {
return
nil
return
nil
}
}
//IsCaughtUp 是否追上最新高度,
func
(
client
*
client
)
Query_IsCaughtUp
(
req
*
types
.
ReqNil
)
(
types
.
Message
,
error
)
{
if
client
==
nil
{
return
nil
,
fmt
.
Errorf
(
"client not bind message queue."
)
}
return
&
types
.
IsCaughtUp
{
Iscaughtup
:
client
.
iscaughtup
},
nil
}
func
checkMinerTx
(
current
*
types
.
BlockDetail
)
error
{
func
checkMinerTx
(
current
*
types
.
BlockDetail
)
error
{
//检查第一个笔交易的execs, 以及执行状态
//检查第一个笔交易的execs, 以及执行状态
if
len
(
current
.
Block
.
Txs
)
==
0
{
if
len
(
current
.
Block
.
Txs
)
==
0
{
...
...
plugin/consensus/para/paracommitmsg.go
View file @
16b9b452
...
@@ -83,7 +83,7 @@ out:
...
@@ -83,7 +83,7 @@ out:
}
}
case
block
:=
<-
client
.
mainBlockAdd
:
case
block
:=
<-
client
.
mainBlockAdd
:
if
client
.
currentTx
!=
nil
&&
!
client
.
paraClient
.
isCatchingU
p
{
if
client
.
currentTx
!=
nil
&&
client
.
paraClient
.
iscaughtu
p
{
exist
:=
checkTxInMainBlock
(
client
.
currentTx
,
block
)
exist
:=
checkTxInMainBlock
(
client
.
currentTx
,
block
)
if
exist
{
if
exist
{
finishHeight
=
sendingHeight
finishHeight
=
sendingHeight
...
...
vendor/github.com/33cn/chain33/client/queueprotocol.go
View file @
16b9b452
...
@@ -678,7 +678,13 @@ func (q *QueueProtocol) DumpPrivkey(param *types.ReqString) (*types.ReplyString,
...
@@ -678,7 +678,13 @@ func (q *QueueProtocol) DumpPrivkey(param *types.ReqString) (*types.ReplyString,
// IsSync query the blockchain sync state
// IsSync query the blockchain sync state
func
(
q
*
QueueProtocol
)
IsSync
()
(
*
types
.
Reply
,
error
)
{
func
(
q
*
QueueProtocol
)
IsSync
()
(
*
types
.
Reply
,
error
)
{
msg
,
err
:=
q
.
query
(
blockchainKey
,
types
.
EventIsSync
,
&
types
.
ReqNil
{})
var
msg
queue
.
Message
var
err
error
if
types
.
IsPara
()
{
msg
,
err
=
q
.
query
(
consensusKey
,
types
.
EventIsSync
,
&
types
.
ReqNil
{})
}
else
{
msg
,
err
=
q
.
query
(
blockchainKey
,
types
.
EventIsSync
,
&
types
.
ReqNil
{})
}
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"IsSync"
,
"Error"
,
err
.
Error
())
log
.
Error
(
"IsSync"
,
"Error"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
...
...
vendor/github.com/33cn/chain33/system/consensus/base.go
View file @
16b9b452
...
@@ -216,6 +216,23 @@ func (bc *BaseClient) EventLoop() {
...
@@ -216,6 +216,23 @@ func (bc *BaseClient) EventLoop() {
block
:=
msg
.
GetData
()
.
(
*
types
.
BlockDetail
)
block
:=
msg
.
GetData
()
.
(
*
types
.
BlockDetail
)
err
:=
bc
.
CheckBlock
(
block
)
err
:=
bc
.
CheckBlock
(
block
)
msg
.
ReplyErr
(
"EventCheckBlock"
,
err
)
msg
.
ReplyErr
(
"EventCheckBlock"
,
err
)
}
else
if
msg
.
Ty
==
types
.
EventIsSync
{
if
types
.
IsPara
()
{
reply
,
err
:=
QueryData
.
Call
(
"para"
,
"IsCaughtUp"
,
&
types
.
ReqNil
{})
if
err
!=
nil
{
msg
.
Reply
(
bc
.
api
.
NewMessage
(
""
,
types
.
EventReplyIsSync
,
err
))
}
else
{
if
isCaughtUp
,
ok
:=
reply
.
(
*
types
.
IsCaughtUp
);
ok
{
msg
.
Reply
(
bc
.
api
.
NewMessage
(
""
,
types
.
EventReplyIsSync
,
isCaughtUp
))
}
else
{
err
=
types
.
ErrTypeAsset
msg
.
Reply
(
bc
.
api
.
NewMessage
(
""
,
types
.
EventReplyIsSync
,
err
))
}
}
}
else
{
msg
.
Reply
(
bc
.
api
.
NewMessage
(
""
,
types
.
EventReplyIsSync
,
&
types
.
IsCaughtUp
{
Iscaughtup
:
bc
.
IsCaughtUp
()}))
}
}
else
if
msg
.
Ty
==
types
.
EventMinerStart
{
}
else
if
msg
.
Ty
==
types
.
EventMinerStart
{
if
!
atomic
.
CompareAndSwapInt32
(
&
bc
.
minerStart
,
0
,
1
)
{
if
!
atomic
.
CompareAndSwapInt32
(
&
bc
.
minerStart
,
0
,
1
)
{
msg
.
ReplyErr
(
"EventMinerStart"
,
types
.
ErrMinerIsStared
)
msg
.
ReplyErr
(
"EventMinerStart"
,
types
.
ErrMinerIsStared
)
...
...
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