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
1b62e231
Commit
1b62e231
authored
Aug 05, 2019
by
mdj33
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add local height query
parent
017bcf9e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
98 additions
and
0 deletions
+98
-0
chain33.para.toml
chain33.para.toml
+2
-0
para.go
plugin/consensus/para/para.go
+36
-0
parasync_test.go
plugin/consensus/para/parasync_test.go
+1
-0
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+1
-0
paracross.go
plugin/dapp/paracross/commands/paracross.go
+31
-0
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+8
-0
rpc.go
plugin/dapp/paracross/rpc/rpc.go
+19
-0
No files found.
chain33.para.toml
View file @
1b62e231
...
@@ -115,6 +115,8 @@ MainForkParacrossCommitTx=2270000
...
@@ -115,6 +115,8 @@ MainForkParacrossCommitTx=2270000
MainParaSelfConsensusForkHeight
=
-1
MainParaSelfConsensusForkHeight
=
-1
#主链开启循环检查共识交易done的fork高度
#主链开启循环检查共识交易done的fork高度
MainLoopCheckCommitTxDoneForkHeight
=
-1
MainLoopCheckCommitTxDoneForkHeight
=
-1
#主链过滤平行链tx
FetchFilterParaTxsEnable
=
-1
[store]
[store]
name
=
"kvmvccmavl"
name
=
"kvmvccmavl"
...
...
plugin/consensus/para/para.go
View file @
1b62e231
...
@@ -15,6 +15,8 @@ import (
...
@@ -15,6 +15,8 @@ import (
"time"
"time"
"test/common"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/merkle"
"github.com/33cn/chain33/common/merkle"
...
@@ -343,6 +345,40 @@ func (client *client) Query_IsCaughtUp(req *types.ReqNil) (types.Message, error)
...
@@ -343,6 +345,40 @@ func (client *client) Query_IsCaughtUp(req *types.ReqNil) (types.Message, error)
return
&
types
.
IsCaughtUp
{
Iscaughtup
:
client
.
isCaughtUp
()},
nil
return
&
types
.
IsCaughtUp
{
Iscaughtup
:
client
.
isCaughtUp
()},
nil
}
}
func
(
client
*
client
)
Query_LocalBlockInfo
(
req
*
types
.
ReqInt
)
(
types
.
Message
,
error
)
{
if
client
==
nil
{
return
nil
,
fmt
.
Errorf
(
"%s"
,
"client not bind message queue."
)
}
var
block
*
pt
.
ParaLocalDbBlock
var
err
error
if
req
.
Height
<=
-
1
{
block
,
err
=
client
.
getLastLocalBlock
()
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
block
,
err
=
client
.
getLocalBlockByHeight
(
req
.
Height
)
if
err
!=
nil
{
return
nil
,
err
}
}
blockInfo
:=
&
pt
.
ParaLocalDbBlockInfo
{
Height
:
block
.
Height
,
MainHash
:
common
.
ToHex
(
block
.
MainHash
),
MainHeight
:
block
.
MainHeight
,
ParentMainHash
:
common
.
ToHex
(
block
.
ParentMainHash
),
BlockTime
:
block
.
BlockTime
,
}
for
_
,
tx
:=
range
block
.
Txs
{
blockInfo
.
Txs
=
append
(
blockInfo
.
Txs
,
common
.
ToHex
(
tx
.
Hash
()))
}
return
blockInfo
,
nil
}
func
checkMinerTx
(
current
*
types
.
BlockDetail
)
error
{
func
checkMinerTx
(
current
*
types
.
BlockDetail
)
error
{
//检查第一个笔交易的execs, 以及执行状态
//检查第一个笔交易的execs, 以及执行状态
if
len
(
current
.
Block
.
Txs
)
==
0
{
if
len
(
current
.
Block
.
Txs
)
==
0
{
...
...
plugin/consensus/para/parasync_test.go
View file @
1b62e231
...
@@ -47,6 +47,7 @@ func initTestSyncBlock() {
...
@@ -47,6 +47,7 @@ func initTestSyncBlock() {
//新建一个para测试实例并初始化一些参数
//新建一个para测试实例并初始化一些参数
func
createParaTestInstance
(
t
*
testing
.
T
,
q
queue
.
Queue
)
*
client
{
func
createParaTestInstance
(
t
*
testing
.
T
,
q
queue
.
Queue
)
*
client
{
para
:=
new
(
client
)
para
:=
new
(
client
)
para
.
subCfg
=
new
(
subConfig
)
baseCli
:=
drivers
.
NewBaseClient
(
&
types
.
Consensus
{
Name
:
"name"
})
baseCli
:=
drivers
.
NewBaseClient
(
&
types
.
Consensus
{
Name
:
"name"
})
para
.
BaseClient
=
baseCli
para
.
BaseClient
=
baseCli
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
1b62e231
...
@@ -41,6 +41,7 @@ function para_set_toml() {
...
@@ -41,6 +41,7 @@ function para_set_toml() {
sed
-i
$xsedfix
's/^MainForkParacrossCommitTx=.*/MainForkParacrossCommitTx=10/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainForkParacrossCommitTx=.*/MainForkParacrossCommitTx=10/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainParaSelfConsensusForkHeight=.*/MainParaSelfConsensusForkHeight=50/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainParaSelfConsensusForkHeight=.*/MainParaSelfConsensusForkHeight=50/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight=60/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight=60/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^FetchFilterParaTxsEnable=.*/FetchFilterParaTxsEnable=1/g'
"
${
1
}
"
# rpc
# rpc
sed
-i
$xsedfix
's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g'
"
${
1
}
"
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
1b62e231
...
@@ -45,6 +45,7 @@ func ParcCmd() *cobra.Command {
...
@@ -45,6 +45,7 @@ func ParcCmd() *cobra.Command {
IsSyncCmd
(),
IsSyncCmd
(),
GetHeightCmd
(),
GetHeightCmd
(),
GetBlockInfoCmd
(),
GetBlockInfoCmd
(),
GetLocalBlockInfoCmd
(),
)
)
return
cmd
return
cmd
}
}
...
@@ -400,6 +401,36 @@ func blockInfo(cmd *cobra.Command, args []string) {
...
@@ -400,6 +401,36 @@ func blockInfo(cmd *cobra.Command, args []string) {
}
}
// GetLocalBlockInfoCmd get blocks hash with main chain hash map
func
GetLocalBlockInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"local_block"
,
Short
:
"Get para local block info"
,
Run
:
localBlockInfo
,
}
addLocalBlockBodyCmdFlags
(
cmd
)
return
cmd
}
func
addLocalBlockBodyCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Int64P
(
"start"
,
"t"
,
0
,
"block height,-1:latest height"
)
cmd
.
MarkFlagRequired
(
"start"
)
}
func
localBlockInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
startH
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"start"
)
params
:=
types
.
ReqInt
{
Height
:
startH
,
}
var
res
pt
.
ParaLocalDbBlockInfo
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetParaLocalBlockInfo"
,
params
,
&
res
)
ctx
.
Run
()
}
// GetParaInfoCmd get para chain status by height
// GetParaInfoCmd get para chain status by height
func
GetParaInfoCmd
()
*
cobra
.
Command
{
func
GetParaInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
1b62e231
...
@@ -310,6 +310,14 @@ message ParaLocalDbBlock {
...
@@ -310,6 +310,14 @@ message ParaLocalDbBlock {
repeated
Transaction
txs
=
6
;
repeated
Transaction
txs
=
6
;
}
}
message
ParaLocalDbBlockInfo
{
int64
height
=
1
;
string
mainHash
=
2
;
int64
mainHeight
=
3
;
string
parentMainHash
=
4
;
int64
blockTime
=
5
;
repeated
string
txs
=
6
;
}
service
paracross
{
service
paracross
{
rpc
GetTitle
(
ReqString
)
returns
(
ParacrossConsensusStatus
)
{}
rpc
GetTitle
(
ReqString
)
returns
(
ParacrossConsensusStatus
)
{}
...
...
plugin/dapp/paracross/rpc/rpc.go
View file @
1b62e231
...
@@ -160,6 +160,25 @@ func (c *Jrpc) IsSync(in *types.ReqNil, result *interface{}) error {
...
@@ -160,6 +160,25 @@ func (c *Jrpc) IsSync(in *types.ReqNil, result *interface{}) error {
return
nil
return
nil
}
}
// GetParaLocalBlockInfo query para local height
func
(
c
*
channelClient
)
GetParaLocalBlockInfo
(
ctx
context
.
Context
,
in
*
types
.
ReqInt
)
(
*
pt
.
ParaLocalDbBlockInfo
,
error
)
{
data
,
err
:=
c
.
QueryConsensusFunc
(
"para"
,
"LocalBlockInfo"
,
in
)
if
err
!=
nil
{
return
nil
,
err
}
return
data
.
(
*
pt
.
ParaLocalDbBlockInfo
),
nil
}
// GetParaLocalBlockInfo query para local height
func
(
c
*
Jrpc
)
GetParaLocalBlockInfo
(
in
*
types
.
ReqInt
,
result
*
interface
{})
error
{
data
,
err
:=
c
.
cli
.
GetParaLocalBlockInfo
(
context
.
Background
(),
in
)
if
err
!=
nil
{
return
err
}
*
result
=
data
return
nil
}
func
(
c
*
channelClient
)
GetBlock2MainInfo
(
ctx
context
.
Context
,
req
*
types
.
ReqBlocks
)
(
*
pt
.
ParaBlock2MainInfo
,
error
)
{
func
(
c
*
channelClient
)
GetBlock2MainInfo
(
ctx
context
.
Context
,
req
*
types
.
ReqBlocks
)
(
*
pt
.
ParaBlock2MainInfo
,
error
)
{
ret
:=
&
pt
.
ParaBlock2MainInfo
{}
ret
:=
&
pt
.
ParaBlock2MainInfo
{}
details
,
err
:=
c
.
GetBlocks
(
req
)
details
,
err
:=
c
.
GetBlocks
(
req
)
...
...
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