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
a511b559
Commit
a511b559
authored
Dec 19, 2019
by
mdj33
Committed by
vipwzw
Dec 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust download strategy
parent
eb87ad16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
parajumpdownload.go
plugin/consensus/para/parajumpdownload.go
+0
-0
parajumpdownload_test.go
plugin/consensus/para/parajumpdownload_test.go
+5
-5
pararpc.go
plugin/consensus/para/pararpc.go
+12
-5
No files found.
plugin/consensus/para/parajumpdownload.go
View file @
a511b559
This diff is collapsed.
Click to expand it.
plugin/consensus/para/parajumpdownload_test.go
View file @
a511b559
...
@@ -27,7 +27,7 @@ func TestGetHeightsArry(t *testing.T) {
...
@@ -27,7 +27,7 @@ func TestGetHeightsArry(t *testing.T) {
heights
:=
[]
*
types
.
BlockInfo
{
h0
,
h1
,
h2
,
h3
,
h4
,
h5
,
h6
,
h7
,
h8
,
h9
}
heights
:=
[]
*
types
.
BlockInfo
{
h0
,
h1
,
h2
,
h3
,
h4
,
h5
,
h6
,
h7
,
h8
,
h9
}
hh
:=
getHeightsArry
(
heights
,
3
)
hh
:=
splitHeights2Rows
(
heights
,
3
)
h11
:=
[]
*
types
.
BlockInfo
{
h0
,
h1
,
h2
}
h11
:=
[]
*
types
.
BlockInfo
{
h0
,
h1
,
h2
}
h12
:=
[]
*
types
.
BlockInfo
{
h3
,
h4
,
h5
}
h12
:=
[]
*
types
.
BlockInfo
{
h3
,
h4
,
h5
}
h13
:=
[]
*
types
.
BlockInfo
{
h6
,
h7
,
h8
}
h13
:=
[]
*
types
.
BlockInfo
{
h6
,
h7
,
h8
}
...
@@ -35,19 +35,19 @@ func TestGetHeightsArry(t *testing.T) {
...
@@ -35,19 +35,19 @@ func TestGetHeightsArry(t *testing.T) {
expect
:=
[][]
*
types
.
BlockInfo
{
h11
,
h12
,
h13
,
h14
}
expect
:=
[][]
*
types
.
BlockInfo
{
h11
,
h12
,
h13
,
h14
}
assert
.
Equal
(
t
,
expect
,
hh
)
assert
.
Equal
(
t
,
expect
,
hh
)
s
,
e
:=
get
StartEndHeight
(
0
,
100
,
hh
,
0
)
s
,
e
:=
get
HeaderStartEndRange
(
0
,
100
,
hh
,
0
)
assert
.
Equal
(
t
,
int64
(
0
),
s
)
assert
.
Equal
(
t
,
int64
(
0
),
s
)
assert
.
Equal
(
t
,
h2
.
Height
,
e
)
assert
.
Equal
(
t
,
h2
.
Height
,
e
)
s
,
e
=
get
StartEndHeight
(
0
,
100
,
hh
,
1
)
s
,
e
=
get
HeaderStartEndRange
(
0
,
100
,
hh
,
1
)
assert
.
Equal
(
t
,
h2
.
Height
+
1
,
s
)
assert
.
Equal
(
t
,
h2
.
Height
+
1
,
s
)
assert
.
Equal
(
t
,
h5
.
Height
,
e
)
assert
.
Equal
(
t
,
h5
.
Height
,
e
)
s
,
e
=
get
StartEndHeight
(
0
,
100
,
hh
,
2
)
s
,
e
=
get
HeaderStartEndRange
(
0
,
100
,
hh
,
2
)
assert
.
Equal
(
t
,
h5
.
Height
+
1
,
s
)
assert
.
Equal
(
t
,
h5
.
Height
+
1
,
s
)
assert
.
Equal
(
t
,
h8
.
Height
,
e
)
assert
.
Equal
(
t
,
h8
.
Height
,
e
)
s
,
e
=
get
StartEndHeight
(
0
,
100
,
hh
,
3
)
s
,
e
=
get
HeaderStartEndRange
(
0
,
100
,
hh
,
3
)
assert
.
Equal
(
t
,
h8
.
Height
+
1
,
s
)
assert
.
Equal
(
t
,
h8
.
Height
+
1
,
s
)
assert
.
Equal
(
t
,
int64
(
100
),
e
)
assert
.
Equal
(
t
,
int64
(
100
),
e
)
}
}
...
...
plugin/consensus/para/pararpc.go
View file @
a511b559
...
@@ -17,11 +17,11 @@ func (client *client) GetBlockByHeight(height int64) (*types.Block, error) {
...
@@ -17,11 +17,11 @@ func (client *client) GetBlockByHeight(height int64) (*types.Block, error) {
//from blockchain db
//from blockchain db
blockDetails
,
err
:=
client
.
GetAPI
()
.
GetBlocks
(
&
types
.
ReqBlocks
{
Start
:
height
,
End
:
height
})
blockDetails
,
err
:=
client
.
GetAPI
()
.
GetBlocks
(
&
types
.
ReqBlocks
{
Start
:
height
,
End
:
height
})
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"
paracommitmsg get node status block count fail"
)
plog
.
Error
(
"
GetBlockByHeight fail"
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
if
1
!=
int64
(
len
(
blockDetails
.
Items
))
{
if
1
!=
int64
(
len
(
blockDetails
.
Items
))
{
plog
.
Error
(
"
paracommitmsg get node status block count fail"
)
plog
.
Error
(
"
GetBlockByHeight count fail"
,
"len"
,
len
(
blockDetails
.
Items
)
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
return
blockDetails
.
Items
[
0
]
.
Block
,
nil
return
blockDetails
.
Items
[
0
]
.
Block
,
nil
...
@@ -31,9 +31,16 @@ func (client *client) GetBlockHeaders(req *types.ReqBlocks) (*types.Headers, err
...
@@ -31,9 +31,16 @@ func (client *client) GetBlockHeaders(req *types.ReqBlocks) (*types.Headers, err
//from blockchain db
//from blockchain db
headers
,
err
:=
client
.
grpcClient
.
GetHeaders
(
context
.
Background
(),
req
)
headers
,
err
:=
client
.
grpcClient
.
GetHeaders
(
context
.
Background
(),
req
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"
paracommitmsg get node status block count fail"
)
plog
.
Error
(
"
GetBlockHeaders fail"
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
count
:=
req
.
End
-
req
.
Start
+
1
if
int64
(
len
(
headers
.
Items
))
!=
count
{
plog
.
Error
(
"GetBlockHeaders"
,
"start"
,
req
.
Start
,
"end"
,
req
.
End
,
"reals"
,
headers
.
Items
[
0
]
.
Height
,
"reale"
,
headers
.
Items
[
len
(
headers
.
Items
)
-
1
]
.
Height
,
"len"
,
len
(
headers
.
Items
),
"count"
,
count
)
return
nil
,
types
.
ErrBlockHeightNoMatch
}
return
headers
,
nil
return
headers
,
nil
}
}
...
@@ -55,7 +62,7 @@ func (client *client) getLastBlockMainInfo() (int64, *types.Block, error) {
...
@@ -55,7 +62,7 @@ func (client *client) getLastBlockMainInfo() (int64, *types.Block, error) {
func
(
client
*
client
)
getLastBlockInfo
()
(
*
types
.
Block
,
error
)
{
func
(
client
*
client
)
getLastBlockInfo
()
(
*
types
.
Block
,
error
)
{
lastBlock
,
err
:=
client
.
RequestLastBlock
()
lastBlock
,
err
:=
client
.
RequestLastBlock
()
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"Parachain
RequestLastBlock
fail"
,
"err"
,
err
)
plog
.
Error
(
"Parachain
getLastBlockInfo
fail"
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
@@ -141,7 +148,7 @@ func (client *client) GetParaHeightsByTitle(req *types.ReqHeightByTitle) (*types
...
@@ -141,7 +148,7 @@ func (client *client) GetParaHeightsByTitle(req *types.ReqHeightByTitle) (*types
//from blockchain db
//from blockchain db
heights
,
err
:=
client
.
grpcClient
.
LoadParaTxByTitle
(
context
.
Background
(),
req
)
heights
,
err
:=
client
.
grpcClient
.
LoadParaTxByTitle
(
context
.
Background
(),
req
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"
paracommitmsg get node status block count fail"
)
plog
.
Error
(
"
GetParaHeightsByTitle fail"
,
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
...
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