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
039dc644
Commit
039dc644
authored
Jan 08, 2019
by
jixing wei
Committed by
vipwzw
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get mainblockhash from paracross
parent
5d2d1be2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
lotterydb.go
plugin/dapp/lottery/executor/lotterydb.go
+8
-6
query.go
plugin/dapp/paracross/executor/query.go
+32
-0
No files found.
plugin/dapp/lottery/executor/lotterydb.go
View file @
039dc644
...
...
@@ -127,6 +127,7 @@ type Action struct {
conn
*
grpc
.
ClientConn
grpcClient
types
.
Chain33Client
index
int
lottery
*
Lottery
}
// NewLotteryAction generate New Action
...
...
@@ -145,7 +146,7 @@ func NewLotteryAction(l *Lottery, tx *types.Transaction, index int) *Action {
grpcClient
:=
types
.
NewChain33Client
(
conn
)
return
&
Action
{
l
.
GetCoinsAccount
(),
l
.
GetStateDB
(),
hash
,
fromaddr
,
l
.
GetBlockTime
(),
l
.
GetHeight
(),
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
l
.
GetDifficulty
(),
l
.
GetAPI
(),
conn
,
grpcClient
,
index
}
l
.
GetHeight
(),
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
l
.
GetDifficulty
(),
l
.
GetAPI
(),
conn
,
grpcClient
,
index
,
l
}
}
// GetLottCommonRecipt generate logs for lottery common action
...
...
@@ -590,18 +591,19 @@ func (action *Action) findLuckyNum(isSolo bool, lott *LotteryDB) int64 {
reply
:=
msg
.
(
*
types
.
ReplyHash
)
hash
=
reply
.
Hash
}
else
{
mainHeight
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
llog
.
Error
(
"findLuckyNum"
,
"
mainHeight"
,
mainHeight
)
txs
:=
action
.
lottery
.
GetTxs
(
)
if
len
(
txs
)
<
action
.
index
+
1
{
llog
.
Error
(
"findLuckyNum"
,
"
len(txs)"
,
len
(
txs
),
"index"
,
action
.
index
)
return
-
1
}
m
ainBlockHash
,
err
:=
action
.
GetMainBlockHashByHeight
(
mainHeight
)
m
sg
,
err
:=
action
.
api
.
Query
(
"paracross"
,
"GetMainBlockHash"
,
txs
[
0
]
)
if
err
!=
nil
{
llog
.
Error
(
"findLuckyNum"
,
"err"
,
err
)
return
-
1
}
queryReply
:=
msg
.
(
*
types
.
ReplyHash
)
mainBlockHash
:=
queryReply
.
Hash
req
:=
&
types
.
ReqRandHash
{
ExecName
:
"ticket"
,
Hash
:
mainBlockHash
,
BlockNum
:
blockNum
}
reply
,
err
:=
action
.
grpcClient
.
QueryRandNum
(
context
.
Background
(),
req
)
if
err
!=
nil
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
039dc644
...
...
@@ -40,6 +40,38 @@ func (p *Paracross) Query_GetAssetTxResult(in *types.ReqHash) (types.Message, er
return
p
.
paracrossGetAssetTxResult
(
in
.
Hash
)
}
// Query_GetMainBlockHash query get mainblockHash by tx
func
(
p
*
Paracross
)
Query_GetMainBlockHash
(
in
*
types
.
Transaction
)
(
types
.
Message
,
error
)
{
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
return
p
.
paracrossGetMainBlockHash
(
in
)
}
func
(
p
*
Paracross
)
paracrossGetMainBlockHash
(
tx
*
types
.
Transaction
)
(
types
.
Message
,
error
)
{
var
paraAction
pt
.
ParacrossAction
err
:=
types
.
Decode
(
tx
.
GetPayload
(),
&
paraAction
)
if
err
!=
nil
{
return
nil
,
err
}
if
paraAction
.
GetTy
()
!=
pt
.
ParacrossActionMiner
{
return
nil
,
types
.
ErrCoinBaseTxType
}
if
paraAction
.
GetMiner
()
==
nil
{
return
nil
,
pt
.
ErrParaEmptyMinerTx
}
paraNodeStatus
:=
paraAction
.
GetMiner
()
.
GetStatus
()
if
paraNodeStatus
==
nil
{
return
nil
,
types
.
ErrCoinBaseTxType
}
mainHashFromNode
:=
paraNodeStatus
.
MainBlockHash
return
&
types
.
ReplyHash
{
Hash
:
mainHashFromNode
},
nil
}
func
(
p
*
Paracross
)
paracrossGetHeight
(
title
string
)
(
types
.
Message
,
error
)
{
ret
,
err
:=
getTitle
(
p
.
GetStateDB
(),
calcTitleKey
(
title
))
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