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
baf4c3b1
Commit
baf4c3b1
authored
Dec 04, 2018
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guess
parent
a8e53ba4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
238 additions
and
131 deletions
+238
-131
game.go
plugin/dapp/guess/commands/game.go
+122
-59
exec_del_local.go
plugin/dapp/guess/executor/exec_del_local.go
+1
-1
exec_local.go
plugin/dapp/guess/executor/exec_local.go
+1
-1
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+0
-0
query.go
plugin/dapp/guess/executor/query.go
+3
-12
guess.proto
plugin/dapp/guess/proto/guess.proto
+19
-26
jrpc.go
plugin/dapp/guess/rpc/jrpc.go
+5
-3
const.go
plugin/dapp/guess/types/const.go
+8
-6
errors.go
plugin/dapp/guess/types/errors.go
+13
-0
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+0
-0
tx.go
plugin/dapp/guess/types/tx.go
+8
-9
types.go
plugin/dapp/guess/types/types.go
+57
-14
init.go
plugin/dapp/init/init.go
+1
-0
No files found.
plugin/dapp/guess/commands/game.go
View file @
baf4c3b1
...
@@ -5,9 +5,12 @@
...
@@ -5,9 +5,12 @@
package
commands
package
commands
import
(
import
(
"fmt"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
pkt
"github.com/33cn/plugin/plugin/dapp/guess/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"strings"
)
)
func
GuessCmd
()
*
cobra
.
Command
{
func
GuessCmd
()
*
cobra
.
Command
{
...
@@ -45,45 +48,38 @@ func addGuessStartFlags(cmd *cobra.Command) {
...
@@ -45,45 +48,38 @@ func addGuessStartFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"options"
,
"o"
,
""
,
"options"
)
cmd
.
Flags
()
.
StringP
(
"options"
,
"o"
,
""
,
"options"
)
cmd
.
MarkFlagRequired
(
"options"
)
cmd
.
MarkFlagRequired
(
"options"
)
cmd
.
Flags
()
.
StringP
(
"maxTime"
,
"mt"
,
""
,
"max time to bet, after this bet is forbidden"
)
cmd
.
Flags
()
.
StringP
(
"maxBetTime"
,
"b"
,
""
,
"max time to bet, after this bet is forbidden"
)
cmd
.
Flags
()
.
Int64P
(
"maxBetHeight"
,
"c"
,
0
,
"max height to bet, after this bet is forbidden"
)
cmd
.
Flags
()
.
Uint32P
(
"maxHeight"
,
"h"
,
0
,
"max height to bet, after this bet is forbidden"
)
cmd
.
MarkFlagRequired
(
"maxHeight"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
"bty"
,
"token symbol"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
"bty"
,
"token symbol"
)
cmd
.
Flags
()
.
StringP
(
"exec"
,
"e"
,
"coins"
,
"excutor name"
)
cmd
.
Flags
()
.
StringP
(
"exec"
,
"e"
,
"coins"
,
"excutor name"
)
cmd
.
Flags
()
.
Uint32P
(
"oneBet"
,
"b"
,
10
,
"one bet number, eg:10 bty / 10 token"
)
cmd
.
Flags
()
.
Uint32P
(
"maxBetsOneTime"
,
"m"
,
10000
,
"max bets one time"
)
//cmd.MarkFlagRequired("oneBet")
cmd
.
Flags
()
.
Uint32P
(
"maxBets"
,
"m"
,
10000
,
"max bets one time"
)
//cmd.MarkFlagRequired("maxBets")
//cmd.MarkFlagRequired("maxBets")
cmd
.
Flags
()
.
Uint32P
(
"maxBetsNumber"
,
"n"
,
100000
,
"max bets number"
)
cmd
.
Flags
()
.
Uint32P
(
"maxBetsNumber"
,
"n"
,
100000
,
"max bets number"
)
//cmd.MarkFlagRequired("maxBetsNumber")
//cmd.MarkFlagRequired("maxBetsNumber")
cmd
.
Flags
()
.
Int64P
(
"devFeeFactor"
,
"d
f
"
,
0
,
"dev fee factor, unit: 1/1000"
)
cmd
.
Flags
()
.
Int64P
(
"devFeeFactor"
,
"d"
,
0
,
"dev fee factor, unit: 1/1000"
)
cmd
.
Flags
()
.
StringP
(
"devFeeAddr"
,
"
dfa
"
,
""
,
"dev address to receive share"
)
cmd
.
Flags
()
.
StringP
(
"devFeeAddr"
,
"
f
"
,
""
,
"dev address to receive share"
)
cmd
.
Flags
()
.
Int64P
(
"platFeeFactor"
,
"p
f
"
,
0
,
"plat fee factor, unit: 1/1000"
)
cmd
.
Flags
()
.
Int64P
(
"platFeeFactor"
,
"p"
,
0
,
"plat fee factor, unit: 1/1000"
)
cmd
.
Flags
()
.
StringP
(
"platFeeAddr"
,
"
pfa
"
,
""
,
"plat address to receive share"
)
cmd
.
Flags
()
.
StringP
(
"platFeeAddr"
,
"
q
"
,
""
,
"plat address to receive share"
)
cmd
.
Flags
()
.
StringP
(
"expire"
,
"
e
x"
,
""
,
"expire time of the game, after this any addr can abort it"
)
cmd
.
Flags
()
.
StringP
(
"expire"
,
"x"
,
""
,
"expire time of the game, after this any addr can abort it"
)
cmd
.
Flags
()
.
Uint32P
(
"expireHeight"
,
"eh
"
,
0
,
"expire height of the game, after this any addr can abort it"
)
cmd
.
Flags
()
.
Int64P
(
"expireHeight"
,
"y
"
,
0
,
"expire height of the game, after this any addr can abort it"
)
}
}
func
guessStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
topic
,
_
:=
cmd
.
Flags
()
.
GetString
(
"topic"
)
topic
,
_
:=
cmd
.
Flags
()
.
GetString
(
"topic"
)
options
,
_
:=
cmd
.
Flags
()
.
GetString
(
"options"
)
options
,
_
:=
cmd
.
Flags
()
.
GetString
(
"options"
)
max
Time
,
_
:=
cmd
.
Flags
()
.
GetString
(
"max
Time"
)
max
BetTime
,
_
:=
cmd
.
Flags
()
.
GetString
(
"maxBet
Time"
)
max
Height
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"max
Height"
)
max
BetHeight
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"maxBet
Height"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
oneBet
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"oneBet"
)
maxBets
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"maxBets"
)
maxBets
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"maxBets"
)
maxBetsNumber
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"maxBetsNumber"
)
maxBetsNumber
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"maxBetsNumber"
)
devFeeFactor
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"devFeeFactor"
)
devFeeFactor
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"devFeeFactor"
)
...
@@ -91,17 +87,16 @@ func guessStart(cmd *cobra.Command, args []string) {
...
@@ -91,17 +87,16 @@ func guessStart(cmd *cobra.Command, args []string) {
platFeeFactor
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"platFeeFactor"
)
platFeeFactor
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"platFeeFactor"
)
platFeeAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"platFeeAddr"
)
platFeeAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"platFeeAddr"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
expireHeight
,
_
:=
cmd
.
Flags
()
.
Get
Uint32
(
"expireHeight"
)
expireHeight
,
_
:=
cmd
.
Flags
()
.
Get
Int64
(
"expireHeight"
)
params
:=
&
pkt
.
GuessStartTxReq
{
params
:=
&
pkt
.
GuessStartTxReq
{
Topic
:
topic
,
Topic
:
topic
,
Options
:
options
,
Options
:
options
,
Max
Time
:
max
Time
,
Max
BetTime
:
maxBet
Time
,
Max
Height
:
max
Height
,
Max
BetHeight
:
maxBet
Height
,
Symbol
:
symbol
,
Symbol
:
symbol
,
Exec
:
exec
,
Exec
:
exec
,
OneBet
:
oneBet
,
MaxBetsOneTime
:
maxBets
,
MaxBets
:
maxBets
,
MaxBetsNumber
:
maxBetsNumber
,
MaxBetsNumber
:
maxBetsNumber
,
DevFeeFactor
:
devFeeFactor
,
DevFeeFactor
:
devFeeFactor
,
DevFeeAddr
:
devFeeAddr
,
DevFeeAddr
:
devFeeAddr
,
...
@@ -217,7 +212,7 @@ func guessPublish(cmd *cobra.Command, args []string) {
...
@@ -217,7 +212,7 @@ func guessPublish(cmd *cobra.Command, args []string) {
func
GuessQueryRawTxCmd
()
*
cobra
.
Command
{
func
GuessQueryRawTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"query"
,
Use
:
"query"
,
Short
:
"
Query result
"
,
Short
:
"
query info
"
,
Run
:
guessQuery
,
Run
:
guessQuery
,
}
}
addGuessQueryFlags
(
cmd
)
addGuessQueryFlags
(
cmd
)
...
@@ -225,62 +220,130 @@ func GuessQueryRawTxCmd() *cobra.Command {
...
@@ -225,62 +220,130 @@ func GuessQueryRawTxCmd() *cobra.Command {
}
}
func
addGuessQueryFlags
(
cmd
*
cobra
.
Command
)
{
func
addGuessQueryFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"gameID"
,
"g"
,
""
,
"game ID"
)
cmd
.
Flags
()
.
Int32P
(
"type"
,
"t"
,
1
,
"query type, 1:QueryGamesByIds,2:QueryGameById,3:QueryGameByAddr,4:QueryGameByAddrStatus,5:QueryGameByStatus,6:QueryGameByAdminAddr,7:QueryGameByAddrStatusAddr,8:QueryGameByAdminStatusAddr,9:QueryGameByCategoryStatusAddr"
)
cmd
.
Flags
()
.
StringP
(
"address"
,
"a"
,
""
,
"address"
)
cmd
.
Flags
()
.
StringP
(
"gameId"
,
"g"
,
""
,
"game Id"
)
cmd
.
Flags
()
.
StringP
(
"index"
,
"i"
,
""
,
"index"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"address"
)
cmd
.
Flags
()
.
StringP
(
"status"
,
"s"
,
""
,
"status"
)
cmd
.
Flags
()
.
StringP
(
"adminAddr"
,
"m"
,
""
,
"admin address"
)
cmd
.
Flags
()
.
Int64P
(
"index"
,
"i"
,
0
,
"index"
)
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status"
)
cmd
.
Flags
()
.
StringP
(
"gameIDs"
,
"d"
,
""
,
"gameIDs"
)
cmd
.
Flags
()
.
StringP
(
"gameIDs"
,
"d"
,
""
,
"gameIDs"
)
cmd
.
Flags
()
.
StringP
(
"category"
,
"c"
,
"default"
,
"game category"
)
}
}
func
guessQuery
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessQuery
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
/*
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameID, _ := cmd.Flags().GetString("gameID
")
ty
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"type
"
)
address, _ := cmd.Flags().GetString("address
")
gameId
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId
"
)
statusStr, _ := cmd.Flags().GetString("status
")
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr
"
)
status, _ := strconv.ParseInt(statusStr, 10, 32
)
adminAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"adminAddr"
)
indexstr, _ := cmd.Flags().GetString("index
")
status
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"status
"
)
index, _ :=
strconv.ParseInt(indexstr, 10, 64
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
gameIDs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameIDs"
)
gameIDs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameIDs"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
fmt
.
Println
(
"ooo"
)
var
params
types
.
Query4Cli
var
params
types
.
Query4Cli
params
.
Execer
=
pkt
.
GuessX
params
.
Execer
=
pkt
.
GuessX
req := &pkt.QueryGuessGameInfo{
GameId: gameID,
//query type,
Addr: address,
//1:QueryGamesByIds,
Status: int32(status),
//2:QueryGameById,
Index: index,
//3:QueryGameByAddr,
}
//4:QueryGameByStatus,
params.Payload = req
//5:QueryGameByAdminAddr,
if gameID != "" {
//6:QueryGameByAddrStatus,
//7:QueryGameByAdminStatus,
//8:QueryGameByCategoryStatus,
switch
ty
{
case
1
:
gameIds
:=
strings
.
Split
(
gameIDs
,
";"
)
req
:=
&
pkt
.
QueryGuessGameInfos
{
GameIds
:
gameIds
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGamesByIds
params
.
Payload
=
req
var
res
pkt
.
ReplyGuessGameInfos
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
2
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
GameId
:
gameId
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameById
params
.
FuncName
=
pkt
.
FuncName_QueryGameById
params
.
Payload
=
req
var
res
pkt
.
ReplyGuessGameInfo
var
res
pkt
.
ReplyGuessGameInfo
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
} else if address != "" {
case
3
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
Addr
:
addr
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameByAddr
params
.
FuncName
=
pkt
.
FuncName_QueryGameByAddr
var res pkt.PBGameRecords
params
.
Payload
=
req
var
res
pkt
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
} else if statusStr != "" {
case
4
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameByStatus
params
.
FuncName
=
pkt
.
FuncName_QueryGameByStatus
var res pkt.PBGameRecords
params
.
Payload
=
req
var
res
pkt
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
} else if gameIDs != "" {
params.FuncName = pkt.FuncName_QueryGameListByIds
case
5
:
var gameIDsS []string
req
:=
&
pkt
.
QueryGuessGameInfo
{
gameIDsS = append(gameIDsS, gameIDs)
AdminAddr
:
adminAddr
,
gameIDsS = append(gameIDsS, gameIDs)
Index
:
index
,
req := &pkt.QueryPBGameInfos{gameIDsS}
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameByAdminAddr
params
.
Payload
=
req
params
.
Payload
=
req
var res pkt.ReplyGuessGameInfos
var
res
pkt
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
6
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
Addr
:
addr
,
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameByAddrStatus
params
.
Payload
=
req
var
res
pkt
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
7
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
AdminAddr
:
adminAddr
,
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameByAdminStatus
params
.
Payload
=
req
var
res
pkt
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
case
8
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
Category
:
category
,
Status
:
status
,
Index
:
index
,
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameByCategoryStatus
params
.
Payload
=
req
var
res
pkt
.
GuessGameRecords
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
:=
jsonrpc
.
NewRpcCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
} else {
fmt.Println("Error: requeres at least one of gameID, address or status")
cmd.Help()
}
}
*/
}
}
plugin/dapp/guess/executor/exec_del_local.go
View file @
baf4c3b1
...
@@ -48,7 +48,7 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
...
@@ -48,7 +48,7 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
player
:=
game
.
Plays
[
i
]
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
log
.
GameId
,
player
.
Bet
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
log
.
GameId
,
player
.
Bet
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
Index
)
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
Index
)
)
}
}
}
}
}
}
...
...
plugin/dapp/guess/executor/exec_local.go
View file @
baf4c3b1
...
@@ -47,7 +47,7 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
...
@@ -47,7 +47,7 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
player
:=
game
.
Plays
[
i
]
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
GameId
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
GameId
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
player
.
Bet
.
PreIndex
)
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
player
.
Bet
.
PreIndex
)
)
}
}
}
}
}
}
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
baf4c3b1
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/executor/query.go
View file @
baf4c3b1
...
@@ -30,15 +30,6 @@ func (g *Guess) Query_QueryGameByAddr(in *pkt.QueryGuessGameInfo) (types.Message
...
@@ -30,15 +30,6 @@ func (g *Guess) Query_QueryGameByAddr(in *pkt.QueryGuessGameInfo) (types.Message
return
records
,
nil
return
records
,
nil
}
}
func
(
g
*
Guess
)
Query_QueryGameByAddrStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAddr
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Index
)
if
err
!=
nil
{
return
nil
,
err
}
return
records
,
nil
}
func
(
g
*
Guess
)
Query_QueryGameByStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameByStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByStatus
(
g
.
GetLocalDB
(),
in
.
Status
,
in
.
Index
)
records
,
err
:=
getGameListByStatus
(
g
.
GetLocalDB
(),
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -57,7 +48,7 @@ func (g *Guess) Query_QueryGameByAdminAddr(in *pkt.QueryGuessGameInfo) (types.Me
...
@@ -57,7 +48,7 @@ func (g *Guess) Query_QueryGameByAdminAddr(in *pkt.QueryGuessGameInfo) (types.Me
return
records
,
nil
return
records
,
nil
}
}
func
(
g
*
Guess
)
Query_QueryGameByAddrStatus
Addr
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameByAddrStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAddrStatus
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Status
,
in
.
Index
)
records
,
err
:=
getGameListByAddrStatus
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -66,7 +57,7 @@ func (g *Guess) Query_QueryGameByAddrStatusAddr(in *pkt.QueryGuessGameInfo) (typ
...
@@ -66,7 +57,7 @@ func (g *Guess) Query_QueryGameByAddrStatusAddr(in *pkt.QueryGuessGameInfo) (typ
return
records
,
nil
return
records
,
nil
}
}
func
(
g
*
Guess
)
Query_QueryGameByAdminStatus
Addr
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameByAdminStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAdminStatus
(
g
.
GetLocalDB
(),
in
.
AdminAddr
,
in
.
Status
,
in
.
Index
)
records
,
err
:=
getGameListByAdminStatus
(
g
.
GetLocalDB
(),
in
.
AdminAddr
,
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -75,7 +66,7 @@ func (g *Guess) Query_QueryGameByAdminStatusAddr(in *pkt.QueryGuessGameInfo) (ty
...
@@ -75,7 +66,7 @@ func (g *Guess) Query_QueryGameByAdminStatusAddr(in *pkt.QueryGuessGameInfo) (ty
return
records
,
nil
return
records
,
nil
}
}
func
(
g
*
Guess
)
Query_QueryGameByCategoryStatus
Addr
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameByCategoryStatus
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByCategoryStatus
(
g
.
GetLocalDB
(),
in
.
Category
,
in
.
Status
,
in
.
Index
)
records
,
err
:=
getGameListByCategoryStatus
(
g
.
GetLocalDB
(),
in
.
Category
,
in
.
Status
,
in
.
Index
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
plugin/dapp/guess/proto/guess.proto
View file @
baf4c3b1
...
@@ -14,12 +14,11 @@ message GuessGame {
...
@@ -14,12 +14,11 @@ message GuessGame {
string
topic
=
6
;
//主题
string
topic
=
6
;
//主题
string
category
=
7
;
//分类
string
category
=
7
;
//分类
string
options
=
8
;
//选项
string
options
=
8
;
//选项
string
maxTime
=
9
;
//截止下注时间
string
max
Bet
Time
=
9
;
//截止下注时间
int64
maxHeight
=
10
;
//截止下注的块高
int64
max
Bet
Height
=
10
;
//截止下注的块高
string
symbol
=
11
;
//bty或者具体token
string
symbol
=
11
;
//bty或者具体token
string
exec
=
12
;
//coins或者token
string
exec
=
12
;
//coins或者token
uint32
oneBet
=
13
;
//一注等于多少bty或者token
uint32
maxBetsOneTime
=
14
;
//单次可以下多少注,默认100
uint32
maxBets
=
14
;
//单次可以下多少注,默认100
uint32
maxBetsNumber
=
15
;
//最多可以下多少注
uint32
maxBetsNumber
=
15
;
//最多可以下多少注
int64
devFeeFactor
=
16
;
//开发者抽成比例
int64
devFeeFactor
=
16
;
//开发者抽成比例
string
devFeeAddr
=
17
;
//开发者地址
string
devFeeAddr
=
17
;
//开发者地址
...
@@ -34,6 +33,7 @@ message GuessGame {
...
@@ -34,6 +33,7 @@ message GuessGame {
GuessBetStat
betStat
=
26
;
GuessBetStat
betStat
=
26
;
int64
index
=
27
;
int64
index
=
27
;
int64
preIndex
=
28
;
int64
preIndex
=
28
;
bool
drivenByAdmin
=
29
;
}
}
message
GuessPlayer
{
message
GuessPlayer
{
...
@@ -80,12 +80,11 @@ message GuessGameStart{
...
@@ -80,12 +80,11 @@ message GuessGameStart{
string
topic
=
1
;
string
topic
=
1
;
string
options
=
2
;
string
options
=
2
;
string
category
=
3
;
string
category
=
3
;
string
maxTime
=
4
;
string
max
Bet
Time
=
4
;
int64
maxHeight
=
5
;
int64
max
Bet
Height
=
5
;
string
symbol
=
6
;
string
symbol
=
6
;
string
exec
=
7
;
string
exec
=
7
;
uint32
oneBet
=
8
;
uint32
maxBetsOneTime
=
9
;
uint32
maxBets
=
9
;
uint32
maxBetsNumber
=
10
;
uint32
maxBetsNumber
=
10
;
int64
devFeeFactor
=
11
;
//开发者抽成比例
int64
devFeeFactor
=
11
;
//开发者抽成比例
string
devFeeAddr
=
12
;
//开发者地址
string
devFeeAddr
=
12
;
//开发者地址
...
@@ -93,7 +92,7 @@ message GuessGameStart{
...
@@ -93,7 +92,7 @@ message GuessGameStart{
string
platFeeAddr
=
14
;
//平台地址
string
platFeeAddr
=
14
;
//平台地址
string
expire
=
15
;
string
expire
=
15
;
int64
expireHeight
=
16
;
int64
expireHeight
=
16
;
int64
fee
=
17
;
bool
drivenByAdmin
=
17
;
}
}
//参与游戏下注
//参与游戏下注
...
@@ -101,33 +100,28 @@ message GuessGameBet{
...
@@ -101,33 +100,28 @@ message GuessGameBet{
string
gameId
=
1
;
string
gameId
=
1
;
string
option
=
2
;
string
option
=
2
;
uint32
betsNum
=
3
;
uint32
betsNum
=
3
;
int64
fee
=
4
;
}
}
//游戏停止下注
//游戏停止下注
message
GuessGameStopBet
{
message
GuessGameStopBet
{
string
gameId
=
1
;
string
gameId
=
1
;
int64
fee
=
2
;
}
}
//游戏异常终止,退还下注
//游戏异常终止,退还下注
message
GuessGameAbort
{
message
GuessGameAbort
{
string
gameId
=
1
;
string
gameId
=
1
;
int64
fee
=
2
;
}
}
//游戏结果揭晓
//游戏结果揭晓
message
GuessGamePublish
{
message
GuessGamePublish
{
string
gameId
=
1
;
string
gameId
=
1
;
string
result
=
2
;
string
result
=
2
;
int64
fee
=
3
;
}
}
//查询游戏结果
//查询游戏结果
message
GuessGameQuery
{
message
GuessGameQuery
{
string
gameId
=
1
;
string
gameId
=
1
;
uint32
ty
=
2
;
uint32
ty
=
2
;
int64
fee
=
3
;
}
}
...
@@ -168,20 +162,19 @@ message GuessStartTxReq {
...
@@ -168,20 +162,19 @@ message GuessStartTxReq {
string
topic
=
1
;
string
topic
=
1
;
string
options
=
2
;
string
options
=
2
;
int64
startTime
=
3
;
int64
startTime
=
3
;
string
maxTime
=
4
;
string
max
Bet
Time
=
4
;
uint32
max
Height
=
5
;
int64
maxBet
Height
=
5
;
string
symbol
=
6
;
string
symbol
=
6
;
string
exec
=
7
;
string
exec
=
7
;
uint32
oneBet
=
8
;
uint32
maxBetsOneTime
=
8
;
uint32
maxBets
=
9
;
uint32
maxBetsNumber
=
9
;
uint32
maxBetsNumber
=
10
;
int64
devFeeFactor
=
10
;
int64
devFeeFactor
=
11
;
string
devFeeAddr
=
11
;
string
devFeeAddr
=
12
;
int64
platFeeFactor
=
12
;
int64
platFeeFactor
=
13
;
string
platFeeAddr
=
13
;
string
platFeeAddr
=
14
;
string
feeAddr
=
14
;
string
feeAddr
=
15
;
string
expire
=
15
;
string
expire
=
16
;
int64
expireHeight
=
16
;
uint32
expireHeight
=
17
;
}
}
message
GuessBetTxReq
{
message
GuessBetTxReq
{
...
...
plugin/dapp/guess/rpc/jrpc.go
View file @
baf4c3b1
...
@@ -19,16 +19,18 @@ func (c *Jrpc) GuessStartTx(parm *pb.GuessStartTxReq, result *interface{}) error
...
@@ -19,16 +19,18 @@ func (c *Jrpc) GuessStartTx(parm *pb.GuessStartTxReq, result *interface{}) error
head
:=
&
pb
.
GuessGameStart
{
head
:=
&
pb
.
GuessGameStart
{
Topic
:
parm
.
Topic
,
Topic
:
parm
.
Topic
,
Options
:
parm
.
Options
,
Options
:
parm
.
Options
,
MaxHeight
:
parm
.
MaxHeight
,
MaxBetTime
:
parm
.
MaxBetTime
,
MaxBetHeight
:
parm
.
MaxBetHeight
,
Symbol
:
parm
.
Symbol
,
Symbol
:
parm
.
Symbol
,
Exec
:
parm
.
Exec
,
Exec
:
parm
.
Exec
,
OneBet
:
parm
.
OneBet
,
MaxBetsOneTime
:
parm
.
MaxBetsOneTime
,
MaxBets
:
parm
.
MaxBets
,
MaxBetsNumber
:
parm
.
MaxBetsNumber
,
MaxBetsNumber
:
parm
.
MaxBetsNumber
,
DevFeeFactor
:
parm
.
DevFeeFactor
,
DevFeeFactor
:
parm
.
DevFeeFactor
,
DevFeeAddr
:
parm
.
DevFeeAddr
,
DevFeeAddr
:
parm
.
DevFeeAddr
,
PlatFeeFactor
:
parm
.
PlatFeeFactor
,
PlatFeeFactor
:
parm
.
PlatFeeFactor
,
PlatFeeAddr
:
parm
.
PlatFeeAddr
,
PlatFeeAddr
:
parm
.
PlatFeeAddr
,
Expire
:
parm
.
Expire
,
ExpireHeight
:
parm
.
ExpireHeight
,
}
}
reply
,
err
:=
c
.
cli
.
GuessStart
(
context
.
Background
(),
head
)
reply
,
err
:=
c
.
cli
.
GuessStart
(
context
.
Background
(),
head
)
...
...
plugin/dapp/guess/types/const.go
View file @
baf4c3b1
...
@@ -46,12 +46,14 @@ var (
...
@@ -46,12 +46,14 @@ var (
const
(
const
(
//查询方法名
//查询方法名
FuncName_QueryGameListByIds
=
"QueryGameListByIds"
FuncName_QueryGamesByIds
=
"QueryGamesByIds"
FuncName_QueryGameById
=
"QueryGameById"
FuncName_QueryGameById
=
"QueryGameById"
FuncName_QueryGameByAddr
=
"QueryGameByAddr"
FuncName_QueryGameByAddr
=
"QueryGameByAddr"
FuncName_QueryGameByStatus
=
"QueryGameByStatus"
FuncName_QueryGameByStatus
=
"QueryGameByStatus"
//FuncName_QueryGameByAdminAddr = "QueryGameByAdminAddr"
FuncName_QueryGameByAdminAddr
=
"QueryGameByAdminAddr"
//FuncName_QueryGameByCategory = "QueryGameByCategory"
FuncName_QueryGameByAddrStatus
=
"QueryGameByAddrStatus"
FuncName_QueryGameByAdminStatus
=
"QueryGameByAdminStatus"
FuncName_QueryGameByCategoryStatus
=
"QueryGameByCategoryStatus"
)
)
const
(
const
(
...
...
plugin/dapp/guess/types/errors.go
0 → 100755
View file @
baf4c3b1
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
types
import
"errors"
// Errors for lottery
var
(
ErrNoPrivilege
=
errors
.
New
(
"ErrNoPrivilege"
)
ErrGuessStatus
=
errors
.
New
(
"ErrGuessStatus"
)
)
plugin/dapp/guess/types/guess.pb.go
View file @
baf4c3b1
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/
rpc
/tx.go
→
plugin/dapp/guess/
types
/tx.go
View file @
baf4c3b1
...
@@ -2,17 +2,16 @@
...
@@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
rpc
package
types
type
GuessGameStart
struct
{
type
GuessGameStart
Tx
struct
{
Topic
string
`json:"topic,omitempty"`
Topic
string
`json:"topic,omitempty"`
Options
string
`json:"options,omitempty"`
Options
string
`json:"options,omitempty"`
Category
string
`json:"category,omitempty"`
Category
string
`json:"category,omitempty"`
MaxTime
string
`json:"maxTime,omitempty"`
Max
Bet
Time
string
`json:"maxTime,omitempty"`
MaxHeight
int64
`json:"maxHeight,omitempty"`
Max
Bet
Height
int64
`json:"maxHeight,omitempty"`
Symbol
string
`json:"symbol,omitempty"`
Symbol
string
`json:"symbol,omitempty"`
Exec
string
`json:"exec,omitempty"`
Exec
string
`json:"exec,omitempty"`
OneBet
uint32
`json:"oneBet,omitempty"`
MaxBets
uint32
`json:"maxBets,omitempty"`
MaxBets
uint32
`json:"maxBets,omitempty"`
MaxBetsNumber
uint32
`json:"maxBetsNumber,omitempty"`
MaxBetsNumber
uint32
`json:"maxBetsNumber,omitempty"`
DevFeeFactor
int64
`json:"devFeeFactor,omitempty"`
DevFeeFactor
int64
`json:"devFeeFactor,omitempty"`
...
@@ -24,25 +23,25 @@ type GuessGameStart struct {
...
@@ -24,25 +23,25 @@ type GuessGameStart struct {
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
type
GuessGameBet
struct
{
type
GuessGameBet
Tx
struct
{
GameId
string
`json:"gameId,omitempty"`
GameId
string
`json:"gameId,omitempty"`
Option
string
`json:"option,omitempty"`
Option
string
`json:"option,omitempty"`
BetsNum
uint32
`json:"betsNum,omitempty"`
BetsNum
uint32
`json:"betsNum,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
type
GuessGameStopBet
struct
{
type
GuessGameStopBet
Tx
struct
{
GameId
string
`json:"gameId,omitempty"`
GameId
string
`json:"gameId,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
type
GuessGamePublish
struct
{
type
GuessGamePublish
Tx
struct
{
GameId
string
`json:"gameId,omitempty"`
GameId
string
`json:"gameId,omitempty"`
Result
string
`json:"result,omitempty"`
Result
string
`json:"result,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
type
GuessGameAbort
struct
{
type
GuessGameAbort
Tx
struct
{
GameId
string
`json:"gameId,omitempty"`
GameId
string
`json:"gameId,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
plugin/dapp/guess/types/types.go
View file @
baf4c3b1
...
@@ -66,7 +66,7 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
...
@@ -66,7 +66,7 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
llog
.
Debug
(
"Guess.CreateTx"
,
"action"
,
action
)
llog
.
Debug
(
"Guess.CreateTx"
,
"action"
,
action
)
if
action
==
"GuessStart"
{
if
action
==
"GuessStart"
{
var
param
Guess
StartTxReq
var
param
Guess
GameStartTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
llog
.
Error
(
"CreateTx.GuessStart"
,
"Error"
,
err
)
llog
.
Error
(
"CreateTx.GuessStart"
,
"Error"
,
err
)
...
@@ -74,15 +74,23 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
...
@@ -74,15 +74,23 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
}
}
return
CreateRawGuessStartTx
(
&
param
)
return
CreateRawGuessStartTx
(
&
param
)
}
else
if
action
==
"GuessBet"
{
}
else
if
action
==
"GuessBet"
{
var
param
Guess
BetTxReq
var
param
Guess
GameBetTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
llog
.
Error
(
"CreateTx.GuessBet"
,
"Error"
,
err
)
llog
.
Error
(
"CreateTx.GuessBet"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
return
CreateRawGuessBetTx
(
&
param
)
return
CreateRawGuessBetTx
(
&
param
)
}
else
if
action
==
"GuessStopBet"
{
var
param
GuessGameStopBetTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
llog
.
Error
(
"CreateTx.GuessStopBet"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawGuessStopBetTx
(
&
param
)
}
else
if
action
==
"GuessPublish"
{
}
else
if
action
==
"GuessPublish"
{
var
param
Guess
PublishTxReq
var
param
Guess
GamePublishTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
llog
.
Error
(
"CreateTx.GuessPublish"
,
"Error"
,
err
)
llog
.
Error
(
"CreateTx.GuessPublish"
,
"Error"
,
err
)
...
@@ -90,7 +98,7 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
...
@@ -90,7 +98,7 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
}
}
return
CreateRawGuessPublishTx
(
&
param
)
return
CreateRawGuessPublishTx
(
&
param
)
}
else
if
action
==
"GuessAbort"
{
}
else
if
action
==
"GuessAbort"
{
var
param
Guess
AbortTxReq
var
param
Guess
GameAbortTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
llog
.
Error
(
"CreateTx.GuessAbort"
,
"Error"
,
err
)
llog
.
Error
(
"CreateTx.GuessAbort"
,
"Error"
,
err
)
...
@@ -103,15 +111,33 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
...
@@ -103,15 +111,33 @@ func (t *GuessType) CreateTx(action string, message json.RawMessage) (*types.Tra
}
}
// CreateRawLotteryCreateTx method
// CreateRawLotteryCreateTx method
func
CreateRawGuessStartTx
(
parm
*
GuessGameStart
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawGuessStartTx
(
parm
*
GuessGameStart
Tx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawGuessStartTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawGuessStartTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
v
:=
&
GuessGameStart
{
Topic
:
parm
.
Topic
,
Options
:
parm
.
Options
,
Category
:
parm
.
Category
,
MaxBetTime
:
parm
.
MaxBetTime
,
MaxBetHeight
:
parm
.
MaxBetHeight
,
Symbol
:
parm
.
Symbol
,
Exec
:
parm
.
Exec
,
MaxBetsOneTime
:
parm
.
MaxBets
,
MaxBetsNumber
:
parm
.
MaxBetsNumber
,
DevFeeFactor
:
parm
.
DevFeeFactor
,
DevFeeAddr
:
parm
.
DevFeeAddr
,
PlatFeeFactor
:
parm
.
PlatFeeFactor
,
PlatFeeAddr
:
parm
.
PlatFeeAddr
,
Expire
:
parm
.
Expire
,
ExpireHeight
:
parm
.
ExpireHeight
,
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
Ty
:
GuessGameActionStart
,
Ty
:
GuessGameActionStart
,
Value
:
&
GuessGameAction_Start
{
Start
:
parm
},
Value
:
&
GuessGameAction_Start
{
Start
:
v
},
}
}
name
:=
types
.
ExecName
(
GuessX
)
name
:=
types
.
ExecName
(
GuessX
)
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
@@ -129,15 +155,20 @@ func CreateRawGuessStartTx(parm *GuessGameStart) (*types.Transaction, error) {
...
@@ -129,15 +155,20 @@ func CreateRawGuessStartTx(parm *GuessGameStart) (*types.Transaction, error) {
}
}
// CreateRawGuessBetTx method
// CreateRawGuessBetTx method
func
CreateRawGuessBetTx
(
parm
*
GuessGameBet
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawGuessBetTx
(
parm
*
GuessGameBet
Tx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawGuessBet"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawGuessBet"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
v
:=
&
GuessGameBet
{
GameId
:
parm
.
GameId
,
Option
:
parm
.
Option
,
BetsNum
:
parm
.
BetsNum
,
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
Ty
:
GuessGameActionBet
,
Ty
:
GuessGameActionBet
,
Value
:
&
GuessGameAction_Bet
{
Bet
:
parm
},
Value
:
&
GuessGameAction_Bet
{
Bet
:
v
},
}
}
name
:=
types
.
ExecName
(
GuessX
)
name
:=
types
.
ExecName
(
GuessX
)
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
@@ -155,15 +186,18 @@ func CreateRawGuessBetTx(parm *GuessGameBet) (*types.Transaction, error) {
...
@@ -155,15 +186,18 @@ func CreateRawGuessBetTx(parm *GuessGameBet) (*types.Transaction, error) {
}
}
// CreateRawGuessStopBetTx method
// CreateRawGuessStopBetTx method
func
CreateRawGuess
BetTx
(
parm
*
GuessGameStopBet
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawGuess
StopBetTx
(
parm
*
GuessGameStopBetTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawGuessBet"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawGuessBet"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
v
:=
&
GuessGameStopBet
{
GameId
:
parm
.
GameId
,
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
Ty
:
GuessGameActionStopBet
,
Ty
:
GuessGameActionStopBet
,
Value
:
&
GuessGameAction_StopBet
{
StopBet
:
parm
},
Value
:
&
GuessGameAction_StopBet
{
StopBet
:
v
},
}
}
name
:=
types
.
ExecName
(
GuessX
)
name
:=
types
.
ExecName
(
GuessX
)
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
@@ -181,15 +215,20 @@ func CreateRawGuessBetTx(parm *GuessGameStopBet) (*types.Transaction, error) {
...
@@ -181,15 +215,20 @@ func CreateRawGuessBetTx(parm *GuessGameStopBet) (*types.Transaction, error) {
}
}
// CreateRawGuessPublishTx method
// CreateRawGuessPublishTx method
func
CreateRawGuessPublishTx
(
parm
*
GuessGamePublish
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawGuessPublishTx
(
parm
*
GuessGamePublish
Tx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawGuessPublish"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawGuessPublish"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
v
:=
&
GuessGamePublish
{
GameId
:
parm
.
GameId
,
Result
:
parm
.
Result
,
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
Ty
:
GuessGameActionPublish
,
Ty
:
GuessGameActionPublish
,
Value
:
&
GuessGameAction_Publish
{
Publish
:
parm
},
Value
:
&
GuessGameAction_Publish
{
Publish
:
v
},
}
}
name
:=
types
.
ExecName
(
GuessX
)
name
:=
types
.
ExecName
(
GuessX
)
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
@@ -207,15 +246,19 @@ func CreateRawGuessPublishTx(parm *GuessGamePublish) (*types.Transaction, error)
...
@@ -207,15 +246,19 @@ func CreateRawGuessPublishTx(parm *GuessGamePublish) (*types.Transaction, error)
}
}
// CreateRawGuessAbortTx method
// CreateRawGuessAbortTx method
func
CreateRawGuessAbortTx
(
parm
*
GuessGameAbort
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawGuessAbortTx
(
parm
*
GuessGameAbort
Tx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
if
parm
==
nil
{
llog
.
Error
(
"CreateRawGuessAbortTx"
,
"parm"
,
parm
)
llog
.
Error
(
"CreateRawGuessAbortTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
v
:=
&
GuessGameAbort
{
GameId
:
parm
.
GameId
,
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
Ty
:
GuessGameActionAbort
,
Ty
:
GuessGameActionAbort
,
Value
:
&
GuessGameAction_Abort
{
Abort
:
parm
},
Value
:
&
GuessGameAction_Abort
{
Abort
:
v
},
}
}
name
:=
types
.
ExecName
(
GuessX
)
name
:=
types
.
ExecName
(
GuessX
)
tx
:=
&
types
.
Transaction
{
tx
:=
&
types
.
Transaction
{
...
...
plugin/dapp/init/init.go
View file @
baf4c3b1
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
_
"github.com/33cn/plugin/plugin/dapp/cert"
_
"github.com/33cn/plugin/plugin/dapp/cert"
_
"github.com/33cn/plugin/plugin/dapp/evm"
_
"github.com/33cn/plugin/plugin/dapp/evm"
_
"github.com/33cn/plugin/plugin/dapp/game"
_
"github.com/33cn/plugin/plugin/dapp/game"
_
"github.com/33cn/plugin/plugin/dapp/guess"
_
"github.com/33cn/plugin/plugin/dapp/hashlock"
_
"github.com/33cn/plugin/plugin/dapp/hashlock"
_
"github.com/33cn/plugin/plugin/dapp/lottery"
_
"github.com/33cn/plugin/plugin/dapp/lottery"
_
"github.com/33cn/plugin/plugin/dapp/norm"
_
"github.com/33cn/plugin/plugin/dapp/norm"
...
...
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