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
1ebeedb2
Commit
1ebeedb2
authored
Aug 09, 2019
by
yukang
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct code style
parent
83fa966c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
parasync.go
plugin/consensus/para/parasync.go
+19
-18
No files found.
plugin/consensus/para/parasync.go
View file @
1ebeedb2
...
...
@@ -370,8 +370,6 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
//添加一个区块
func
(
client
*
blockSyncClient
)
addBlock
(
lastBlock
*
types
.
Block
,
localBlock
*
pt
.
ParaLocalDbBlock
)
error
{
var
newBlock
types
.
Block
client
.
printDebugInfo
(
fmt
.
Sprintf
(
"Para sync - the len txs is: %v"
,
len
(
localBlock
.
Txs
)))
newBlock
.
ParentHash
=
lastBlock
.
Hash
()
newBlock
.
Height
=
lastBlock
.
Height
+
1
newBlock
.
Txs
=
localBlock
.
Txs
...
...
@@ -388,7 +386,8 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
err
=
client
.
writeBlock
(
lastBlock
.
StateHash
,
&
newBlock
)
client
.
printDebugInfo
(
"Para sync - para create new Block"
,
"newblock.ParentHash"
,
common
.
ToHex
(
newBlock
.
ParentHash
),
client
.
printDebugInfo
(
"Para sync - create new Block"
,
"newblock.ParentHash"
,
common
.
ToHex
(
newBlock
.
ParentHash
),
"newblock.Height"
,
newBlock
.
Height
,
"newblock.TxHash"
,
common
.
ToHex
(
newBlock
.
TxHash
),
"newblock.BlockTime"
,
newBlock
.
BlockTime
)
...
...
@@ -397,34 +396,35 @@ func (client *blockSyncClient) addBlock(lastBlock *types.Block, localBlock *pt.P
// 向blockchain删区块
func
(
client
*
blockSyncClient
)
rollbackBlock
(
block
*
types
.
Block
)
error
{
client
.
printDebugInfo
(
"Para sync - delete block in parachain"
)
start
:=
block
.
Height
if
start
=
=
0
{
panic
(
"Para sync - Parachain attempt to Delete GenesisBlock !
"
)
if
start
<
=
0
{
return
errors
.
New
(
"para sync - attempt to rollbackBlock genesisBlock
"
)
}
msg
:=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventGetBlocks
,
&
types
.
ReqBlocks
{
Start
:
start
,
End
:
start
,
IsDetail
:
true
,
Pid
:
[]
string
{
""
}})
reqBlocks
:=
&
types
.
ReqBlocks
{
Start
:
start
,
End
:
start
,
IsDetail
:
true
,
Pid
:
[]
string
{
""
}}
msg
:=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventGetBlocks
,
reqBlocks
)
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
if
err
!=
nil
{
return
err
}
resp
,
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Wait
(
msg
)
if
err
!=
nil
{
return
err
}
blocks
:=
resp
.
GetData
()
.
(
*
types
.
BlockDetails
)
blocks
:=
resp
.
GetData
()
.
(
*
types
.
BlockDetails
)
if
len
(
blocks
.
Items
)
==
0
{
return
errors
.
New
(
"para sync -blocks Items len = 0 "
)
}
para
b
lockDetail
:=
&
types
.
ParaChainBlockDetail
{
Blockdetail
:
blocks
.
Items
[
0
]}
msg
=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventDelParaChainBlockDetail
,
para
b
lockDetail
)
para
B
lockDetail
:=
&
types
.
ParaChainBlockDetail
{
Blockdetail
:
blocks
.
Items
[
0
]}
msg
=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventDelParaChainBlockDetail
,
para
B
lockDetail
)
err
=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
if
err
!=
nil
{
return
err
}
resp
,
err
=
client
.
paraClient
.
GetQueueClient
()
.
Wait
(
msg
)
if
err
!=
nil
{
return
err
...
...
@@ -442,23 +442,24 @@ func (client *blockSyncClient) rollbackBlock(block *types.Block) error {
func
(
client
*
blockSyncClient
)
writeBlock
(
prev
[]
byte
,
paraBlock
*
types
.
Block
)
error
{
//共识模块不执行block,统一由blockchain模块执行block并做去重的处理,返回执行后的blockdetail
blockDetail
:=
&
types
.
BlockDetail
{
Block
:
paraBlock
}
parablockDetail
:=
&
types
.
ParaChainBlockDetail
{
Blockdetail
:
blockDetail
}
msg
:=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventAddParaChainBlockDetail
,
parablockDetail
)
paraBlockDetail
:=
&
types
.
ParaChainBlockDetail
{
Blockdetail
:
blockDetail
}
msg
:=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"blockchain"
,
types
.
EventAddParaChainBlockDetail
,
paraBlockDetail
)
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
if
err
!=
nil
{
return
err
}
resp
,
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Wait
(
msg
)
if
err
!=
nil
{
return
err
}
blkdetail
:=
resp
.
GetData
()
.
(
*
types
.
BlockDetail
)
if
blkdetail
==
nil
{
return
errors
.
New
(
"Para sync - block detail is nil"
)
respBlockDetail
:=
resp
.
GetData
()
.
(
*
types
.
BlockDetail
)
if
respBlockDetail
==
nil
{
return
errors
.
New
(
"para sync - block detail is nil"
)
}
client
.
paraClient
.
SetCurrentBlock
(
blkd
etail
.
Block
)
client
.
paraClient
.
SetCurrentBlock
(
respBlockD
etail
.
Block
)
return
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