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
71c5cb08
Commit
71c5cb08
authored
Apr 22, 2019
by
mdj33
Committed by
vipwzw
Apr 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix genesis block check
parent
6991d259
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
para.go
plugin/consensus/para/para.go
+7
-1
No files found.
plugin/consensus/para/para.go
View file @
71c5cb08
...
@@ -319,13 +319,19 @@ func (client *client) getLastBlockInfo() (int64, *types.Block, error) {
...
@@ -319,13 +319,19 @@ func (client *client) getLastBlockInfo() (int64, *types.Block, error) {
// 平行链创世区块特殊场景:
// 平行链创世区块特殊场景:
// 1,创世区块seq从-1开始,也就是从主链0高度同步区块,主链seq从0开始,平行链对seq=0的区块做特殊处理,不校验parentHash
// 1,创世区块seq从-1开始,也就是从主链0高度同步区块,主链seq从0开始,平行链对seq=0的区块做特殊处理,不校验parentHash
// 2,创世区块seq不是-1, 也就是从主链seq=n高度同步区块,此时创世区块倒退一个seq,blockedSeq=n-1,
// 2,创世区块seq不是-1, 也就是从主链seq=n高度同步区块,此时创世区块倒退一个seq,blockedSeq=n-1,
// 由于创世区块本身没有记录主块hash,需要
在此处
获取,有可能n-1 seq 是回退block 获取的Hash不对,这里获取主链第n seq的parentHash
// 由于创世区块本身没有记录主块hash,需要
通过最初记录的seq
获取,有可能n-1 seq 是回退block 获取的Hash不对,这里获取主链第n seq的parentHash
// 在genesis create时候直接设mainhash也可以,但是会导致已有平行链所有block hash变化
// 在genesis create时候直接设mainhash也可以,但是会导致已有平行链所有block hash变化
if
lastBlock
.
Height
==
0
&&
blockedSeq
>
-
1
{
if
lastBlock
.
Height
==
0
&&
blockedSeq
>
-
1
{
main
,
err
:=
client
.
GetBlockOnMainBySeq
(
blockedSeq
+
1
)
main
,
err
:=
client
.
GetBlockOnMainBySeq
(
blockedSeq
+
1
)
if
err
!=
nil
{
if
err
!=
nil
{
return
-
2
,
nil
,
err
return
-
2
,
nil
,
err
}
}
if
main
.
Detail
.
Block
.
Height
!=
startHeight
{
plog
.
Error
(
"get start seq's main block height not expected as config"
,
"config"
,
startHeight
,
"main"
,
main
.
Detail
.
Block
.
Height
)
//main chain node is not the initial node and the startHeight not match as config
panic
(
"main chain node is not the initial node, need switch main node or delete db"
)
}
lastBlock
.
MainHash
=
main
.
Detail
.
Block
.
ParentHash
lastBlock
.
MainHash
=
main
.
Detail
.
Block
.
ParentHash
lastBlock
.
MainHeight
=
main
.
Detail
.
Block
.
Height
-
1
lastBlock
.
MainHeight
=
main
.
Detail
.
Block
.
Height
-
1
return
blockedSeq
,
lastBlock
,
nil
return
blockedSeq
,
lastBlock
,
nil
...
...
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