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
62edd355
Commit
62edd355
authored
Jan 22, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
385b3512
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
47 deletions
+7
-47
guess.go
plugin/dapp/guess/executor/guess.go
+1
-9
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+6
-38
No files found.
plugin/dapp/guess/executor/guess.go
View file @
62edd355
...
...
@@ -20,21 +20,13 @@ func init() {
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Guess
{}))
}
type
subConfig
struct
{
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient"`
}
var
cfg
subConfig
// Init Guess
func
Init
(
name
string
,
sub
[]
byte
)
{
driverName
:=
GetName
()
if
name
!=
driverName
{
panic
(
"system dapp can't be rename"
)
}
if
sub
!=
nil
{
types
.
MustDecode
(
sub
,
&
cfg
)
}
drivers
.
Register
(
driverName
,
newGuessGame
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
}
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
62edd355
...
...
@@ -8,7 +8,6 @@ import (
"fmt"
"strings"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
...
...
@@ -59,7 +58,7 @@ type Action struct {
localDB
dbm
.
KVDB
index
int
api
client
.
QueueProtocolAPI
execAPI
api
.
ExecutorAPI
mainHeight
int64
}
//NewAction 生成Action对象
...
...
@@ -77,8 +76,7 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
execaddr
:
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
localDB
:
guess
.
GetLocalDB
(),
index
:
index
,
api
:
guess
.
GetAPI
(),
execAPI
:
guess
.
GetExecutorAPI
(),
mainHeight
:
guess
.
GetMainHeight
(),
}
}
...
...
@@ -351,16 +349,7 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
gameID
:=
common
.
ToHex
(
action
.
txhash
)
game
,
_
:=
action
.
newGame
(
gameID
,
start
)
game
.
StartTime
=
action
.
blocktime
if
types
.
IsPara
()
{
mainHeight
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
logger
.
Error
(
"GameStart"
,
"mainHeight"
,
mainHeight
)
return
nil
,
gty
.
ErrGuessStatus
}
game
.
StartHeight
=
mainHeight
}
else
{
game
.
StartHeight
=
action
.
height
}
game
.
StartHeight
=
action
.
mainHeight
game
.
AdminAddr
=
action
.
fromaddr
game
.
PreIndex
=
0
game
.
Index
=
action
.
getIndex
()
...
...
@@ -807,18 +796,7 @@ func (action *Action) changeAllAddrIndex(game *gty.GuessGame) {
//refreshStatusByTime 检测游戏是否过期,是否可以下注
func
(
action
*
Action
)
refreshStatusByTime
(
game
*
gty
.
GuessGame
)
(
canBet
bool
)
{
var
mainHeight
int64
if
types
.
IsPara
()
{
mainHeight
=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
logger
.
Error
(
"RefreshStatusByTime"
,
"mainHeight err"
,
mainHeight
)
return
true
}
}
else
{
mainHeight
=
action
.
height
}
mainHeight
:=
action
.
mainHeight
//如果完全由管理员驱动状态变化,则除了保护性过期判断外,不需要做其他判断。
if
game
.
DrivenByAdmin
{
...
...
@@ -874,15 +852,4 @@ func (action *Action) checkTime(start *gty.GuessGameStart) bool {
}
return
false
}
// GetMainHeightByTxHash get Block height
func
(
action
*
Action
)
GetMainHeightByTxHash
(
txHash
[]
byte
)
int64
{
req
:=
&
types
.
ReqHash
{
Hash
:
txHash
}
txDetail
,
err
:=
action
.
execAPI
.
QueryTx
(
req
)
if
err
!=
nil
{
return
-
1
}
return
txDetail
.
GetHeight
()
}
}
\ No newline at end of file
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