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
02443aa3
Commit
02443aa3
authored
Jul 13, 2019
by
mdj33
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust commit msg
parent
4d9a73bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
26 deletions
+45
-26
para.go
plugin/consensus/para/para.go
+6
-6
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+0
-0
paracreate.go
plugin/consensus/para/paracreate.go
+38
-19
action.go
plugin/dapp/paracross/executor/action.go
+1
-1
No files found.
plugin/consensus/para/para.go
View file @
02443aa3
...
...
@@ -163,10 +163,9 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
paraClient
:
para
,
waitMainBlocks
:
waitBlocks
,
waitConsensStopTimes
:
waitConsensTimes
,
commitMsgNotify
:
make
(
chan
int64
,
1
),
delMsgNotify
:
make
(
chan
int64
,
1
),
mainBlockAdd
:
make
(
chan
*
types
.
BlockDetail
,
1
),
minerSwitch
:
make
(
chan
bool
,
1
),
commitNotify
:
make
(
chan
int64
,
1
),
resetNotify
:
make
(
chan
int64
,
1
),
chainHeight
:
-
1
,
quit
:
make
(
chan
struct
{}),
}
c
.
SetChild
(
para
)
...
...
@@ -393,7 +392,7 @@ func (client *client) WriteBlock(prev []byte, paraBlock *types.Block, seq int64)
client
.
SetCurrentBlock
(
blkdetail
.
Block
)
if
client
.
authAccount
!=
""
{
client
.
commitMsgClient
.
onBlockAdded
(
blkdetail
.
Block
.
Height
)
client
.
commitMsgClient
.
updateChainHeight
(
blockDetail
.
Block
.
Height
,
false
)
}
return
nil
...
...
@@ -430,7 +429,8 @@ func (client *client) DelBlock(block *types.Block, seq int64) error {
if
resp
.
GetData
()
.
(
*
types
.
Reply
)
.
IsOk
{
if
client
.
authAccount
!=
""
{
client
.
commitMsgClient
.
onBlockDeleted
(
blocks
.
Items
[
0
]
.
Block
.
Height
)
client
.
commitMsgClient
.
updateChainHeight
(
blocks
.
Items
[
0
]
.
Block
.
Height
,
true
)
}
}
else
{
reply
:=
resp
.
GetData
()
.
(
*
types
.
Reply
)
...
...
plugin/consensus/para/paracommitmsg.go
View file @
02443aa3
This diff is collapsed.
Click to expand it.
plugin/consensus/para/paracreate.go
View file @
02443aa3
...
...
@@ -15,7 +15,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
paraexec
"github.com/33cn/plugin/plugin/dapp/paracross/executor"
p
aracross
"github.com/33cn/plugin/plugin/dapp/paracross/types"
p
t
"github.com/33cn/plugin/plugin/dapp/paracross/types"
)
func
(
client
*
client
)
setLocalDb
(
set
*
types
.
LocalDBSet
)
error
{
...
...
@@ -59,7 +59,7 @@ func (client *client) getLocalDb(set *types.LocalDBGet, count int) ([][]byte, er
return
reply
.
Values
,
nil
}
func
(
client
*
client
)
addLocalBlock
(
height
int64
,
block
*
p
aracross
.
ParaLocalDbBlock
)
error
{
func
(
client
*
client
)
addLocalBlock
(
height
int64
,
block
*
p
t
.
ParaLocalDbBlock
)
error
{
set
:=
&
types
.
LocalDBSet
{}
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
...
...
@@ -74,8 +74,26 @@ func (client *client) addLocalBlock(height int64, block *paracross.ParaLocalDbBl
return
client
.
setLocalDb
(
set
)
}
func
(
client
*
client
)
createLocalBlock
(
lastBlock
*
paracross
.
ParaLocalDbBlock
,
txs
[]
*
types
.
Transaction
,
mainBlock
*
types
.
BlockSeq
)
error
{
var
newblock
paracross
.
ParaLocalDbBlock
func
(
client
*
client
)
checkTxInMainBlock
(
detail
*
types
.
BlockDetail
)
{
if
!
client
.
isCaughtUp
{
return
}
txMap
:=
make
(
map
[
string
]
bool
)
for
i
,
tx
:=
range
detail
.
Block
.
Txs
{
if
bytes
.
HasSuffix
(
tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
&&
detail
.
Receipts
[
i
]
.
Ty
==
types
.
ExecOk
{
txMap
[
string
(
tx
.
Hash
())]
=
true
}
}
//return txMap[string(targetTx.Hash())]
client
.
commitMsgClient
.
checkSendingTxDone
(
txMap
)
}
func
(
client
*
client
)
createLocalBlock
(
lastBlock
*
pt
.
ParaLocalDbBlock
,
txs
[]
*
types
.
Transaction
,
mainBlock
*
types
.
BlockSeq
)
error
{
var
newblock
pt
.
ParaLocalDbBlock
newblock
.
Height
=
lastBlock
.
Height
+
1
newblock
.
MainHash
=
mainBlock
.
Seq
.
Hash
...
...
@@ -85,7 +103,12 @@ func (client *client) createLocalBlock(lastBlock *paracross.ParaLocalDbBlock, tx
newblock
.
Txs
=
txs
return
client
.
addLocalBlock
(
newblock
.
Height
,
&
newblock
)
err
:=
client
.
addLocalBlock
(
newblock
.
Height
,
&
newblock
)
if
err
!=
nil
{
return
err
}
client
.
checkTxInMainBlock
(
mainBlock
.
Detail
)
return
nil
}
func
(
client
*
client
)
createLocalGenesisBlock
(
genesis
*
types
.
Block
)
error
{
...
...
@@ -137,7 +160,7 @@ func (client *client) getLastLocalHeight() (int64, error) {
}
func
(
client
*
client
)
getLocalBlockByHeight
(
height
int64
)
(
*
p
aracross
.
ParaLocalDbBlock
,
error
)
{
func
(
client
*
client
)
getLocalBlockByHeight
(
height
int64
)
(
*
p
t
.
ParaLocalDbBlock
,
error
)
{
key
:=
calcTitleHeightKey
(
types
.
GetTitle
(),
height
)
set
:=
&
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
...
...
@@ -149,7 +172,7 @@ func (client *client) getLocalBlockByHeight(height int64) (*paracross.ParaLocalD
return
nil
,
types
.
ErrNotFound
}
var
block
p
aracross
.
ParaLocalDbBlock
var
block
p
t
.
ParaLocalDbBlock
err
=
types
.
Decode
(
value
[
0
],
&
block
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -175,7 +198,7 @@ func (client *client) getLocalBlockSeq(height int64) (int64, []byte, error) {
//根据匹配上的chainblock,设置当前localdb block
func
(
client
*
client
)
alignLocalBlock2ChainBlock
(
chainBlock
*
types
.
Block
)
error
{
localBlock
:=
&
p
aracross
.
ParaLocalDbBlock
{
localBlock
:=
&
p
t
.
ParaLocalDbBlock
{
Height
:
chainBlock
.
Height
,
MainHeight
:
chainBlock
.
MainHeight
,
MainHash
:
chainBlock
.
MainHash
,
...
...
@@ -211,7 +234,7 @@ func (client *client) getLastLocalBlockSeq() (int64, []byte, error) {
}
func
(
client
*
client
)
getLastLocalBlock
()
(
*
p
aracross
.
ParaLocalDbBlock
,
error
)
{
func
(
client
*
client
)
getLastLocalBlock
()
(
*
p
t
.
ParaLocalDbBlock
,
error
)
{
height
,
err
:=
client
.
getLastLocalHeight
()
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -277,7 +300,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B
"new currSeq"
,
mainSeq
,
"new preMainBlockHash"
,
hex
.
EncodeToString
(
block
.
MainHash
))
return
mainSeq
,
block
,
nil
}
return
-
2
,
nil
,
p
aracross
.
ErrParaCurHashNotMatch
return
-
2
,
nil
,
p
t
.
ErrParaCurHashNotMatch
}
func
(
client
*
client
)
switchMatchedBlockOnChain
(
startHeight
int64
)
(
int64
,
[]
byte
,
error
)
{
...
...
@@ -331,7 +354,7 @@ func (client *client) switchLocalHashMatchedBlock() (int64, []byte, error) {
"currSeq"
,
mainSeq
,
"currMainBlockHash"
,
hex
.
EncodeToString
(
block
.
MainHash
))
return
mainSeq
,
block
.
MainHash
,
nil
}
return
-
2
,
nil
,
p
aracross
.
ErrParaCurHashNotMatch
return
-
2
,
nil
,
p
t
.
ErrParaCurHashNotMatch
}
// preBlockHash to identify the same main node
...
...
@@ -362,27 +385,23 @@ func (client *client) RequestTx(currSeq int64, preMainBlockHash []byte) ([]*type
}
client
.
mtx
.
Unlock
()
if
client
.
authAccount
!=
""
{
client
.
commitMsgClient
.
onMainBlockAdded
(
blockSeq
.
Detail
)
}
return
txs
,
blockSeq
,
nil
}
//not consistent case be processed at below
plog
.
Error
(
"RequestTx"
,
"preMainHash"
,
hex
.
EncodeToString
(
preMainBlockHash
),
"currSeq preMainHash"
,
hex
.
EncodeToString
(
blockSeq
.
Detail
.
Block
.
ParentHash
),
"currSeq mainHash"
,
hex
.
EncodeToString
(
blockSeq
.
Seq
.
Hash
),
"curr seq"
,
currSeq
,
"ty"
,
blockSeq
.
Seq
.
Type
,
"currSeq Mainheight"
,
blockSeq
.
Detail
.
Block
.
Height
)
return
nil
,
nil
,
p
aracross
.
ErrParaCurHashNotMatch
return
nil
,
nil
,
p
t
.
ErrParaCurHashNotMatch
}
//lastSeq < CurrSeq case:
//lastSeq = currSeq-1, main node not update
if
lastSeq
+
1
==
currSeq
{
plog
.
Debug
(
"Waiting new sequence from main chain"
)
return
nil
,
nil
,
p
aracross
.
ErrParaWaitingNewSeq
return
nil
,
nil
,
p
t
.
ErrParaWaitingNewSeq
}
// 1. lastSeq < currSeq-1
// 2. lastSeq >= currSeq and seq not consistent or fork case
return
nil
,
nil
,
p
aracross
.
ErrParaCurHashNotMatch
return
nil
,
nil
,
p
t
.
ErrParaCurHashNotMatch
}
func
(
client
*
client
)
CreateBlock
()
{
...
...
@@ -395,7 +414,7 @@ func (client *client) CreateBlock() {
for
{
txs
,
mainBlock
,
err
:=
client
.
RequestTx
(
currSeq
,
lastSeqMainHash
)
if
err
!=
nil
{
if
err
==
p
aracross
.
ErrParaCurHashNotMatch
{
if
err
==
p
t
.
ErrParaCurHashNotMatch
{
preSeq
,
preSeqMainHash
,
err
:=
client
.
switchHashMatchedBlock
()
if
err
==
nil
{
currSeq
=
preSeq
+
1
...
...
plugin/dapp/paracross/executor/action.go
View file @
02443aa3
...
...
@@ -534,7 +534,7 @@ func (a *action) commitTxDoneStep2(nodeStatus *pt.ParacrossNodeStatus, stat *pt.
if
!
bytes
.
Equal
(
selfBlockHash
.
Hash
,
nodeStatus
.
BlockHash
)
{
clog
.
Error
(
"paracross.CommitDone mosthash not match"
,
"height"
,
nodeStatus
.
Height
,
"blockHash"
,
hex
.
EncodeToString
(
selfBlockHash
.
Hash
),
"mosthash"
,
hex
.
EncodeToString
(
nodeStatus
.
BlockHash
))
return
nil
,
pt
.
ErrParaCurHashNotMatch
return
nil
,
types
.
ErrConsensusHashErr
}
//平行连进行奖励分配
...
...
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