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
14ddd950
Commit
14ddd950
authored
Aug 04, 2019
by
yukang
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize some sync code for review
parent
0e0bc545
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
para.go
plugin/consensus/para/para.go
+2
-2
parasync.go
plugin/consensus/para/parasync.go
+16
-0
No files found.
plugin/consensus/para/para.go
View file @
14ddd950
...
@@ -192,8 +192,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -192,8 +192,8 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
paraClient
:
para
,
paraClient
:
para
,
notifyChan
:
make
(
chan
bool
),
notifyChan
:
make
(
chan
bool
),
quitChan
:
make
(
chan
struct
{}),
quitChan
:
make
(
chan
struct
{}),
maxCacheCount
:
1000
,
maxCacheCount
:
DefaultMaxCacheCount
,
maxSyncErrCount
:
100
,
maxSyncErrCount
:
DefaultMaxSyncErrCount
,
isPrintDebugInfo
:
false
,
isPrintDebugInfo
:
false
,
}
}
if
subcfg
.
MaxCacheCount
>
0
{
if
subcfg
.
MaxCacheCount
>
0
{
...
...
plugin/consensus/para/parasync.go
View file @
14ddd950
...
@@ -15,6 +15,13 @@ import (
...
@@ -15,6 +15,13 @@ import (
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
)
)
const
(
//DefaultMaxCacheCount 默认local最大缓冲数
DefaultMaxCacheCount
=
int64
(
1000
)
//DefaultMaxSyncErrCount 默认连续错误最大数量
DefaultMaxSyncErrCount
=
int32
(
100
)
)
//BlockSyncClient 区块同步控制和状态变量
//BlockSyncClient 区块同步控制和状态变量
type
BlockSyncClient
struct
{
type
BlockSyncClient
struct
{
paraClient
*
client
paraClient
*
client
...
@@ -298,6 +305,11 @@ func (client *BlockSyncClient) getFirstLocalHeight() (int64, error) {
...
@@ -298,6 +305,11 @@ func (client *BlockSyncClient) getFirstLocalHeight() (int64, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
-
1
,
err
return
-
1
,
err
}
}
if
len
(
value
)
==
0
{
return
-
1
,
types
.
ErrNotFound
}
if
value
[
0
]
==
nil
{
if
value
[
0
]
==
nil
{
return
-
1
,
types
.
ErrNotFound
return
-
1
,
types
.
ErrNotFound
}
}
...
@@ -403,6 +415,10 @@ func (client *BlockSyncClient) rollbackBlock(block *types.Block) error {
...
@@ -403,6 +415,10 @@ func (client *BlockSyncClient) rollbackBlock(block *types.Block) error {
}
}
blocks
:=
resp
.
GetData
()
.
(
*
types
.
BlockDetails
)
blocks
:=
resp
.
GetData
()
.
(
*
types
.
BlockDetails
)
if
len
(
blocks
.
Items
)
==
0
{
return
errors
.
New
(
"para sync -blocks Items len = 0 "
)
}
parablockDetail
:=
&
types
.
ParaChainBlockDetail
{
Blockdetail
:
blocks
.
Items
[
0
]}
parablockDetail
:=
&
types
.
ParaChainBlockDetail
{
Blockdetail
:
blocks
.
Items
[
0
]}
msg
=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventDelParaChainBlockDetail
,
parablockDetail
)
msg
=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventDelParaChainBlockDetail
,
parablockDetail
)
err
=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
err
=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
...
...
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