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
b35ffc11
Commit
b35ffc11
authored
Dec 18, 2018
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linter
parent
ca870478
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
81 additions
and
83 deletions
+81
-83
game.go
plugin/dapp/guess/commands/game.go
+6
-6
exec_del_local.go
plugin/dapp/guess/executor/exec_del_local.go
+8
-8
exec_local.go
plugin/dapp/guess/executor/exec_local.go
+14
-14
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+20
-22
keys.go
plugin/dapp/guess/executor/keys.go
+6
-6
query.go
plugin/dapp/guess/executor/query.go
+1
-1
guess.proto
plugin/dapp/guess/proto/guess.proto
+14
-14
rpc.go
plugin/dapp/guess/rpc/rpc.go
+4
-4
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+0
-0
tx.go
plugin/dapp/guess/types/tx.go
+4
-4
types.go
plugin/dapp/guess/types/types.go
+4
-4
No files found.
plugin/dapp/guess/commands/game.go
View file @
b35ffc11
...
@@ -139,7 +139,7 @@ func guessBet(cmd *cobra.Command, args []string) {
...
@@ -139,7 +139,7 @@ func guessBet(cmd *cobra.Command, args []string) {
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessBetTxReq
{
params
:=
&
pkt
.
GuessBetTxReq
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Option
:
option
,
Option
:
option
,
Bets
:
betsNumber
,
Bets
:
betsNumber
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
Fee
:
int64
(
fee
*
float64
(
1e8
)),
...
@@ -173,7 +173,7 @@ func guessStopBet(cmd *cobra.Command, args []string) {
...
@@ -173,7 +173,7 @@ func guessStopBet(cmd *cobra.Command, args []string) {
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessStopBetTxReq
{
params
:=
&
pkt
.
GuessStopBetTxReq
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
}
...
@@ -204,7 +204,7 @@ func guessAbort(cmd *cobra.Command, args []string) {
...
@@ -204,7 +204,7 @@ func guessAbort(cmd *cobra.Command, args []string) {
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
gameID
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameId"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessAbortTxReq
{
params
:=
&
pkt
.
GuessAbortTxReq
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
}
...
@@ -241,7 +241,7 @@ func guessPublish(cmd *cobra.Command, args []string) {
...
@@ -241,7 +241,7 @@ func guessPublish(cmd *cobra.Command, args []string) {
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
fee
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"fee"
)
params
:=
&
pkt
.
GuessPublishTxReq
{
params
:=
&
pkt
.
GuessPublishTxReq
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Result
:
result
,
Result
:
result
,
Fee
:
int64
(
fee
*
float64
(
1e8
)),
Fee
:
int64
(
fee
*
float64
(
1e8
)),
}
}
...
@@ -300,7 +300,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -300,7 +300,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
case
1
:
case
1
:
gameIds
:=
strings
.
Split
(
gameIDs
,
";"
)
gameIds
:=
strings
.
Split
(
gameIDs
,
";"
)
req
:=
&
pkt
.
QueryGuessGameInfos
{
req
:=
&
pkt
.
QueryGuessGameInfos
{
GameI
d
s
:
gameIds
,
GameI
D
s
:
gameIds
,
}
}
params
.
FuncName
=
pkt
.
FuncName_QueryGamesByIds
params
.
FuncName
=
pkt
.
FuncName_QueryGamesByIds
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -310,7 +310,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -310,7 +310,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
case
2
:
case
2
:
req
:=
&
pkt
.
QueryGuessGameInfo
{
req
:=
&
pkt
.
QueryGuessGameInfo
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
}
}
params
.
FuncName
=
pkt
.
FuncName_QueryGameById
params
.
FuncName
=
pkt
.
FuncName_QueryGameById
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
...
plugin/dapp/guess/executor/exec_del_local.go
View file @
b35ffc11
...
@@ -24,9 +24,9 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
...
@@ -24,9 +24,9 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
//如果发生了状态变化,恢复老状态的记录,删除新添加的状态记录
//如果发生了状态变化,恢复老状态的记录,删除新添加的状态记录
if
log
.
StatusChange
{
if
log
.
StatusChange
{
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
GameI
d
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
GameI
D
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
GameI
d
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
GameI
D
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
GameI
d
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
GameI
D
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
...
@@ -34,20 +34,20 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
...
@@ -34,20 +34,20 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
}
}
}
else
if
log
.
StatusChange
{
}
else
if
log
.
StatusChange
{
//其他状态时的状态发生变化的情况,要将老状态对应的记录恢复,同时删除新加的状态记录;对于每个地址的下注记录也需要遍历处理。
//其他状态时的状态发生变化的情况,要将老状态对应的记录恢复,同时删除新加的状态记录;对于每个地址的下注记录也需要遍历处理。
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
GameI
d
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
GameI
D
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
GameI
d
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
GameI
D
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
GameI
d
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
GameI
D
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
Index
))
//从game中遍历每个地址的记录进行删除新增记录,回复老记录
//从game中遍历每个地址的记录进行删除新增记录,回复老记录
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
log
.
GameI
d
)
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
log
.
GameI
D
)
if
err
==
nil
{
if
err
==
nil
{
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
.
GameI
d
,
player
.
Bet
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
log
.
GameI
D
,
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 @
b35ffc11
...
@@ -13,19 +13,19 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
...
@@ -13,19 +13,19 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
//新创建游戏
//新创建游戏
if
log
.
Status
==
pkt
.
GuessGameStatusStart
{
if
log
.
Status
==
pkt
.
GuessGameStatusStart
{
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameI
D
,
log
.
Index
))
}
else
if
log
.
Status
==
pkt
.
GuessGameStatusBet
{
}
else
if
log
.
Status
==
pkt
.
GuessGameStatusBet
{
//如果是下注状态,则有用户进行了下注操作
//如果是下注状态,则有用户进行了下注操作
kvs
=
append
(
kvs
,
addGuessGameAddrIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAddrIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameI
D
,
log
.
Index
))
//如果发生了状态变化,则是从start->bet,对于老状态的记录进行删除操作,并增加新状态记录
//如果发生了状态变化,则是从start->bet,对于老状态的记录进行删除操作,并增加新状态记录
if
log
.
StatusChange
{
if
log
.
StatusChange
{
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
PreIndex
))
...
@@ -33,20 +33,20 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
...
@@ -33,20 +33,20 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
}
}
}
else
if
log
.
StatusChange
{
}
else
if
log
.
StatusChange
{
//其他状态时的状态发生变化,要将老状态对应的记录删除,同时加入新状态记录;对于每个地址的下注记录也需要遍历处理。
//其他状态时的状态发生变化,要将老状态对应的记录删除,同时加入新状态记录;对于每个地址的下注记录也需要遍历处理。
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameI
D
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
PreIndex
))
//从game中遍历每个地址的记录进行新状态记录的增和老状态记录的删除
//从game中遍历每个地址的记录进行新状态记录的增和老状态记录的删除
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
log
.
GameI
d
)
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
log
.
GameI
D
)
if
err
==
nil
{
if
err
==
nil
{
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
.
GameI
d
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
GameI
D
,
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 @
b35ffc11
...
@@ -139,8 +139,8 @@ func readGame(db dbm.KV, id string) (*pkt.GuessGame, error) {
...
@@ -139,8 +139,8 @@ func readGame(db dbm.KV, id string) (*pkt.GuessGame, error) {
//Infos 根据游戏id列表查询多个游戏详情信息
//Infos 根据游戏id列表查询多个游戏详情信息
func
Infos
(
db
dbm
.
KV
,
infos
*
pkt
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
func
Infos
(
db
dbm
.
KV
,
infos
*
pkt
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
var
games
[]
*
pkt
.
GuessGame
var
games
[]
*
pkt
.
GuessGame
for
i
:=
0
;
i
<
len
(
infos
.
GameI
d
s
);
i
++
{
for
i
:=
0
;
i
<
len
(
infos
.
GameI
D
s
);
i
++
{
id
:=
infos
.
GameI
d
s
[
i
]
id
:=
infos
.
GameI
D
s
[
i
]
game
,
err
:=
readGame
(
db
,
id
)
game
,
err
:=
readGame
(
db
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -302,8 +302,8 @@ func getGameListByCategoryStatus(db dbm.Lister, category string, status int32, i
...
@@ -302,8 +302,8 @@ func getGameListByCategoryStatus(db dbm.Lister, category string, status int32, i
func
(
action
*
Action
)
saveGame
(
game
*
pkt
.
GuessGame
)
(
kvset
[]
*
types
.
KeyValue
)
{
func
(
action
*
Action
)
saveGame
(
game
*
pkt
.
GuessGame
)
(
kvset
[]
*
types
.
KeyValue
)
{
value
:=
types
.
Encode
(
game
)
value
:=
types
.
Encode
(
game
)
action
.
db
.
Set
(
Key
(
game
.
GetGameI
d
()),
value
)
action
.
db
.
Set
(
Key
(
game
.
GetGameI
D
()),
value
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
Key
(
game
.
GameI
d
),
Value
:
value
})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
Key
(
game
.
GameI
D
),
Value
:
value
})
return
kvset
return
kvset
}
}
...
@@ -331,7 +331,7 @@ func (action *Action) GetReceiptLog(game *pkt.GuessGame, statusChange bool) *typ
...
@@ -331,7 +331,7 @@ func (action *Action) GetReceiptLog(game *pkt.GuessGame, statusChange bool) *typ
}
}
r
.
Index
=
game
.
Index
r
.
Index
=
game
.
Index
r
.
GameI
d
=
game
.
GameId
r
.
GameI
D
=
game
.
GameID
r
.
Status
=
game
.
Status
r
.
Status
=
game
.
Status
r
.
AdminAddr
=
game
.
AdminAddr
r
.
AdminAddr
=
game
.
AdminAddr
r
.
PreStatus
=
game
.
PreStatus
r
.
PreStatus
=
game
.
PreStatus
...
@@ -359,7 +359,7 @@ func (action *Action) readGame(id string) (*pkt.GuessGame, error) {
...
@@ -359,7 +359,7 @@ func (action *Action) readGame(id string) (*pkt.GuessGame, error) {
// 新建一局游戏
// 新建一局游戏
func
(
action
*
Action
)
newGame
(
gameID
string
,
start
*
pkt
.
GuessGameStart
)
(
*
pkt
.
GuessGame
,
error
)
{
func
(
action
*
Action
)
newGame
(
gameID
string
,
start
*
pkt
.
GuessGameStart
)
(
*
pkt
.
GuessGame
,
error
)
{
game
:=
&
pkt
.
GuessGame
{
game
:=
&
pkt
.
GuessGame
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
pkt
.
GuessGameActionStart
,
Status
:
pkt
.
GuessGameActionStart
,
//StartTime: action.blocktime,
//StartTime: action.blocktime,
StartTxHash
:
gameID
,
StartTxHash
:
gameID
,
...
@@ -468,10 +468,10 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
...
@@ -468,10 +468,10 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameI
d
())
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameI
D
())
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
pbBet
.
GetGameI
d
(),
"err"
,
err
)
pbBet
.
GetGameI
D
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
@@ -484,7 +484,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
...
@@ -484,7 +484,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
canBet
:=
action
.
RefreshStatusByTime
(
game
)
canBet
:=
action
.
RefreshStatusByTime
(
game
)
if
canBet
==
false
{
if
!
canBet
{
var
receiptLog
*
types
.
ReceiptLog
var
receiptLog
*
types
.
ReceiptLog
if
prevStatus
!=
game
.
Status
{
if
prevStatus
!=
game
.
Status
{
//状态发生了变化,且是变到了不可下注的状态,那么对于所有下注的addr来说,其addr:status主键的数据都需要更新
//状态发生了变化,且是变到了不可下注的状态,那么对于所有下注的addr来说,其addr:status主键的数据都需要更新
...
@@ -529,7 +529,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
...
@@ -529,7 +529,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
checkValue
:=
pbBet
.
BetsNum
checkValue
:=
pbBet
.
BetsNum
if
!
action
.
CheckExecAccountBalance
(
action
.
fromaddr
,
checkValue
,
0
)
{
if
!
action
.
CheckExecAccountBalance
(
action
.
fromaddr
,
checkValue
,
0
)
{
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"id"
,
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"id"
,
pbBet
.
GetGameI
d
(),
"err"
,
types
.
ErrNoBalance
)
pbBet
.
GetGameI
D
(),
"err"
,
types
.
ErrNoBalance
)
return
nil
,
types
.
ErrNoBalance
return
nil
,
types
.
ErrNoBalance
}
}
...
@@ -562,10 +562,10 @@ func (action *Action) GameStopBet(pbBet *pkt.GuessGameStopBet) (*types.Receipt,
...
@@ -562,10 +562,10 @@ func (action *Action) GameStopBet(pbBet *pkt.GuessGameStopBet) (*types.Receipt,
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameI
d
())
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameI
D
())
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"GameStopBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
logger
.
Error
(
"GameStopBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
pbBet
.
GetGameI
d
(),
"err"
,
err
)
pbBet
.
GetGameI
D
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
@@ -622,10 +622,10 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
...
@@ -622,10 +622,10 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
game
,
err
:=
action
.
readGame
(
publish
.
GetGameI
d
())
game
,
err
:=
action
.
readGame
(
publish
.
GetGameI
D
())
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"GamePublish"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
logger
.
Error
(
"GamePublish"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
publish
.
GetGameI
d
(),
"err"
,
err
)
publish
.
GetGameI
D
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
@@ -706,7 +706,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
...
@@ -706,7 +706,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
}
}
if
game
.
DevFeeFactor
>
0
{
if
game
.
DevFeeFactor
>
0
{
devFee
=
int64
(
totalBetsNumber
)
*
game
.
DevFeeFactor
/
1000
devFee
=
totalBetsNumber
*
game
.
DevFeeFactor
/
1000
receipt
,
err
:=
action
.
coinsAccount
.
ExecTransfer
(
game
.
AdminAddr
,
devAddr
,
action
.
execaddr
,
devFee
)
receipt
,
err
:=
action
.
coinsAccount
.
ExecTransfer
(
game
.
AdminAddr
,
devAddr
,
action
.
execaddr
,
devFee
)
if
err
!=
nil
{
if
err
!=
nil
{
action
.
coinsAccount
.
ExecFrozen
(
game
.
AdminAddr
,
action
.
execaddr
,
devFee
)
// rollback
action
.
coinsAccount
.
ExecFrozen
(
game
.
AdminAddr
,
action
.
execaddr
,
devFee
)
// rollback
...
@@ -719,7 +719,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
...
@@ -719,7 +719,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
}
}
if
game
.
PlatFeeFactor
>
0
{
if
game
.
PlatFeeFactor
>
0
{
platFee
=
int64
(
totalBetsNumber
)
*
game
.
PlatFeeFactor
/
1000
platFee
=
totalBetsNumber
*
game
.
PlatFeeFactor
/
1000
receipt
,
err
:=
action
.
coinsAccount
.
ExecTransfer
(
game
.
AdminAddr
,
platAddr
,
action
.
execaddr
,
platFee
)
receipt
,
err
:=
action
.
coinsAccount
.
ExecTransfer
(
game
.
AdminAddr
,
platAddr
,
action
.
execaddr
,
platFee
)
if
err
!=
nil
{
if
err
!=
nil
{
action
.
coinsAccount
.
ExecFrozen
(
game
.
AdminAddr
,
action
.
execaddr
,
platFee
)
// rollback
action
.
coinsAccount
.
ExecFrozen
(
game
.
AdminAddr
,
action
.
execaddr
,
platFee
)
// rollback
...
@@ -736,7 +736,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
...
@@ -736,7 +736,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
for
j
:=
0
;
j
<
len
(
game
.
Plays
);
j
++
{
for
j
:=
0
;
j
<
len
(
game
.
Plays
);
j
++
{
player
:=
game
.
Plays
[
j
]
player
:=
game
.
Plays
[
j
]
if
player
.
Bet
.
Option
==
game
.
Result
{
if
player
.
Bet
.
Option
==
game
.
Result
{
value
:=
int64
(
player
.
Bet
.
BetsNumber
*
winValue
/
winBetsNumber
)
value
:=
player
.
Bet
.
BetsNumber
*
winValue
/
winBetsNumber
receipt
,
err
:=
action
.
coinsAccount
.
ExecTransfer
(
game
.
AdminAddr
,
player
.
Addr
,
action
.
execaddr
,
value
)
receipt
,
err
:=
action
.
coinsAccount
.
ExecTransfer
(
game
.
AdminAddr
,
player
.
Addr
,
action
.
execaddr
,
value
)
if
err
!=
nil
{
if
err
!=
nil
{
action
.
coinsAccount
.
ExecFrozen
(
player
.
Addr
,
action
.
execaddr
,
value
)
// rollback
action
.
coinsAccount
.
ExecFrozen
(
player
.
Addr
,
action
.
execaddr
,
value
)
// rollback
...
@@ -766,10 +766,10 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro
...
@@ -766,10 +766,10 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
game
,
err
:=
action
.
readGame
(
pbend
.
GetGameI
d
())
game
,
err
:=
action
.
readGame
(
pbend
.
GetGameI
D
())
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"GameAbort"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
logger
.
Error
(
"GameAbort"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"get game failed"
,
pbend
.
GetGameI
d
(),
"err"
,
err
)
pbend
.
GetGameI
D
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
@@ -796,7 +796,7 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro
...
@@ -796,7 +796,7 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro
//激活冻结账户
//激活冻结账户
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
player
:=
game
.
Plays
[
i
]
value
:=
int64
(
player
.
Bet
.
BetsNumber
)
value
:=
player
.
Bet
.
BetsNumber
receipt
,
err
:=
action
.
coinsAccount
.
ExecActive
(
player
.
Addr
,
action
.
execaddr
,
value
)
receipt
,
err
:=
action
.
coinsAccount
.
ExecActive
(
player
.
Addr
,
action
.
execaddr
,
value
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"GameAbort"
,
"addr"
,
player
.
Addr
,
"execaddr"
,
action
.
execaddr
,
"amount"
,
value
,
"err"
,
err
)
logger
.
Error
(
"GameAbort"
,
"addr"
,
player
.
Addr
,
"execaddr"
,
action
.
execaddr
,
"amount"
,
value
,
"err"
,
err
)
...
@@ -864,8 +864,6 @@ func (action *Action) ChangeStatus(game *pkt.GuessGame, destStatus int32) {
...
@@ -864,8 +864,6 @@ func (action *Action) ChangeStatus(game *pkt.GuessGame, destStatus int32) {
game
.
Status
=
destStatus
game
.
Status
=
destStatus
game
.
Index
=
action
.
getIndex
()
game
.
Index
=
action
.
getIndex
()
}
}
return
}
}
//ChangeAllAddrIndex 状态更新时,更新下注记录的历史信息
//ChangeAllAddrIndex 状态更新时,更新下注记录的历史信息
...
...
plugin/dapp/guess/executor/keys.go
View file @
b35ffc11
...
@@ -81,7 +81,7 @@ func addGuessGameAddrIndexKey(status int32, addr, gameID string, index int64) *t
...
@@ -81,7 +81,7 @@ func addGuessGameAddrIndexKey(status int32, addr, gameID string, index int64) *t
kv
:=
&
types
.
KeyValue
{}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrKey
(
addr
,
index
)
kv
.
Key
=
calcGuessGameAddrKey
(
addr
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
pkt
.
GuessGameRecord
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
}
}
...
@@ -100,7 +100,7 @@ func addGuessGameStatusIndexKey(status int32, gameID string, index int64) *types
...
@@ -100,7 +100,7 @@ func addGuessGameStatusIndexKey(status int32, gameID string, index int64) *types
kv
:=
&
types
.
KeyValue
{}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameStatusKey
(
status
,
index
)
kv
.
Key
=
calcGuessGameStatusKey
(
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
pkt
.
GuessGameRecord
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
}
}
...
@@ -119,7 +119,7 @@ func addGuessGameAddrStatusIndexKey(status int32, addr, gameID string, index int
...
@@ -119,7 +119,7 @@ func addGuessGameAddrStatusIndexKey(status int32, addr, gameID string, index int
kv
:=
&
types
.
KeyValue
{}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrStatusKey
(
addr
,
status
,
index
)
kv
.
Key
=
calcGuessGameAddrStatusKey
(
addr
,
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
pkt
.
GuessGameRecord
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
}
}
...
@@ -138,7 +138,7 @@ func addGuessGameAdminIndexKey(status int32, addr, gameID string, index int64) *
...
@@ -138,7 +138,7 @@ func addGuessGameAdminIndexKey(status int32, addr, gameID string, index int64) *
kv
:=
&
types
.
KeyValue
{}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminKey
(
addr
,
index
)
kv
.
Key
=
calcGuessGameAdminKey
(
addr
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
pkt
.
GuessGameRecord
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
}
}
...
@@ -157,7 +157,7 @@ func addGuessGameAdminStatusIndexKey(status int32, addr, gameID string, index in
...
@@ -157,7 +157,7 @@ func addGuessGameAdminStatusIndexKey(status int32, addr, gameID string, index in
kv
:=
&
types
.
KeyValue
{}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminStatusKey
(
addr
,
status
,
index
)
kv
.
Key
=
calcGuessGameAdminStatusKey
(
addr
,
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
pkt
.
GuessGameRecord
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
}
}
...
@@ -176,7 +176,7 @@ func addGuessGameCategoryStatusIndexKey(status int32, category, gameID string, i
...
@@ -176,7 +176,7 @@ func addGuessGameCategoryStatusIndexKey(status int32, category, gameID string, i
kv
:=
&
types
.
KeyValue
{}
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameCategoryStatusKey
(
category
,
status
,
index
)
kv
.
Key
=
calcGuessGameCategoryStatusKey
(
category
,
status
,
index
)
record
:=
&
pkt
.
GuessGameRecord
{
record
:=
&
pkt
.
GuessGameRecord
{
GameI
d
:
gameID
,
GameI
D
:
gameID
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
}
}
...
...
plugin/dapp/guess/executor/query.go
View file @
b35ffc11
...
@@ -16,7 +16,7 @@ func (g *Guess) Query_QueryGamesByIds(in *pkt.QueryGuessGameInfos) (types.Messag
...
@@ -16,7 +16,7 @@ func (g *Guess) Query_QueryGamesByIds(in *pkt.QueryGuessGameInfos) (types.Messag
//Query_QueryGameById method
//Query_QueryGameById method
func
(
g
*
Guess
)
Query_QueryGameById
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameById
(
in
*
pkt
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
in
.
GetGameI
d
())
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
in
.
GetGameI
D
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
plugin/dapp/guess/proto/guess.proto
View file @
b35ffc11
...
@@ -6,7 +6,7 @@ package types;
...
@@ -6,7 +6,7 @@ package types;
//GuessGame 竞猜游戏详情
//GuessGame 竞猜游戏详情
message
GuessGame
{
message
GuessGame
{
string
gameI
d
=
1
;
//游戏ID
string
gameI
D
=
1
;
//游戏ID
int32
status
=
2
;
//游戏的状态:创建->投注->截止投注->开奖
int32
status
=
2
;
//游戏的状态:创建->投注->截止投注->开奖
int32
preStatus
=
3
;
int32
preStatus
=
3
;
int64
startTime
=
4
;
//创建游戏的时间
int64
startTime
=
4
;
//创建游戏的时间
...
@@ -94,36 +94,36 @@ message GuessGameStart{
...
@@ -94,36 +94,36 @@ message GuessGameStart{
//GuessGameBet 参与游戏下注
//GuessGameBet 参与游戏下注
message
GuessGameBet
{
message
GuessGameBet
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
string
option
=
2
;
string
option
=
2
;
int64
betsNum
=
3
;
int64
betsNum
=
3
;
}
}
//GuessGameStopBet 游戏停止下注
//GuessGameStopBet 游戏停止下注
message
GuessGameStopBet
{
message
GuessGameStopBet
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
}
}
//GuessGameAbort 游戏异常终止,退还下注
//GuessGameAbort 游戏异常终止,退还下注
message
GuessGameAbort
{
message
GuessGameAbort
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
}
}
//GuessGamePublish 游戏结果揭晓
//GuessGamePublish 游戏结果揭晓
message
GuessGamePublish
{
message
GuessGamePublish
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
string
result
=
2
;
string
result
=
2
;
}
}
//GuessGameQuery 查询游戏结果
//GuessGameQuery 查询游戏结果
message
GuessGameQuery
{
message
GuessGameQuery
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
uint32
ty
=
2
;
uint32
ty
=
2
;
}
}
//QueryGuessGameInfo 游戏信息查询消息
//QueryGuessGameInfo 游戏信息查询消息
message
QueryGuessGameInfo
{
message
QueryGuessGameInfo
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
string
addr
=
2
;
string
addr
=
2
;
int32
status
=
3
;
int32
status
=
3
;
int64
index
=
4
;
int64
index
=
4
;
...
@@ -138,7 +138,7 @@ message ReplyGuessGameInfo {
...
@@ -138,7 +138,7 @@ message ReplyGuessGameInfo {
//QueryGuessGameInfos 游戏信息列表查询消息
//QueryGuessGameInfos 游戏信息列表查询消息
message
QueryGuessGameInfos
{
message
QueryGuessGameInfos
{
repeated
string
gameI
d
s
=
1
;
repeated
string
gameI
D
s
=
1
;
}
}
//ReplyGuessGameInfos 游戏信息列表查询响应消息
//ReplyGuessGameInfos 游戏信息列表查询响应消息
...
@@ -148,7 +148,7 @@ message ReplyGuessGameInfos {
...
@@ -148,7 +148,7 @@ message ReplyGuessGameInfos {
//ReceiptGuessGame 竞猜游戏收据信息
//ReceiptGuessGame 竞猜游戏收据信息
message
ReceiptGuessGame
{
message
ReceiptGuessGame
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
int32
preStatus
=
2
;
int32
preStatus
=
2
;
int32
status
=
3
;
int32
status
=
3
;
string
addr
=
4
;
string
addr
=
4
;
...
@@ -178,7 +178,7 @@ message GuessStartTxReq {
...
@@ -178,7 +178,7 @@ message GuessStartTxReq {
//GuessBetTxReq 构造bet交易的请求
//GuessBetTxReq 构造bet交易的请求
message
GuessBetTxReq
{
message
GuessBetTxReq
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
string
option
=
2
;
string
option
=
2
;
int64
bets
=
3
;
int64
bets
=
3
;
int64
fee
=
4
;
int64
fee
=
4
;
...
@@ -186,26 +186,26 @@ message GuessBetTxReq {
...
@@ -186,26 +186,26 @@ message GuessBetTxReq {
//GuessStopBetTxReq 构造stopBet交易的请求
//GuessStopBetTxReq 构造stopBet交易的请求
message
GuessStopBetTxReq
{
message
GuessStopBetTxReq
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
int64
fee
=
2
;
int64
fee
=
2
;
}
}
//GuessAbortTxReq 构造abort交易的请求
//GuessAbortTxReq 构造abort交易的请求
message
GuessAbortTxReq
{
message
GuessAbortTxReq
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
int64
fee
=
2
;
int64
fee
=
2
;
}
}
//GuessPublishTxReq 构造publish交易的请求
//GuessPublishTxReq 构造publish交易的请求
message
GuessPublishTxReq
{
message
GuessPublishTxReq
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
string
result
=
2
;
string
result
=
2
;
int64
fee
=
3
;
int64
fee
=
3
;
}
}
// GuessGameRecord game信息查询记录
// GuessGameRecord game信息查询记录
message
GuessGameRecord
{
message
GuessGameRecord
{
string
gameI
d
=
1
;
string
gameI
D
=
1
;
int32
status
=
2
;
int32
status
=
2
;
int64
index
=
3
;
int64
index
=
3
;
}
}
...
...
plugin/dapp/guess/rpc/rpc.go
View file @
b35ffc11
...
@@ -52,7 +52,7 @@ func (c *channelClient) GuessStart(ctx context.Context, parm *pb.GuessStartTxReq
...
@@ -52,7 +52,7 @@ func (c *channelClient) GuessStart(ctx context.Context, parm *pb.GuessStartTxReq
//构造bet原始交易
//构造bet原始交易
func
(
c
*
channelClient
)
GuessBet
(
ctx
context
.
Context
,
parm
*
pb
.
GuessBetTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessBet
(
ctx
context
.
Context
,
parm
*
pb
.
GuessBetTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGameBet
{
v
:=
&
pb
.
GuessGameBet
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
Option
:
parm
.
Option
,
Option
:
parm
.
Option
,
BetsNum
:
parm
.
Bets
,
BetsNum
:
parm
.
Bets
,
}
}
...
@@ -81,7 +81,7 @@ func (c *channelClient) GuessBet(ctx context.Context, parm *pb.GuessBetTxReq) (*
...
@@ -81,7 +81,7 @@ func (c *channelClient) GuessBet(ctx context.Context, parm *pb.GuessBetTxReq) (*
//构造stopBet原始交易
//构造stopBet原始交易
func
(
c
*
channelClient
)
GuessStopBet
(
ctx
context
.
Context
,
parm
*
pb
.
GuessStopBetTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessStopBet
(
ctx
context
.
Context
,
parm
*
pb
.
GuessStopBetTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGameStopBet
{
v
:=
&
pb
.
GuessGameStopBet
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
}
}
val
:=
&
pb
.
GuessGameAction
{
val
:=
&
pb
.
GuessGameAction
{
...
@@ -108,7 +108,7 @@ func (c *channelClient) GuessStopBet(ctx context.Context, parm *pb.GuessStopBetT
...
@@ -108,7 +108,7 @@ func (c *channelClient) GuessStopBet(ctx context.Context, parm *pb.GuessStopBetT
//构造abort原始交易
//构造abort原始交易
func
(
c
*
channelClient
)
GuessAbort
(
ctx
context
.
Context
,
parm
*
pb
.
GuessAbortTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessAbort
(
ctx
context
.
Context
,
parm
*
pb
.
GuessAbortTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGameAbort
{
v
:=
&
pb
.
GuessGameAbort
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
}
}
val
:=
&
pb
.
GuessGameAction
{
val
:=
&
pb
.
GuessGameAction
{
...
@@ -134,7 +134,7 @@ func (c *channelClient) GuessAbort(ctx context.Context, parm *pb.GuessAbortTxReq
...
@@ -134,7 +134,7 @@ func (c *channelClient) GuessAbort(ctx context.Context, parm *pb.GuessAbortTxReq
//构造publish原始交易
//构造publish原始交易
func
(
c
*
channelClient
)
GuessPublish
(
ctx
context
.
Context
,
parm
*
pb
.
GuessPublishTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessPublish
(
ctx
context
.
Context
,
parm
*
pb
.
GuessPublishTxReq
)
(
*
types
.
UnsignTx
,
error
)
{
v
:=
&
pb
.
GuessGamePublish
{
v
:=
&
pb
.
GuessGamePublish
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
Result
:
parm
.
Result
,
Result
:
parm
.
Result
,
}
}
...
...
plugin/dapp/guess/types/guess.pb.go
View file @
b35ffc11
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/types/tx.go
View file @
b35ffc11
...
@@ -22,7 +22,7 @@ type GuessGameStartTx struct {
...
@@ -22,7 +22,7 @@ type GuessGameStartTx struct {
//GuessGameBetTx struct
//GuessGameBetTx struct
type
GuessGameBetTx
struct
{
type
GuessGameBetTx
struct
{
GameI
d
string
`json:"gameId,omitempty"`
GameI
D
string
`json:"gameId,omitempty"`
Option
string
`json:"option,omitempty"`
Option
string
`json:"option,omitempty"`
BetsNum
int64
`json:"betsNum,omitempty"`
BetsNum
int64
`json:"betsNum,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
...
@@ -30,19 +30,19 @@ type GuessGameBetTx struct {
...
@@ -30,19 +30,19 @@ type GuessGameBetTx struct {
//GuessGameStopBetTx struct
//GuessGameStopBetTx struct
type
GuessGameStopBetTx
struct
{
type
GuessGameStopBetTx
struct
{
GameI
d
string
`json:"gameId,omitempty"`
GameI
D
string
`json:"gameId,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
//GuessGamePublishTx struct
//GuessGamePublishTx struct
type
GuessGamePublishTx
struct
{
type
GuessGamePublishTx
struct
{
GameI
d
string
`json:"gameId,omitempty"`
GameI
D
string
`json:"gameId,omitempty"`
Result
string
`json:"result,omitempty"`
Result
string
`json:"result,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
//GuessGameAbortTx struct
//GuessGameAbortTx struct
type
GuessGameAbortTx
struct
{
type
GuessGameAbortTx
struct
{
GameI
d
string
`json:"gameId,omitempty"`
GameI
D
string
`json:"gameId,omitempty"`
Fee
int64
`json:"fee,omitempty"`
Fee
int64
`json:"fee,omitempty"`
}
}
plugin/dapp/guess/types/types.go
View file @
b35ffc11
...
@@ -164,7 +164,7 @@ func CreateRawGuessBetTx(parm *GuessGameBetTx) (*types.Transaction, error) {
...
@@ -164,7 +164,7 @@ func CreateRawGuessBetTx(parm *GuessGameBetTx) (*types.Transaction, error) {
}
}
v
:=
&
GuessGameBet
{
v
:=
&
GuessGameBet
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
Option
:
parm
.
Option
,
Option
:
parm
.
Option
,
BetsNum
:
parm
.
BetsNum
,
BetsNum
:
parm
.
BetsNum
,
}
}
...
@@ -195,7 +195,7 @@ func CreateRawGuessStopBetTx(parm *GuessGameStopBetTx) (*types.Transaction, erro
...
@@ -195,7 +195,7 @@ func CreateRawGuessStopBetTx(parm *GuessGameStopBetTx) (*types.Transaction, erro
}
}
v
:=
&
GuessGameStopBet
{
v
:=
&
GuessGameStopBet
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
}
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
Ty
:
GuessGameActionStopBet
,
Ty
:
GuessGameActionStopBet
,
...
@@ -224,7 +224,7 @@ func CreateRawGuessPublishTx(parm *GuessGamePublishTx) (*types.Transaction, erro
...
@@ -224,7 +224,7 @@ func CreateRawGuessPublishTx(parm *GuessGamePublishTx) (*types.Transaction, erro
}
}
v
:=
&
GuessGamePublish
{
v
:=
&
GuessGamePublish
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
Result
:
parm
.
Result
,
Result
:
parm
.
Result
,
}
}
...
@@ -255,7 +255,7 @@ func CreateRawGuessAbortTx(parm *GuessGameAbortTx) (*types.Transaction, error) {
...
@@ -255,7 +255,7 @@ func CreateRawGuessAbortTx(parm *GuessGameAbortTx) (*types.Transaction, error) {
}
}
v
:=
&
GuessGameAbort
{
v
:=
&
GuessGameAbort
{
GameI
d
:
parm
.
GameId
,
GameI
D
:
parm
.
GameID
,
}
}
val
:=
&
GuessGameAction
{
val
:=
&
GuessGameAction
{
...
...
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