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
a880415d
Commit
a880415d
authored
Jul 16, 2019
by
mdj33
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix last block main parent block hash
parent
f6843e35
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
16 deletions
+22
-16
para.go
plugin/consensus/para/para.go
+3
-3
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+12
-12
paracreate.go
plugin/consensus/para/paracreate.go
+7
-1
No files found.
plugin/consensus/para/para.go
View file @
a880415d
...
...
@@ -309,7 +309,7 @@ func (client *client) removeBlocks(endHeight int64) error {
return
err
}
err
=
client
.
DelBlock
(
lastBlock
,
blockedSeq
)
err
=
client
.
DelBlock
(
lastBlock
.
Height
,
blockedSeq
)
if
err
!=
nil
{
plog
.
Error
(
"Parachain GetBlockedSeq fail"
,
"err"
,
err
)
return
err
...
...
@@ -410,9 +410,9 @@ func (client *client) WriteBlock(prev []byte, paraBlock *types.Block, seq int64)
}
// 向blockchain删区块
func
(
client
*
client
)
DelBlock
(
block
*
types
.
Block
,
seq
int64
)
error
{
func
(
client
*
client
)
DelBlock
(
start
,
seq
int64
)
error
{
plog
.
Debug
(
"delete block in parachain"
)
start
:=
block
.
Height
//
start := block.Height
if
start
==
0
{
panic
(
"Parachain attempt to Delete GenesisBlock !"
)
}
...
...
plugin/consensus/para/paracommitmsg.go
View file @
a880415d
...
...
@@ -67,18 +67,18 @@ func (client *commitMsgClient) handler() {
out
:
for
{
select
{
//正常
的触发检查
//正常
commit 入口
case
<-
client
.
commitCh
:
//回滚场景
if
atomic
.
LoadInt64
(
&
client
.
chainHeight
)
<
client
.
sendingHeight
{
client
.
clearSendingTx
()
}
client
.
procSendTx
()
//
发送出错场景
,需要reset 重发
//
出错场景入口
,需要reset 重发
case
<-
client
.
resetCh
:
client
.
clearSendingTx
()
client
.
procSendTx
()
//例行检查发送
//例行检查发送
入口
case
<-
readTick
:
consensStopTimes
=
client
.
checkConsensusStop
(
consensStopTimes
)
client
.
procSendTx
()
...
...
@@ -104,9 +104,9 @@ func (client *commitMsgClient) clearSendingTx() {
}
func
(
client
*
commitMsgClient
)
procSendTx
()
{
plog
.
Info
(
"para
procSendTx ---send"
,
"consensHeight"
,
atomic
.
LoadInt64
(
&
client
.
consensHeight
)
,
"c
hainHeight"
,
atomic
.
LoadInt64
(
&
client
.
chainHeight
),
"sendingHeight"
,
client
.
sendingHeight
,
"isSendingTx"
,
client
.
isSendingCommitMsg
(),
"sync"
,
client
.
isSync
())
plog
.
Info
(
"para
commitMsg---send"
,
"chainHeight"
,
atomic
.
LoadInt64
(
&
client
.
chainHeight
),
"sendingHeight"
,
client
.
sendingHeight
,
"c
onsensHeight"
,
atomic
.
LoadInt64
(
&
client
.
consensHeight
),
"isSendingTx"
,
client
.
isSendingCommitMsg
(),
"sync"
,
client
.
isSync
())
if
client
.
isSendingCommitMsg
()
||
!
client
.
isSync
()
{
return
}
...
...
@@ -124,7 +124,7 @@ func (client *commitMsgClient) procSendTx() {
}
//已发送,未共识场景
if
client
.
sendingHeight
>
-
1
&&
client
.
sendingHeight
>
consensHeight
{
if
client
.
sendingHeight
>
consensHeight
{
return
}
...
...
@@ -135,7 +135,7 @@ func (client *commitMsgClient) procSendTx() {
}
client
.
sendingHeight
=
client
.
sendingHeight
+
count
client
.
setCurrentTx
(
signTx
)
client
.
checkTxCommitTimes
=
0
atomic
.
StoreInt32
(
&
client
.
checkTxCommitTimes
,
0
)
client
.
sendMsgCh
<-
signTx
}
...
...
@@ -144,23 +144,23 @@ func (client *commitMsgClient) procSendTx() {
func
(
client
*
commitMsgClient
)
isSync
()
bool
{
height
:=
atomic
.
LoadInt64
(
&
client
.
chainHeight
)
if
height
<=
0
{
plog
.
Info
(
"para isSync"
,
"chainHeight"
,
height
)
plog
.
Info
(
"para is
not
Sync"
,
"chainHeight"
,
height
)
return
false
}
height
=
atomic
.
LoadInt64
(
&
client
.
consensHeight
)
if
height
==
-
2
{
plog
.
Info
(
"para isSync"
,
"consensHeight"
,
height
)
plog
.
Info
(
"para is
not
Sync"
,
"consensHeight"
,
height
)
return
false
}
if
atomic
.
LoadInt32
(
&
client
.
authAccountIn
)
!=
1
{
plog
.
Info
(
"para is
Sync
"
,
"authAccountIn"
,
atomic
.
LoadInt32
(
&
client
.
authAccountIn
))
plog
.
Info
(
"para is
not Sync
"
,
"authAccountIn"
,
atomic
.
LoadInt32
(
&
client
.
authAccountIn
))
return
false
}
if
atomic
.
LoadInt32
(
&
client
.
minerSwitch
)
!=
1
{
plog
.
Info
(
"para is
Sync
"
,
"minerSwitch"
,
atomic
.
LoadInt32
(
&
client
.
minerSwitch
))
plog
.
Info
(
"para is
not Sync
"
,
"minerSwitch"
,
atomic
.
LoadInt32
(
&
client
.
minerSwitch
))
return
false
}
...
...
plugin/consensus/para/paracreate.go
View file @
a880415d
...
...
@@ -98,7 +98,7 @@ func (client *client) createLocalBlock(lastBlock *pt.ParaLocalDbBlock, txs []*ty
newblock
.
Height
=
lastBlock
.
Height
+
1
newblock
.
MainHash
=
mainBlock
.
Seq
.
Hash
newblock
.
MainHeight
=
mainBlock
.
Detail
.
Block
.
Height
newblock
.
ParentMainHash
=
mainBlock
.
Detail
.
Block
.
Parent
Hash
newblock
.
ParentMainHash
=
lastBlock
.
Main
Hash
newblock
.
BlockTime
=
mainBlock
.
Detail
.
Block
.
BlockTime
newblock
.
Txs
=
txs
...
...
@@ -351,6 +351,11 @@ func (client *client) switchLocalHashMatchedBlock() (int64, []byte, error) {
return
-
2
,
nil
,
err
}
//err = client.removeBlocks(height)
//if err != nil {
// return -2, nil, err
//}
plog
.
Info
(
"switchLocalHashMatchedBlock succ"
,
"currHeight"
,
height
,
"initHeight"
,
lastBlock
.
Height
,
"currSeq"
,
mainSeq
,
"currMainBlockHash"
,
hex
.
EncodeToString
(
block
.
MainHash
))
return
mainSeq
,
block
.
MainHash
,
nil
...
...
@@ -453,6 +458,7 @@ func (client *client) CreateBlock() {
plog
.
Info
(
"Delete empty block"
)
}
err
=
client
.
delLocalBlock
(
lastBlock
.
Height
)
//client.DelBlock(lastBlock.Height,0)
}
else
if
mainBlock
.
Seq
.
Type
==
addAct
{
if
len
(
txs
)
==
0
{
if
lastSeqMainHeight
-
lastBlock
.
MainHeight
<
emptyBlockInterval
{
...
...
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