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
0c4557b7
Commit
0c4557b7
authored
Dec 24, 2018
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
2bea5d2e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
88 deletions
+83
-88
game.go
plugin/dapp/guess/commands/game.go
+36
-36
exec.go
plugin/dapp/guess/executor/exec.go
+6
-6
exec_del_local.go
plugin/dapp/guess/executor/exec_del_local.go
+10
-10
exec_local.go
plugin/dapp/guess/executor/exec_local.go
+11
-11
guess.go
plugin/dapp/guess/executor/guess.go
+3
-3
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+0
-0
keys.go
plugin/dapp/guess/executor/keys.go
+7
-7
query.go
plugin/dapp/guess/executor/query.go
+10
-10
types.go
plugin/dapp/guess/types/types.go
+0
-5
No files found.
plugin/dapp/guess/commands/game.go
View file @
0c4557b7
...
...
@@ -11,7 +11,7 @@ import (
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
"github.com/spf13/cobra"
)
...
...
@@ -80,8 +80,8 @@ func guessStart(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
topic
\"
:
\"
%s
\"
,
\"
options
\"
:
\"
%s
\"
,
\"
category
\"
:
\"
%s
\"
,
\"
maxBetHeight
\"
:%d,
\"
maxBetsOneTime
\"
:%d,
\"
maxBetsNumber
\"
:%d,
\"
devFeeFactor
\"
:%d,
\"
platFeeFactor
\"
:%d,
\"
expireHeight
\"
:%d,
\"
devFeeAddr
\"
:
\"
%s
\"
,
\"
platFeeAddr
\"
:
\"
%s
\"
}"
,
topic
,
options
,
category
,
maxBetHeight
,
maxBetsOneTime
,
maxBetsNumber
,
devFeeFactor
,
platFeeFactor
,
expireHeight
,
devFeeAddr
,
platFeeAddr
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
GuessX
),
ActionName
:
pkt
.
CreateStartTx
,
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateStartTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -119,8 +119,8 @@ func guessBet(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
option
\"
:
\"
%s
\"
,
\"
betsNum
\"
:%d}"
,
gameID
,
option
,
betsNumber
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
GuessX
),
ActionName
:
pkt
.
CreateBetTx
,
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateBetTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -152,8 +152,8 @@ func guessStopBet(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
GuessX
),
ActionName
:
pkt
.
CreateStopBetTx
,
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateStopBetTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -184,8 +184,8 @@ func guessAbort(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
}"
,
gameID
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
GuessX
),
ActionName
:
pkt
.
CreateAbortTx
,
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreateAbortTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -220,8 +220,8 @@ func guessPublish(cmd *cobra.Command, args []string) {
payload
:=
fmt
.
Sprintf
(
"{
\"
gameID
\"
:
\"
%s
\"
,
\"
result
\"
:
\"
%s
\"
}"
,
gameID
,
result
)
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pkt
.
GuessX
),
ActionName
:
pkt
.
CreatePublishTx
,
Execer
:
types
.
ExecName
(
gty
.
GuessX
),
ActionName
:
gty
.
CreatePublishTx
,
Payload
:
[]
byte
(
payload
),
}
...
...
@@ -264,7 +264,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
pkt
.
GuessX
params
.
Execer
=
gty
.
GuessX
//query type,
//1:QueryGamesByIds,
...
...
@@ -278,91 +278,91 @@ func guessQuery(cmd *cobra.Command, args []string) {
switch
ty
{
case
1
:
gameIds
:=
strings
.
Split
(
gameIDs
,
";"
)
req
:=
&
pkt
.
QueryGuessGameInfos
{
req
:=
&
gty
.
QueryGuessGameInfos
{
GameIDs
:
gameIds
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGamesByIDs
params
.
FuncName
=
gty
.
FuncNameQueryGamesByIDs
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
ReplyGuessGameInfos
var
res
gty
.
ReplyGuessGameInfos
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
2
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
GameID
:
gameID
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByID
params
.
FuncName
=
gty
.
FuncNameQueryGameByID
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
ReplyGuessGameInfo
var
res
gty
.
ReplyGuessGameInfo
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
3
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Addr
:
addr
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByAddr
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddr
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
GuessGameRecords
var
res
gty
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
4
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
GuessGameRecords
var
res
gty
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
5
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
AdminAddr
:
adminAddr
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByAdminAddr
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminAddr
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
GuessGameRecords
var
res
gty
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
6
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Addr
:
addr
,
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByAddrStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddrStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
GuessGameRecords
var
res
gty
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
7
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
AdminAddr
:
adminAddr
,
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByAdminStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
GuessGameRecords
var
res
gty
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
8
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Category
:
category
,
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncNameQueryGameByCategoryStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByCategoryStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
var
res
pkt
.
GuessGameRecords
var
res
gty
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
}
...
...
plugin/dapp/guess/executor/exec.go
View file @
0c4557b7
...
...
@@ -6,35 +6,35 @@ package executor
import
(
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
//Exec_Start Guess执行器创建游戏
func
(
c
*
Guess
)
Exec_Start
(
payload
*
pkt
.
GuessGameStart
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_Start
(
payload
*
gty
.
GuessGameStart
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameStart
(
payload
)
}
//Exec_Bet Guess执行器参与游戏
func
(
c
*
Guess
)
Exec_Bet
(
payload
*
pkt
.
GuessGameBet
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_Bet
(
payload
*
gty
.
GuessGameBet
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameBet
(
payload
)
}
//Exec_StopBet Guess执行器停止游戏下注
func
(
c
*
Guess
)
Exec_StopBet
(
payload
*
pkt
.
GuessGameStopBet
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_StopBet
(
payload
*
gty
.
GuessGameStopBet
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameStopBet
(
payload
)
}
//Exec_Publish Guess执行器公布游戏结果
func
(
c
*
Guess
)
Exec_Publish
(
payload
*
pkt
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_Publish
(
payload
*
gty
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GamePublish
(
payload
)
}
//Exec_Abort Guess执行器撤销未结束游戏
func
(
c
*
Guess
)
Exec_Abort
(
payload
*
pkt
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_Abort
(
payload
*
gty
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameAbort
(
payload
)
}
plugin/dapp/guess/executor/exec_del_local.go
View file @
0c4557b7
...
...
@@ -6,18 +6,18 @@ package executor
import
(
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
func
(
g
*
Guess
)
rollbackIndex
(
log
*
pkt
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
func
(
g
*
Guess
)
rollbackIndex
(
log
*
gty
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
//新创建游戏,将增加的记录都删除掉
if
log
.
Status
==
pkt
.
GuessGameStatusStart
{
if
log
.
Status
==
gty
.
GuessGameStatusStart
{
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAdminIndexKey
(
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
Index
))
}
else
if
log
.
Status
==
pkt
.
GuessGameStatusBet
{
}
else
if
log
.
Status
==
gty
.
GuessGameStatusBet
{
//如果是下注状态,则有用户进行了下注操作,对这些记录进行删除
kvs
=
append
(
kvs
,
delGuessGameAddrIndexKey
(
log
.
Addr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
Index
))
...
...
@@ -64,8 +64,8 @@ func (g *Guess) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet,
for
_
,
log
:=
range
receiptData
.
Logs
{
switch
log
.
GetTy
()
{
case
pkt
.
TyLogGuessGameStart
,
pkt
.
TyLogGuessGameBet
,
pkt
.
TyLogGuessGameStopBet
,
pkt
.
TyLogGuessGameAbort
,
pkt
.
TyLogGuessGamePublish
,
pkt
.
TyLogGuessGameTimeout
:
receiptGame
:=
&
pkt
.
ReceiptGuessGame
{}
case
gty
.
TyLogGuessGameStart
,
gty
.
TyLogGuessGameBet
,
gty
.
TyLogGuessGameStopBet
,
gty
.
TyLogGuessGameAbort
,
gty
.
TyLogGuessGamePublish
,
gty
.
TyLogGuessGameTimeout
:
receiptGame
:=
&
gty
.
ReceiptGuessGame
{}
if
err
:=
types
.
Decode
(
log
.
Log
,
receiptGame
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -77,21 +77,21 @@ func (g *Guess) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet,
}
//ExecDelLocal_Start Guess执行器Start交易撤销
func
(
g
*
Guess
)
ExecDelLocal_Start
(
payload
*
pkt
.
GuessGameStart
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecDelLocal_Start
(
payload
*
gty
.
GuessGameStart
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecDelLocal_Bet Guess执行器Bet交易撤销
func
(
g
*
Guess
)
ExecDelLocal_Bet
(
payload
*
pkt
.
GuessGameBet
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecDelLocal_Bet
(
payload
*
gty
.
GuessGameBet
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecDelLocal_Publish Guess执行器Publish交易撤销
func
(
g
*
Guess
)
ExecDelLocal_Publish
(
payload
*
pkt
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecDelLocal_Publish
(
payload
*
gty
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecDelLocal_Abort Guess执行器Abort交易撤销
func
(
g
*
Guess
)
ExecDelLocal_Abort
(
payload
*
pkt
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecDelLocal_Abort
(
payload
*
gty
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
plugin/dapp/guess/executor/exec_local.go
View file @
0c4557b7
...
...
@@ -6,18 +6,18 @@ package executor
import
(
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
func
(
g
*
Guess
)
updateIndex
(
log
*
pkt
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
func
(
g
*
Guess
)
updateIndex
(
log
*
gty
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
//新创建游戏
if
log
.
Status
==
pkt
.
GuessGameStatusStart
{
if
log
.
Status
==
gty
.
GuessGameStatusStart
{
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameID
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameID
,
log
.
Index
))
}
else
if
log
.
Status
==
pkt
.
GuessGameStatusBet
{
}
else
if
log
.
Status
==
gty
.
GuessGameStatusBet
{
//如果是下注状态,则有用户进行了下注操作
kvs
=
append
(
kvs
,
addGuessGameAddrIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameID
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameID
,
log
.
Index
))
...
...
@@ -62,8 +62,8 @@ func (g *Guess) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error)
}
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
item
:=
receipt
.
Logs
[
i
]
if
item
.
Ty
>=
pkt
.
TyLogGuessGameStart
&&
item
.
Ty
<=
pkt
.
TyLogGuessGameTimeout
{
var
Gamelog
pkt
.
ReceiptGuessGame
if
item
.
Ty
>=
gty
.
TyLogGuessGameStart
&&
item
.
Ty
<=
gty
.
TyLogGuessGameTimeout
{
var
Gamelog
gty
.
ReceiptGuessGame
err
:=
types
.
Decode
(
item
.
Log
,
&
Gamelog
)
if
err
!=
nil
{
panic
(
err
)
//数据错误了,已经被修改了
...
...
@@ -76,26 +76,26 @@ func (g *Guess) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error)
}
//ExecLocal_Start method
func
(
g
*
Guess
)
ExecLocal_Start
(
payload
*
pkt
.
GuessGameStart
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecLocal_Start
(
payload
*
gty
.
GuessGameStart
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecLocal_Bet method
func
(
g
*
Guess
)
ExecLocal_Bet
(
payload
*
pkt
.
GuessGameBet
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecLocal_Bet
(
payload
*
gty
.
GuessGameBet
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecLocal_StopBet method
func
(
g
*
Guess
)
ExecLocal_StopBet
(
payload
*
pkt
.
GuessGameStopBet
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecLocal_StopBet
(
payload
*
gty
.
GuessGameStopBet
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecLocal_Publish method
func
(
g
*
Guess
)
ExecLocal_Publish
(
payload
*
pkt
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecLocal_Publish
(
payload
*
gty
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
//ExecLocal_Abort method
func
(
g
*
Guess
)
ExecLocal_Abort
(
payload
*
pkt
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
g
*
Guess
)
ExecLocal_Abort
(
payload
*
gty
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
return
g
.
execLocal
(
receiptData
)
}
plugin/dapp/guess/executor/guess.go
View file @
0c4557b7
...
...
@@ -8,12 +8,12 @@ import (
log
"github.com/33cn/chain33/common/log/log15"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
var
logger
=
log
.
New
(
"module"
,
"execs.guess"
)
var
driverName
=
pkt
.
GuessX
var
driverName
=
gty
.
GuessX
func
init
()
{
ety
:=
types
.
LoadExecutorType
(
driverName
)
...
...
@@ -57,7 +57,7 @@ func GetName() string {
//GetDriverName 获取Guess执行器的名称
func
(
g
*
Guess
)
GetDriverName
()
string
{
return
pkt
.
GuessX
return
gty
.
GuessX
}
/*
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
0c4557b7
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/executor/keys.go
View file @
0c4557b7
...
...
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
//addr prefix
...
...
@@ -80,7 +80,7 @@ func calcGuessGameCategoryStatusKey(category string, status int32, index int64)
func
addGuessGameAddrIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrKey
(
addr
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
...
...
@@ -99,7 +99,7 @@ func delGuessGameAddrIndexKey(addr string, index int64) *types.KeyValue {
func
addGuessGameStatusIndexKey
(
status
int32
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameStatusKey
(
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
...
...
@@ -118,7 +118,7 @@ func delGuessGameStatusIndexKey(status int32, index int64) *types.KeyValue {
func
addGuessGameAddrStatusIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrStatusKey
(
addr
,
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
...
...
@@ -137,7 +137,7 @@ func delGuessGameAddrStatusIndexKey(status int32, addr string, index int64) *typ
func
addGuessGameAdminIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminKey
(
addr
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
...
...
@@ -156,7 +156,7 @@ func delGuessGameAdminIndexKey(addr string, index int64) *types.KeyValue {
func
addGuessGameAdminStatusIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminStatusKey
(
addr
,
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
...
...
@@ -175,7 +175,7 @@ func delGuessGameAdminStatusIndexKey(status int32, addr string, index int64) *ty
func
addGuessGameCategoryStatusIndexKey
(
status
int32
,
category
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameCategoryStatusKey
(
category
,
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
...
...
plugin/dapp/guess/executor/query.go
View file @
0c4557b7
...
...
@@ -6,25 +6,25 @@ package executor
import
(
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
//Query_QueryGamesByIDs method
func
(
g
*
Guess
)
Query_QueryGamesByIDs
(
in
*
pkt
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByIDs
(
in
*
gty
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
return
Infos
(
g
.
GetStateDB
(),
in
)
}
//Query_QueryGameByID method
func
(
g
*
Guess
)
Query_QueryGameByID
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameByID
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
in
.
GetGameID
())
if
err
!=
nil
{
return
nil
,
err
}
return
&
pkt
.
ReplyGuessGameInfo
{
Game
:
game
},
nil
return
&
gty
.
ReplyGuessGameInfo
{
Game
:
game
},
nil
}
//Query_QueryGamesByAddr method
func
(
g
*
Guess
)
Query_QueryGamesByAddr
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAddr
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAddr
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -34,7 +34,7 @@ func (g *Guess) Query_QueryGamesByAddr(in *pkt.QueryGuessGameInfo) (types.Messag
}
//Query_QueryGamesByStatus method
func
(
g
*
Guess
)
Query_QueryGamesByStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByStatus
(
g
.
GetLocalDB
(),
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -44,7 +44,7 @@ func (g *Guess) Query_QueryGamesByStatus(in *pkt.QueryGuessGameInfo) (types.Mess
}
//Query_QueryGamesByAdminAddr method
func
(
g
*
Guess
)
Query_QueryGamesByAdminAddr
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAdminAddr
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAdminAddr
(
g
.
GetLocalDB
(),
in
.
AdminAddr
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -54,7 +54,7 @@ func (g *Guess) Query_QueryGamesByAdminAddr(in *pkt.QueryGuessGameInfo) (types.M
}
//Query_QueryGamesByAddrStatus method
func
(
g
*
Guess
)
Query_QueryGamesByAddrStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAddrStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAddrStatus
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -64,7 +64,7 @@ func (g *Guess) Query_QueryGamesByAddrStatus(in *pkt.QueryGuessGameInfo) (types.
}
//Query_QueryGamesByAdminStatus method
func
(
g
*
Guess
)
Query_QueryGamesByAdminStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAdminStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAdminStatus
(
g
.
GetLocalDB
(),
in
.
AdminAddr
,
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -74,7 +74,7 @@ func (g *Guess) Query_QueryGamesByAdminStatus(in *pkt.QueryGuessGameInfo) (types
}
//Query_QueryGamesByCategoryStatus method
func
(
g
*
Guess
)
Query_QueryGamesByCategoryStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByCategoryStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByCategoryStatus
(
g
.
GetLocalDB
(),
in
.
Category
,
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
...
...
plugin/dapp/guess/types/types.go
View file @
0c4557b7
...
...
@@ -7,14 +7,9 @@ package types
import
(
"reflect"
log
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
)
var
(
llog
=
log
.
New
(
"module"
,
"exectype."
+
GuessX
)
)
func
init
()
{
// init executor type
types
.
RegistorExecutor
(
GuessX
,
NewType
())
...
...
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