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
e010ff88
Commit
e010ff88
authored
May 30, 2019
by
mdj33
Committed by
vipwzw
May 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paracross add query
parent
0ed57c0e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
8 deletions
+60
-8
paracross.go
plugin/dapp/paracross/commands/paracross.go
+1
-1
action.go
plugin/dapp/paracross/executor/action.go
+2
-2
query.go
plugin/dapp/paracross/executor/query.go
+28
-2
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+15
-1
rpc.go
plugin/dapp/paracross/rpc/rpc.go
+14
-2
No files found.
plugin/dapp/paracross/commands/paracross.go
View file @
e010ff88
...
...
@@ -446,7 +446,7 @@ func paraInfo(cmd *cobra.Command, args []string) {
Title
:
title
,
Height
:
height
,
}
var
res
pt
.
RespParacrossDone
var
res
pt
.
ParacrossHeightStatusRsp
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetTitleHeight"
,
params
,
&
res
)
ctx
.
Run
()
}
...
...
plugin/dapp/paracross/executor/action.go
View file @
e010ff88
...
...
@@ -344,6 +344,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
if
a
.
exec
.
GetMainHeight
()
>=
getDappForkHeight
(
pt
.
ForkCommitTx
)
{
stat
.
MainHeight
=
commit
.
Status
.
MainBlockHeight
stat
.
MainHash
=
commit
.
Status
.
MainBlockHash
}
receipt
=
makeCommitReceipt
(
a
.
fromaddr
,
commit
,
nil
,
stat
)
}
else
{
...
...
@@ -384,8 +385,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
//add commit done receipt
receiptDone
:=
makeDoneReceipt
(
a
.
fromaddr
,
commit
,
stat
,
int32
(
most
),
int32
(
commitCount
),
int32
(
len
(
nodes
)))
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptDone
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptDone
.
Logs
...
)
receipt
=
mergeReceipt
(
receipt
,
receiptDone
)
//平行连进行奖励分配,考虑可能的失败,需要在保存共识高度等数据之前处理
if
types
.
IsPara
()
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
e010ff88
...
...
@@ -12,6 +12,7 @@ import (
"github.com/33cn/chain33/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/pkg/errors"
"github.com/33cn/chain33/common"
)
// Query_GetTitle query paracross title
...
...
@@ -22,6 +23,31 @@ func (p *Paracross) Query_GetTitle(in *types.ReqString) (types.Message, error) {
return
p
.
paracrossGetHeight
(
in
.
GetData
())
}
// Query_GetTitleHeight query paracross status with title and height
func
(
p
*
Paracross
)
Query_GetTitleHeight
(
in
*
pt
.
ReqParacrossTitleHeight
)
(
types
.
Message
,
error
)
{
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
stat
,
err
:=
p
.
paracrossGetStateTitleHeight
(
in
.
Title
,
in
.
Height
)
if
err
!=
nil
{
clog
.
Error
(
"paracross.GetTitleHeight"
,
"title"
,
title
,
"height"
,
in
.
Height
,
"err"
,
err
.
Error
())
return
nil
,
err
}
status
:=
stat
.
(
*
pt
.
ParacrossHeightStatus
)
res
:=
&
pt
.
ParacrossHeightStatusRsp
{
Status
:
status
.
Status
,
Title
:
status
.
Title
,
Height
:
status
.
Height
,
MainHeight
:
status
.
MainHeight
,
MainHash
:
common
.
ToHex
(
status
.
MainHash
),
}
for
i
,
addr
:=
range
status
.
Details
.
Addrs
{
res
.
CommitAddrs
=
append
(
res
.
CommitAddrs
,
addr
)
res
.
CommitBlockHash
=
append
(
res
.
CommitBlockHash
,
common
.
ToHex
(
status
.
Details
.
BlockHash
[
i
]))
}
return
res
,
nil
}
// Query_GetTitleByHash query paracross title by block hash
func
(
p
*
Paracross
)
Query_GetTitleByHash
(
in
*
pt
.
ReqParacrossTitleHash
)
(
types
.
Message
,
error
)
{
if
in
==
nil
{
...
...
@@ -99,8 +125,8 @@ func (p *Paracross) Query_ListTitles(in *types.ReqNil) (types.Message, error) {
return
p
.
paracrossListTitles
()
}
// Query_GetTitleHeight query title height
func
(
p
*
Paracross
)
Query_GetTitleHeight
(
in
*
pt
.
ReqParacrossTitleHeight
)
(
types
.
Message
,
error
)
{
// Query_Get
Done
TitleHeight query title height
func
(
p
*
Paracross
)
Query_Get
Done
TitleHeight
(
in
*
pt
.
ReqParacrossTitleHeight
)
(
types
.
Message
,
error
)
{
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
e010ff88
...
...
@@ -20,6 +20,18 @@ message ParacrossHeightStatus {
int64
height
=
3
;
ParacrossStatusDetails
details
=
4
;
int64
mainHeight
=
5
;
bytes
mainHash
=
6
;
}
message
ParacrossHeightStatusRsp
{
int32
status
=
1
;
string
title
=
2
;
int64
height
=
3
;
int64
mainHeight
=
4
;
string
mainHash
=
5
;
repeated
string
commitAddrs
=
6
;
repeated
string
commitBlockHash
=
7
;
}
message
ParacrossStatus
{
...
...
@@ -263,7 +275,8 @@ message ParacrossAsset {
service
paracross
{
rpc
GetTitle
(
ReqString
)
returns
(
ParacrossConsensusStatus
)
{}
rpc
ListTitles
(
ReqNil
)
returns
(
RespParacrossTitles
)
{}
rpc
GetTitleHeight
(
ReqParacrossTitleHeight
)
returns
(
RespParacrossDone
)
{}
rpc
GetDoneTitleHeight
(
ReqParacrossTitleHeight
)
returns
(
RespParacrossDone
)
{}
rpc
GetTitleHeight
(
ReqParacrossTitleHeight
)
returns
(
ParacrossHeightStatusRsp
)
{}
rpc
GetAssetTxResult
(
ReqHash
)
returns
(
ParacrossAsset
)
{}
rpc
IsSync
(
ReqNil
)
returns
(
IsCaughtUp
)
{}
}
\ No newline at end of file
plugin/dapp/paracross/rpc/rpc.go
View file @
e010ff88
...
...
@@ -72,12 +72,12 @@ func (c *Jrpc) ListTitles(req *types.ReqNil, result *interface{}) error {
return
err
}
func
(
c
*
channelClient
)
GetTitleHeight
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossTitleHeight
)
(
*
pt
.
RespParacrossDone
,
error
)
{
func
(
c
*
channelClient
)
GetTitleHeight
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossTitleHeight
)
(
*
pt
.
ParacrossHeightStatusRsp
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetTitleHeight"
,
req
)
if
err
!=
nil
{
return
nil
,
err
}
if
resp
,
ok
:=
data
.
(
*
pt
.
RespParacrossDone
);
ok
{
if
resp
,
ok
:=
data
.
(
*
pt
.
ParacrossHeightStatusRsp
);
ok
{
return
resp
,
nil
}
return
nil
,
types
.
ErrDecode
...
...
@@ -93,6 +93,18 @@ func (c *Jrpc) GetTitleHeight(req *pt.ReqParacrossTitleHeight, result *interface
return
err
}
func
(
c
*
channelClient
)
GetDoneTitleHeight
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossTitleHeight
)
(
*
pt
.
RespParacrossDone
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetDoneTitleHeight"
,
req
)
if
err
!=
nil
{
return
nil
,
err
}
if
resp
,
ok
:=
data
.
(
*
pt
.
RespParacrossDone
);
ok
{
return
resp
,
nil
}
return
nil
,
types
.
ErrDecode
}
func
(
c
*
channelClient
)
GetAssetTxResult
(
ctx
context
.
Context
,
req
*
types
.
ReqHash
)
(
*
pt
.
ParacrossAsset
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetAssetTxResult"
,
req
)
if
err
!=
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