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
c071ed4d
Commit
c071ed4d
authored
Jan 17, 2019
by
mdj33
Committed by
vipwzw
Jan 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust fork height init
parent
4440a138
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
10 deletions
+16
-10
para.go
plugin/consensus/para/para.go
+14
-10
paracommitmsg_test.go
plugin/consensus/para/paracommitmsg_test.go
+1
-0
paratxrequest_test.go
plugin/consensus/para/paratxrequest_test.go
+1
-0
No files found.
plugin/consensus/para/para.go
View file @
c071ed4d
...
...
@@ -47,8 +47,9 @@ var (
zeroHash
[
32
]
byte
grpcRecSize
=
30
*
1024
*
1024
//the size should be limited in server
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
minerPrivateKey
=
"6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
searchHashMatchDepth
int32
=
100
minerPrivateKey
=
"6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
searchHashMatchDepth
int32
=
100
mainBlockHashForkHeight
int64
=
types
.
MaxHeight
//calc block hash fork height in main chain
)
func
init
()
{
...
...
@@ -203,6 +204,14 @@ func (client *client) GetStartSeq(height int64) int64 {
if
height
==
0
{
return
0
}
ret
,
err
:=
client
.
grpcClient
.
GetFork
(
context
.
Background
(),
&
types
.
ReqKey
{
Key
:
[]
byte
(
"ForkBlockHash"
)})
if
err
!=
nil
{
plog
.
Error
(
"para get rpc ForkBlockHash fail"
,
"err"
,
err
.
Error
())
panic
(
err
)
}
mainBlockHashForkHeight
=
ret
.
Data
lastHeight
,
err
:=
client
.
GetLastHeightOnMainChain
()
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -422,15 +431,10 @@ func (client *client) GetBlockOnMainBySeq(seq int64) (*types.BlockSeq, error) {
return
nil
,
err
}
height
,
err
:=
client
.
grpcClient
.
GetFork
(
context
.
Background
(),
&
types
.
ReqKey
{
Key
:
[]
byte
(
"ForkBlockHash"
)})
if
err
!=
nil
{
plog
.
Error
(
"para get rpc ForkBlockHash fail"
,
"err"
,
err
.
Error
())
return
nil
,
err
}
hash
:=
blockSeq
.
Detail
.
Block
.
HashByForkHeight
(
height
.
Data
)
hash
:=
blockSeq
.
Detail
.
Block
.
HashByForkHeight
(
mainBlockHashForkHeight
)
if
!
bytes
.
Equal
(
blockSeq
.
Seq
.
Hash
,
hash
)
{
plog
.
Error
(
"para compare ForkBlockHash fail"
,
"
height"
,
height
,
"seqHash"
,
common
.
Bytes2Hex
(
blockSeq
.
Seq
.
Hash
)
,
"calcHash"
,
common
.
Bytes2Hex
(
hash
))
plog
.
Error
(
"para compare ForkBlockHash fail"
,
"
forkHeight"
,
mainBlockHashForkHeight
,
"
seqHash"
,
common
.
Bytes2Hex
(
blockSeq
.
Seq
.
Hash
),
"
calcHash"
,
common
.
Bytes2Hex
(
hash
))
return
nil
,
types
.
ErrBlockHashNoMatch
}
...
...
plugin/consensus/para/paracommitmsg_test.go
View file @
c071ed4d
...
...
@@ -75,6 +75,7 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
s
.
para
=
New
(
cfg
.
Consensus
,
sub
.
Consensus
[
"para"
])
.
(
*
client
)
s
.
grpcCli
=
&
typesmocks
.
Chain33Client
{}
s
.
grpcCli
.
On
(
"GetFork"
,
mock
.
Anything
,
&
types
.
ReqKey
{
Key
:
[]
byte
(
"ForkBlockHash"
)})
.
Return
(
&
types
.
Int64
{
Data
:
1
},
nil
)
// GetBlockBySeq return error to stop create's for cycle to request tx
s
.
grpcCli
.
On
(
"GetBlockBySeq"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
nil
,
errors
.
New
(
"quit create"
))
//data := &types.Int64{1}
...
...
plugin/consensus/para/paratxrequest_test.go
View file @
c071ed4d
...
...
@@ -66,6 +66,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
s
.
para
=
New
(
cfg
.
Consensus
,
sub
.
Consensus
[
"para"
])
.
(
*
client
)
s
.
grpcCli
=
&
typesmocks
.
Chain33Client
{}
s
.
grpcCli
.
On
(
"GetFork"
,
mock
.
Anything
,
&
types
.
ReqKey
{
Key
:
[]
byte
(
"ForkBlockHash"
)})
.
Return
(
&
types
.
Int64
{
Data
:
1
},
nil
)
s
.
createBlockMock
()
reply
:=
&
types
.
Reply
{
IsOk
:
true
}
...
...
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