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
96391f7b
Commit
96391f7b
authored
Dec 17, 2018
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
0420e49a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
212 additions
and
208 deletions
+212
-208
game.go
plugin/dapp/guess/commands/game.go
+24
-20
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+65
-86
guess.proto
plugin/dapp/guess/proto/guess.proto
+42
-49
jrpc.go
plugin/dapp/guess/rpc/jrpc.go
+4
-33
rpc.go
plugin/dapp/guess/rpc/rpc.go
+77
-12
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+0
-0
tx.go
plugin/dapp/guess/types/tx.go
+0
-4
types.go
plugin/dapp/guess/types/types.go
+0
-4
No files found.
plugin/dapp/guess/commands/game.go
View file @
96391f7b
...
...
@@ -48,12 +48,11 @@ func addGuessStartFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"options"
,
"o"
,
""
,
"options"
)
cmd
.
MarkFlagRequired
(
"options"
)
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
()
.
StringP
(
"symbol"
,
"s"
,
"bty"
,
"token symbol"
)
cmd
.
Flags
()
.
StringP
(
"exec"
,
"e"
,
"coins"
,
"excutor name"
)
cmd
.
Flags
()
.
StringP
(
"category"
,
"c"
,
"default"
,
"options"
)
cmd
.
Flags
()
.
Int64P
(
"maxBetsOneTime"
,
"m"
,
10000
,
"max bets one time"
)
cmd
.
Flags
()
.
Int64P
(
"maxBetHeight"
,
"m"
,
0
,
"max height to bet, after this bet is forbidden"
)
cmd
.
Flags
()
.
Int64P
(
"maxBetsOneTime"
,
"s"
,
10000
,
"max bets one time"
)
//cmd.MarkFlagRequired("maxBets")
cmd
.
Flags
()
.
Int64P
(
"maxBetsNumber"
,
"n"
,
100000
,
"max bets number"
)
...
...
@@ -67,43 +66,39 @@ func addGuessStartFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"platFeeAddr"
,
"q"
,
""
,
"plat address to receive share"
)
cmd
.
Flags
()
.
StringP
(
"expire"
,
"x"
,
""
,
"expire time
of the game, after this any addr can abort it"
)
cmd
.
Flags
()
.
Int64P
(
"expireHeight"
,
"e"
,
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
"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"g"
,
0.01
,
"tx fee
"
)
}
func
guessStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
topic
,
_
:=
cmd
.
Flags
()
.
GetString
(
"topic"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
options
,
_
:=
cmd
.
Flags
()
.
GetString
(
"options"
)
maxBetTime
,
_
:=
cmd
.
Flags
()
.
GetString
(
"maxBetTime"
)
maxBetHeight
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"maxBetHeight"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
maxBets
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"maxBets"
)
maxBetsOneTime
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"maxBetsOneTime"
)
maxBetsNumber
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"maxBetsNumber"
)
devFeeFactor
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"devFeeFactor"
)
devFeeAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"devFeeAddr"
)
platFeeFactor
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"platFeeFactor"
)
platFeeAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"platFeeAddr"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetString
(
"expire"
)
expireHeight
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expireHeight"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessStartTxReq
{
Topic
:
topic
,
Options
:
options
,
MaxBetTime
:
maxBetTime
,
Category
:
category
,
MaxBetHeight
:
maxBetHeight
,
Symbol
:
symbol
,
Exec
:
exec
,
MaxBetsOneTime
:
maxBets
,
MaxBetsNumber
:
maxBetsNumber
,
MaxBetsOneTime
:
maxBetsOneTime
*
1e8
,
MaxBetsNumber
:
maxBetsNumber
*
1e8
,
DevFeeFactor
:
devFeeFactor
,
DevFeeAddr
:
devFeeAddr
,
PlatFeeFactor
:
platFeeFactor
,
PlatFeeAddr
:
platFeeAddr
,
Expire
:
expire
,
ExpireHeight
:
expireHeight
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
var
res
string
...
...
@@ -128,6 +123,7 @@ func addGuessBetFlags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"option"
)
cmd
.
Flags
()
.
Int64P
(
"betsNumber"
,
"b"
,
1
,
"bets number for one option in a guess game"
)
cmd
.
MarkFlagRequired
(
"betsNumber"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
0.01
,
"tx fee"
)
}
func
guessBet
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
@@ -135,11 +131,13 @@ func guessBet(cmd *cobra.Command, args []string) {
gameId
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
option
,
_
:=
cmd
.
Flags
()
.
GetString
(
"option"
)
betsNumber
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"betsNumber"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessBetTxReq
{
GameId
:
gameId
,
Option
:
option
,
Bets
:
betsNumber
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
var
res
string
...
...
@@ -160,14 +158,16 @@ func GuessAbortRawTxCmd() *cobra.Command {
func
addGuessAbortFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"gameId"
,
"g"
,
""
,
"game Id"
)
cmd
.
MarkFlagRequired
(
"gameId"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
0.01
,
"tx fee"
)
}
func
guessAbort
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameId
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessAbortTxReq
{
GameId
:
gameId
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
var
res
string
...
...
@@ -191,16 +191,20 @@ func addGuessPublishFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"result"
,
"r"
,
""
,
"result of a guess game"
)
cmd
.
MarkFlagRequired
(
"result"
)
cmd
.
Flags
()
.
Float64P
(
"fee"
,
"f"
,
0.01
,
"tx fee"
)
}
func
guessPublish
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
gameId
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
result
,
_
:=
cmd
.
Flags
()
.
GetString
(
"result"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessPublishTxReq
{
GameId
:
gameId
,
Result
:
result
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
var
res
string
...
...
@@ -220,7 +224,7 @@ func GuessQueryRawTxCmd() *cobra.Command {
}
func
addGuessQueryFlags
(
cmd
*
cobra
.
Command
)
{
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
()
.
Int32P
(
"type"
,
"t"
,
1
,
"query type, 1:
Ids,2:Id,3:Addr,4:Status,5:AdminAddr,6:AddrStatus,7:AdminStatus,8:CategoryStatus
"
)
cmd
.
Flags
()
.
StringP
(
"gameId"
,
"g"
,
""
,
"game Id"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"address"
)
cmd
.
Flags
()
.
StringP
(
"adminAddr"
,
"m"
,
""
,
"admin address"
)
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
96391f7b
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/proto/guess.proto
View file @
96391f7b
...
...
@@ -10,30 +10,27 @@ message GuessGame {
int32
status
=
2
;
//游戏的状态:创建->投注->截止投注->开奖
int32
preStatus
=
3
;
int64
startTime
=
4
;
//创建游戏的时间
string
startTxHash
=
5
;
//创建游戏的交易hash
string
topic
=
6
;
//主题
string
category
=
7
;
//分类
string
options
=
8
;
//选项
string
maxBetTime
=
9
;
//截止下注时间
int64
startHeight
=
5
;
//创建游戏的时间
string
startTxHash
=
6
;
//创建游戏的交易hash
string
topic
=
7
;
//主题
string
category
=
8
;
//分类
string
options
=
9
;
//选项
int64
maxBetHeight
=
10
;
//截止下注的块高
string
symbol
=
11
;
//bty或者具体token
string
exec
=
12
;
//coins或者token
int64
maxBetsOneTime
=
14
;
//单次可以下多少注,默认100
int64
maxBetsNumber
=
15
;
//最多可以下多少注
int64
devFeeFactor
=
16
;
//开发者抽成比例
string
devFeeAddr
=
17
;
//开发者地址
int64
platFeeFactor
=
18
;
//平台抽成比例
string
platFeeAddr
=
19
;
//平台地址
string
expire
=
20
;
//游戏过期时间
int64
expireHeight
=
21
;
//游戏过期区块高度
string
adminAddr
=
22
;
//游戏创建者地址,只有该地址可以开奖
int64
betsNumber
=
23
;
//已下注数,如果数量达到maxBetsNumber,则不允许再下注
repeated
GuessPlayer
plays
=
24
;
//参与游戏下注的玩家投注信息
string
result
=
25
;
//公布的中奖结果
GuessBetStat
betStat
=
26
;
int64
index
=
27
;
int64
preIndex
=
28
;
bool
drivenByAdmin
=
29
;
int64
maxBetsOneTime
=
11
;
//单次可以下多少注,默认100
int64
maxBetsNumber
=
12
;
//最多可以下多少注
int64
devFeeFactor
=
13
;
//开发者抽成比例
string
devFeeAddr
=
14
;
//开发者地址
int64
platFeeFactor
=
15
;
//平台抽成比例
string
platFeeAddr
=
16
;
//平台地址
int64
expireHeight
=
17
;
//游戏过期区块高度
string
adminAddr
=
18
;
//游戏创建者地址,只有该地址可以开奖
int64
betsNumber
=
19
;
//已下注数,如果数量达到maxBetsNumber,则不允许再下注
repeated
GuessPlayer
plays
=
20
;
//参与游戏下注的玩家投注信息
string
result
=
21
;
//公布的中奖结果
GuessBetStat
betStat
=
22
;
int64
index
=
23
;
int64
preIndex
=
24
;
bool
drivenByAdmin
=
25
;
}
message
GuessPlayer
{
...
...
@@ -80,19 +77,15 @@ message GuessGameStart{
string
topic
=
1
;
string
options
=
2
;
string
category
=
3
;
string
maxBetTime
=
4
;
int64
maxBetHeight
=
5
;
string
symbol
=
6
;
string
exec
=
7
;
int64
maxBetsOneTime
=
9
;
int64
maxBetsNumber
=
10
;
int64
devFeeFactor
=
11
;
//开发者抽成比例
string
devFeeAddr
=
12
;
//开发者地址
int64
platFeeFactor
=
13
;
//平台抽成比例
string
platFeeAddr
=
14
;
//平台地址
string
expire
=
15
;
int64
expireHeight
=
16
;
bool
drivenByAdmin
=
17
;
int64
maxBetHeight
=
4
;
int64
maxBetsOneTime
=
5
;
int64
maxBetsNumber
=
6
;
int64
devFeeFactor
=
7
;
//开发者抽成比例
string
devFeeAddr
=
8
;
//开发者地址
int64
platFeeFactor
=
9
;
//平台抽成比例
string
platFeeAddr
=
10
;
//平台地址
int64
expireHeight
=
11
;
bool
drivenByAdmin
=
12
;
}
//参与游戏下注
...
...
@@ -161,35 +154,35 @@ message ReceiptGuessGame {
message
GuessStartTxReq
{
string
topic
=
1
;
string
options
=
2
;
int64
startTime
=
3
;
string
maxBetTime
=
4
;
string
category
=
3
;
int64
maxHeight
=
4
;
int64
maxBetHeight
=
5
;
string
symbol
=
6
;
string
exec
=
7
;
int64
maxBetsOneTime
=
8
;
int64
maxBetsNumber
=
9
;
int64
devFeeFactor
=
10
;
string
devFeeAddr
=
11
;
int64
platFeeFactor
=
12
;
string
platFeeAddr
=
13
;
string
feeAddr
=
14
;
string
expire
=
15
;
int64
expireHeight
=
16
;
int64
maxBetsOneTime
=
6
;
int64
maxBetsNumber
=
7
;
int64
devFeeFactor
=
8
;
string
devFeeAddr
=
9
;
int64
platFeeFactor
=
10
;
string
platFeeAddr
=
11
;
int64
expireHeight
=
12
;
int64
fee
=
13
;
}
message
GuessBetTxReq
{
string
gameId
=
1
;
string
option
=
2
;
int64
bets
=
3
;
int64
fee
=
4
;
}
message
GuessAbortTxReq
{
string
gameId
=
1
;
int64
fee
=
2
;
}
message
GuessPublishTxReq
{
string
gameId
=
1
;
string
result
=
2
;
int64
fee
=
3
;
}
// 索引value值
...
...
plugin/dapp/guess/rpc/jrpc.go
View file @
96391f7b
...
...
@@ -16,24 +16,8 @@ func (c *Jrpc) GuessStartTx(parm *pb.GuessStartTxReq, result *interface{}) error
if
parm
==
nil
{
return
types
.
ErrInvalidParam
}
head
:=
&
pb
.
GuessGameStart
{
Topic
:
parm
.
Topic
,
Options
:
parm
.
Options
,
MaxBetTime
:
parm
.
MaxBetTime
,
MaxBetHeight
:
parm
.
MaxBetHeight
,
Symbol
:
parm
.
Symbol
,
Exec
:
parm
.
Exec
,
MaxBetsOneTime
:
parm
.
MaxBetsOneTime
,
MaxBetsNumber
:
parm
.
MaxBetsNumber
,
DevFeeFactor
:
parm
.
DevFeeFactor
,
DevFeeAddr
:
parm
.
DevFeeAddr
,
PlatFeeFactor
:
parm
.
PlatFeeFactor
,
PlatFeeAddr
:
parm
.
PlatFeeAddr
,
Expire
:
parm
.
Expire
,
ExpireHeight
:
parm
.
ExpireHeight
,
}
reply
,
err
:=
c
.
cli
.
GuessStart
(
context
.
Background
(),
head
)
reply
,
err
:=
c
.
cli
.
GuessStart
(
context
.
Background
(),
parm
)
if
err
!=
nil
{
return
err
}
...
...
@@ -46,13 +30,7 @@ func (c *Jrpc) GuessBetTx(parm *pb.GuessBetTxReq, result *interface{}) error {
return
types
.
ErrInvalidParam
}
head
:=
&
pb
.
GuessGameBet
{
GameId
:
parm
.
GameId
,
Option
:
parm
.
Option
,
BetsNum
:
parm
.
Bets
,
}
reply
,
err
:=
c
.
cli
.
GuessBet
(
context
.
Background
(),
head
)
reply
,
err
:=
c
.
cli
.
GuessBet
(
context
.
Background
(),
parm
)
if
err
!=
nil
{
return
err
}
...
...
@@ -66,10 +44,7 @@ func (c *Jrpc) GuessAbortTx(parm *pb.GuessAbortTxReq, result *interface{}) error
return
types
.
ErrInvalidParam
}
head
:=
&
pb
.
GuessGameAbort
{
GameId
:
parm
.
GameId
,
}
reply
,
err
:=
c
.
cli
.
GuessAbort
(
context
.
Background
(),
head
)
reply
,
err
:=
c
.
cli
.
GuessAbort
(
context
.
Background
(),
parm
)
if
err
!=
nil
{
return
err
}
...
...
@@ -83,11 +58,7 @@ func (c *Jrpc) GuessPublishTx(parm *pb.GuessPublishTxReq, result *interface{}) e
return
types
.
ErrInvalidParam
}
head
:=
&
pb
.
GuessGamePublish
{
GameId
:
parm
.
GameId
,
Result
:
parm
.
Result
,
}
reply
,
err
:=
c
.
cli
.
GuessPublish
(
context
.
Background
(),
head
)
reply
,
err
:=
c
.
cli
.
GuessPublish
(
context
.
Background
(),
parm
)
if
err
!=
nil
{
return
err
}
...
...
plugin/dapp/guess/rpc/rpc.go
View file @
96391f7b
...
...
@@ -6,16 +6,40 @@ package rpc
import
(
"context"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types"
pb
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
func
(
c
*
channelClient
)
GuessStart
(
ctx
context
.
Context
,
head
*
pb
.
GuessGameStart
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessStart
(
ctx
context
.
Context
,
parm
*
pb
.
GuessStartTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGameStart
{
Topic
:
parm
.
Topic
,
Options
:
parm
.
Options
,
Category
:
parm
.
Category
,
MaxBetHeight
:
parm
.
MaxBetHeight
,
MaxBetsOneTime
:
parm
.
MaxBetsOneTime
,
MaxBetsNumber
:
parm
.
MaxBetsNumber
,
DevFeeFactor
:
parm
.
DevFeeFactor
,
DevFeeAddr
:
parm
.
DevFeeAddr
,
PlatFeeFactor
:
parm
.
PlatFeeFactor
,
PlatFeeAddr
:
parm
.
PlatFeeAddr
,
ExpireHeight
:
parm
.
ExpireHeight
,
}
val
:=
&
pb
.
GuessGameAction
{
Ty
:
pb
.
GuessGameActionStart
,
Value
:
&
pb
.
GuessGameAction_Start
{
head
},
Value
:
&
pb
.
GuessGameAction_Start
{
v
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
GuessX
,
types
.
Encode
(
val
))
name
:=
types
.
ExecName
(
pb
.
GuessX
)
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
pb
.
GuessX
)),
Payload
:
types
.
Encode
(
val
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
name
),
}
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -23,12 +47,27 @@ func (c *channelClient) GuessStart(ctx context.Context, head *pb.GuessGameStart)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
func
(
c
*
channelClient
)
GuessBet
(
ctx
context
.
Context
,
head
*
pb
.
GuessGameBet
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessBet
(
ctx
context
.
Context
,
parm
*
pb
.
GuessBetTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGameBet
{
GameId
:
parm
.
GameId
,
Option
:
parm
.
Option
,
BetsNum
:
parm
.
Bets
,
}
val
:=
&
pb
.
GuessGameAction
{
Ty
:
pb
.
GuessGameActionBet
,
Value
:
&
pb
.
GuessGameAction_Bet
{
head
},
Value
:
&
pb
.
GuessGameAction_Bet
{
v
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
GuessX
,
types
.
Encode
(
val
))
name
:=
types
.
ExecName
(
pb
.
GuessX
)
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
pb
.
GuessX
)),
Payload
:
types
.
Encode
(
val
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
name
),
}
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -36,12 +75,24 @@ func (c *channelClient) GuessBet(ctx context.Context, head *pb.GuessGameBet) (*t
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
func
(
c
*
channelClient
)
GuessAbort
(
ctx
context
.
Context
,
head
*
pb
.
GuessGameAbort
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessAbort
(
ctx
context
.
Context
,
parm
*
pb
.
GuessAbortTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGameAbort
{
GameId
:
parm
.
GameId
,
}
val
:=
&
pb
.
GuessGameAction
{
Ty
:
pb
.
GuessGameActionAbort
,
Value
:
&
pb
.
GuessGameAction_Abort
{
head
},
Value
:
&
pb
.
GuessGameAction_Abort
{
v
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
GuessX
,
types
.
Encode
(
val
))
name
:=
types
.
ExecName
(
pb
.
GuessX
)
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
pb
.
GuessX
)),
Payload
:
types
.
Encode
(
val
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
name
),
}
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -49,12 +100,26 @@ func (c *channelClient) GuessAbort(ctx context.Context, head *pb.GuessGameAbort)
return
&
types
.
UnsignTx
{
Data
:
data
},
nil
}
func
(
c
*
channelClient
)
GuessPublish
(
ctx
context
.
Context
,
head
*
pb
.
GuessGamePublish
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessPublish
(
ctx
context
.
Context
,
parm
*
pb
.
GuessPublishTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGamePublish
{
GameId
:
parm
.
GameId
,
Result
:
parm
.
Result
,
}
val
:=
&
pb
.
GuessGameAction
{
Ty
:
pb
.
GuessGameActionPublish
,
Value
:
&
pb
.
GuessGameAction_Publish
{
head
},
Value
:
&
pb
.
GuessGameAction_Publish
{
v
},
}
tx
,
err
:=
types
.
CreateFormatTx
(
pb
.
GuessX
,
types
.
Encode
(
val
))
name
:=
types
.
ExecName
(
pb
.
GuessX
)
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
types
.
ExecName
(
pb
.
GuessX
)),
Payload
:
types
.
Encode
(
val
),
Fee
:
parm
.
Fee
,
To
:
address
.
ExecAddress
(
name
),
}
tx
,
err
:=
types
.
FormatTx
(
name
,
tx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/guess/types/guess.pb.go
View file @
96391f7b
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/types/tx.go
View file @
96391f7b
...
...
@@ -8,17 +8,13 @@ type GuessGameStartTx struct {
Topic
string
`json:"topic,omitempty"`
Options
string
`json:"options,omitempty"`
Category
string
`json:"category,omitempty"`
MaxBetTime
string
`json:"maxTime,omitempty"`
MaxBetHeight
int64
`json:"maxHeight,omitempty"`
Symbol
string
`json:"symbol,omitempty"`
Exec
string
`json:"exec,omitempty"`
MaxBets
int64
`json:"maxBets,omitempty"`
MaxBetsNumber
int64
`json:"maxBetsNumber,omitempty"`
DevFeeFactor
int64
`json:"devFeeFactor,omitempty"`
DevFeeAddr
string
`json:"devFeeAddr,omitempty"`
PlatFeeFactor
int64
`json:"platFeeFactor,omitempty"`
PlatFeeAddr
string
`json:"platFeeAddr,omitempty"`
Expire
string
`json:"expire,omitempty"`
ExpireHeight
int64
`json:"expireHeight,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
...
...
plugin/dapp/guess/types/types.go
View file @
96391f7b
...
...
@@ -121,17 +121,13 @@ func CreateRawGuessStartTx(parm *GuessGameStartTx) (*types.Transaction, error) {
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
,
}
...
...
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