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
d32b6dce
Commit
d32b6dce
authored
Jan 18, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor to use new execapi to query data from main chain
parent
efb27f35
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
39 deletions
+10
-39
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+10
-39
No files found.
plugin/dapp/guess/executor/guessdb.go
View file @
d32b6dce
...
@@ -5,18 +5,14 @@
...
@@ -5,18 +5,14 @@
package
executor
package
executor
import
(
import
(
"context"
"fmt"
"fmt"
"strings"
"github.com/33cn/chain33/client/api"
"time"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/common/db/table"
"strings"
"github.com/33cn/chain33/client"
"google.golang.org/grpc"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
...
@@ -48,12 +44,6 @@ const (
...
@@ -48,12 +44,6 @@ const (
//MaxExpireHeight 距离游戏创建区块的最大过期高度差
//MaxExpireHeight 距离游戏创建区块的最大过期高度差
MaxExpireHeight
=
1000000
MaxExpireHeight
=
1000000
//grpcRecSize 接收缓冲大小
grpcRecSize
int
=
30
*
1024
*
1024
//retryNum 失败时的重试次数
retryNum
=
10
)
)
//Action 具体动作执行
//Action 具体动作执行
...
@@ -68,8 +58,7 @@ type Action struct {
...
@@ -68,8 +58,7 @@ type Action struct {
localDB
dbm
.
KVDB
localDB
dbm
.
KVDB
index
int
index
int
api
client
.
QueueProtocolAPI
api
client
.
QueueProtocolAPI
conn
*
grpc
.
ClientConn
execApi
api
.
ExecutorAPI
grpcClient
types
.
Chain33Client
}
}
//NewAction 生成Action对象
//NewAction 生成Action对象
...
@@ -77,19 +66,6 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
...
@@ -77,19 +66,6 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
hash
:=
tx
.
Hash
()
hash
:=
tx
.
Hash
()
fromAddr
:=
tx
.
From
()
fromAddr
:=
tx
.
From
()
msgRecvOp
:=
grpc
.
WithMaxMsgSize
(
grpcRecSize
)
paraRemoteGrpcClient
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
if
types
.
IsPara
()
&&
paraRemoteGrpcClient
==
""
{
panic
(
"ParaRemoteGrpcClient error"
)
}
conn
,
err
:=
grpc
.
Dial
(
paraRemoteGrpcClient
,
grpc
.
WithInsecure
(),
msgRecvOp
)
if
err
!=
nil
{
panic
(
err
)
}
grpcClient
:=
types
.
NewChain33Client
(
conn
)
return
&
Action
{
return
&
Action
{
coinsAccount
:
guess
.
GetCoinsAccount
(),
coinsAccount
:
guess
.
GetCoinsAccount
(),
db
:
guess
.
GetStateDB
(),
db
:
guess
.
GetStateDB
(),
...
@@ -101,8 +77,7 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
...
@@ -101,8 +77,7 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
localDB
:
guess
.
GetLocalDB
(),
localDB
:
guess
.
GetLocalDB
(),
index
:
index
,
index
:
index
,
api
:
guess
.
GetAPI
(),
api
:
guess
.
GetAPI
(),
conn
:
conn
,
execApi
:
guess
.
GetExecutorAPI
(),
grpcClient
:
grpcClient
,
}
}
}
}
...
@@ -902,15 +877,11 @@ func (action *Action) checkTime(start *gty.GuessGameStart) bool {
...
@@ -902,15 +877,11 @@ func (action *Action) checkTime(start *gty.GuessGameStart) bool {
// GetMainHeightByTxHash get Block height
// GetMainHeightByTxHash get Block height
func
(
action
*
Action
)
GetMainHeightByTxHash
(
txHash
[]
byte
)
int64
{
func
(
action
*
Action
)
GetMainHeightByTxHash
(
txHash
[]
byte
)
int64
{
for
i
:=
0
;
i
<
retryNum
;
i
++
{
req
:=
&
types
.
ReqHash
{
Hash
:
txHash
}
req
:=
&
types
.
ReqHash
{
Hash
:
txHash
}
txDetail
,
err
:=
action
.
execApi
.
QueryTx
(
req
)
txDetail
,
err
:=
action
.
grpcClient
.
QueryTransaction
(
context
.
Background
(),
req
)
if
err
!=
nil
{
if
err
!=
nil
{
return
-
1
time
.
Sleep
(
time
.
Second
)
}
else
{
return
txDetail
.
GetHeight
()
}
}
}
return
-
1
return
txDetail
.
GetHeight
()
}
}
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