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
4da6c484
Commit
4da6c484
authored
Jan 04, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table refactor
parent
55e2f303
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
729 additions
and
706 deletions
+729
-706
game.go
plugin/dapp/guess/commands/game.go
+15
-2
exec_del_local.go
plugin/dapp/guess/executor/exec_del_local.go
+89
-58
exec_local.go
plugin/dapp/guess/executor/exec_local.go
+60
-59
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+134
-181
keys.go
plugin/dapp/guess/executor/keys.go
+0
-192
query.go
plugin/dapp/guess/executor/query.go
+29
-30
guess.proto
plugin/dapp/guess/proto/guess.proto
+46
-29
errors.go
plugin/dapp/guess/types/errors.go
+4
-0
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+274
-131
table.go
plugin/dapp/guess/types/table.go
+78
-24
No files found.
plugin/dapp/guess/commands/game.go
View file @
4da6c484
...
@@ -6,13 +6,12 @@ package commands
...
@@ -6,13 +6,12 @@ package commands
import
(
import
(
"fmt"
"fmt"
"strings"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
jsonrpc
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"strings"
)
)
//GuessCmd Guess合约命令行
//GuessCmd Guess合约命令行
...
@@ -250,6 +249,8 @@ func addGuessQueryFlags(cmd *cobra.Command) {
...
@@ -250,6 +249,8 @@ func addGuessQueryFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status"
)
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"
)
cmd
.
Flags
()
.
StringP
(
"category"
,
"c"
,
"default"
,
"game category"
)
cmd
.
Flags
()
.
StringP
(
"primary"
,
"p"
,
""
,
"the primary to query from"
)
}
}
func
guessQuery
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
guessQuery
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
@@ -262,6 +263,12 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -262,6 +263,12 @@ func guessQuery(cmd *cobra.Command, args []string) {
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
index
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"index"
)
gameIDs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameIDs"
)
gameIDs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"gameIDs"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
primary
,
_
:=
cmd
.
Flags
()
.
GetString
(
"primary"
)
var
primaryKey
[]
byte
if
len
(
primary
)
>
0
{
primaryKey
=
[]
byte
(
primary
)
}
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
gty
.
GuessX
params
.
Execer
=
gty
.
GuessX
...
@@ -301,6 +308,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -301,6 +308,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
req
:=
&
gty
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Addr
:
addr
,
Addr
:
addr
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primaryKey
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddr
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddr
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -312,6 +320,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -312,6 +320,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
req
:=
&
gty
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primaryKey
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -323,6 +332,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -323,6 +332,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
req
:=
&
gty
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
AdminAddr
:
adminAddr
,
AdminAddr
:
adminAddr
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primaryKey
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminAddr
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminAddr
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -335,6 +345,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -335,6 +345,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
Addr
:
addr
,
Addr
:
addr
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primaryKey
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddrStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddrStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -347,6 +358,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -347,6 +358,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
AdminAddr
:
adminAddr
,
AdminAddr
:
adminAddr
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primaryKey
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -359,6 +371,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -359,6 +371,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
Category
:
category
,
Category
:
category
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primaryKey
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByCategoryStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByCategoryStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
...
plugin/dapp/guess/executor/exec_del_local.go
View file @
4da6c484
...
@@ -5,52 +5,104 @@
...
@@ -5,52 +5,104 @@
package
executor
package
executor
import
(
import
(
"fmt"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
)
func
(
g
*
Guess
)
rollbackGame
(
game
*
gty
.
GuessGame
,
log
*
gty
.
ReceiptGuessGame
){
if
game
==
nil
||
log
==
nil
{
return
}
//如果状态发生了变化,则需要将游戏状态恢复到前一状态
if
log
.
StatusChange
{
game
.
Status
=
log
.
PreStatus
game
.
Index
=
log
.
PreIndex
//玩家信息中的index回滚
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
player
.
Bet
.
Index
=
player
.
Bet
.
PreIndex
}
}
//如果下注了,则需要把下注回滚
if
log
.
Bet
{
//统计信息回滚
game
.
BetStat
.
TotalBetTimes
--
game
.
BetStat
.
TotalBetsNumber
-=
log
.
BetsNumber
for
i
:=
0
;
i
<
len
(
game
.
BetStat
.
Items
);
i
++
{
item
:=
game
.
BetStat
.
Items
[
i
]
if
item
.
Option
==
log
.
Option
{
item
.
BetsTimes
--
item
.
BetsNumber
-=
log
.
BetsNumber
break
}
}
//玩家下注信息回滚
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
if
player
.
Addr
==
log
.
Addr
&&
player
.
Bet
.
Index
==
log
.
Index
{
game
.
Plays
=
append
(
game
.
Plays
[
:
i
],
game
.
Plays
[
i
+
1
:
]
...
)
break
}
}
}
}
func
(
g
*
Guess
)
rollbackIndex
(
log
*
gty
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
func
(
g
*
Guess
)
rollbackIndex
(
log
*
gty
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
//新创建游戏,将增加的记录都删除掉
userTable
:=
gty
.
NewGuessUserTable
(
g
.
GetLocalDB
())
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
tablejoin
,
err
:=
table
.
NewJoinTable
(
userTable
,
gameTable
,
[]
string
{
"addr#status"
})
if
err
!=
nil
{
return
nil
}
if
log
.
Status
==
gty
.
GuessGameStatusStart
{
if
log
.
Status
==
gty
.
GuessGameStatusStart
{
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
//新创建游戏回滚,game表删除记录
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
err
=
tablejoin
.
MustGetTable
(
"game"
)
.
Del
([]
byte
(
fmt
.
Sprintf
(
"%018d"
,
log
.
StartIndex
)))
kvs
=
append
(
kvs
,
delGuessGameAdminIndexKey
(
log
.
AdminAddr
,
log
.
Index
))
if
err
!=
nil
{
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
return
nil
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
Index
))
}
kvs
,
_
=
tablejoin
.
Save
()
return
kvs
}
else
if
log
.
Status
==
gty
.
GuessGameStatusBet
{
}
else
if
log
.
Status
==
gty
.
GuessGameStatusBet
{
//如果是下注状态,则有用户进行了下注操作,对这些记录进行删除
//下注阶段,需要更新游戏信息,回滚下注信息
kvs
=
append
(
kvs
,
delGuessGameAddrIndexKey
(
log
.
Addr
,
log
.
Index
))
game
:=
log
.
Game
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
Index
))
log
.
Game
=
nil
//如果发生了状态变化,恢复老状态的记录,删除新添加的状态记录
//先回滚游戏信息,再进行更新
if
log
.
StatusChange
{
g
.
rollbackGame
(
game
,
log
)
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
GameID
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
PreIndex
))
err
=
tablejoin
.
MustGetTable
(
"game"
)
.
Replace
(
game
)
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
GameID
,
log
.
PreIndex
))
if
err
!=
nil
{
return
nil
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
}
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
Index
))
err
=
tablejoin
.
MustGetTable
(
"user"
)
.
Del
([]
byte
(
fmt
.
Sprintf
(
"%018d"
,
log
.
Index
)))
if
err
!=
nil
{
return
nil
}
}
kvs
,
_
=
tablejoin
.
Save
()
}
else
if
log
.
StatusChange
{
}
else
if
log
.
StatusChange
{
//其他状态时的状态发生变化的情况,要将老状态对应的记录恢复,同时删除新加的状态记录;对于每个地址的下注记录也需要遍历处理。
//如果是其他状态下仅发生了状态变化,则需要恢复游戏状态,并更新游戏记录。
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
GameID
,
log
.
PreIndex
))
game
:=
log
.
Game
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
PreIndex
))
log
.
Game
=
nil
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
GameID
,
log
.
PreIndex
))
//先回滚游戏信息,再进行更新
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
Status
,
log
.
Index
))
g
.
rollbackGame
(
game
,
log
)
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
Index
))
err
=
tablejoin
.
MustGetTable
(
"game"
)
.
Replace
(
game
)
if
err
!=
nil
{
//从game中遍历每个地址的记录进行删除新增记录,回复老记录
return
nil
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
log
.
GameID
)
if
err
==
nil
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
log
.
GameID
,
player
.
Bet
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
Index
))
}
}
}
kvs
,
_
=
tablejoin
.
Save
()
}
}
return
kvs
return
kvs
...
@@ -62,8 +114,7 @@ func (g *Guess) execDelLocal(receipt *types.ReceiptData) (*types.LocalDBSet, err
...
@@ -62,8 +114,7 @@ func (g *Guess) execDelLocal(receipt *types.ReceiptData) (*types.LocalDBSet, err
return
dbSet
,
nil
return
dbSet
,
nil
}
}
/*
for
_
,
log
:=
range
receipt
.
Logs
{
for _, log := range receiptData.Logs {
switch
log
.
GetTy
()
{
switch
log
.
GetTy
()
{
case
gty
.
TyLogGuessGameStart
,
gty
.
TyLogGuessGameBet
,
gty
.
TyLogGuessGameStopBet
,
gty
.
TyLogGuessGameAbort
,
gty
.
TyLogGuessGamePublish
,
gty
.
TyLogGuessGameTimeout
:
case
gty
.
TyLogGuessGameStart
,
gty
.
TyLogGuessGameBet
,
gty
.
TyLogGuessGameStopBet
,
gty
.
TyLogGuessGameAbort
,
gty
.
TyLogGuessGamePublish
,
gty
.
TyLogGuessGameTimeout
:
receiptGame
:=
&
gty
.
ReceiptGuessGame
{}
receiptGame
:=
&
gty
.
ReceiptGuessGame
{}
...
@@ -73,28 +124,8 @@ func (g *Guess) execDelLocal(receipt *types.ReceiptData) (*types.LocalDBSet, err
...
@@ -73,28 +124,8 @@ func (g *Guess) execDelLocal(receipt *types.ReceiptData) (*types.LocalDBSet, err
kv
:=
g
.
rollbackIndex
(
receiptGame
)
kv
:=
g
.
rollbackIndex
(
receiptGame
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kv
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kv
...
)
}
}
}*/
table
:=
gty
.
NewTable
(
g
.
GetLocalDB
())
for
_
,
item
:=
range
receipt
.
Logs
{
var
gameLog
gty
.
ReceiptGuessGame
err
:=
types
.
Decode
(
item
.
Log
,
&
gameLog
)
if
err
!=
nil
{
return
nil
,
err
}
gameLog
.
Status
=
gameLog
.
PreStatus
gameLog
.
Index
=
gameLog
.
PreIndex
err
=
table
.
Replace
(
&
gameLog
)
if
err
!=
nil
{
return
nil
,
err
}
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
}
}
return
dbSet
,
nil
return
dbSet
,
nil
}
}
...
...
plugin/dapp/guess/executor/exec_local.go
View file @
4da6c484
...
@@ -5,51 +5,75 @@
...
@@ -5,51 +5,75 @@
package
executor
package
executor
import
(
import
(
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
)
func
(
g
*
Guess
)
getUserBet
(
log
*
gty
.
ReceiptGuessGame
)
(
userBet
*
gty
.
UserBet
)
{
userBet
=
&
gty
.
UserBet
{}
userBet
.
StartIndex
=
log
.
StartIndex
userBet
.
Index
=
log
.
Index
userBet
.
GameID
=
log
.
GameID
userBet
.
Addr
=
log
.
Addr
if
log
.
Bet
{
userBet
.
Option
=
log
.
Option
userBet
.
BetsNumber
=
log
.
BetsNumber
}
return
userBet
}
func
(
g
*
Guess
)
updateIndex
(
log
*
gty
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
func
(
g
*
Guess
)
updateIndex
(
log
*
gty
.
ReceiptGuessGame
)
(
kvs
[]
*
types
.
KeyValue
)
{
//新创建游戏
userTable
:=
gty
.
NewGuessUserTable
(
g
.
GetLocalDB
())
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
tablejoin
,
err
:=
table
.
NewJoinTable
(
userTable
,
gameTable
,
[]
string
{
"addr#status"
})
if
err
!=
nil
{
return
nil
}
if
log
.
Status
==
gty
.
GuessGameStatusStart
{
if
log
.
Status
==
gty
.
GuessGameStatusStart
{
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
//新创建游戏,game表新增记录
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameID
,
log
.
Index
))
game
:=
log
.
Game
kvs
=
append
(
kvs
,
addGuessGameAdminIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
Index
))
log
.
Game
=
nil
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
Index
))
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameID
,
log
.
Index
))
err
=
tablejoin
.
MustGetTable
(
"game"
)
.
Replace
(
game
)
if
err
!=
nil
{
return
nil
}
kvs
,
_
=
tablejoin
.
Save
()
return
kvs
}
else
if
log
.
Status
==
gty
.
GuessGameStatusBet
{
}
else
if
log
.
Status
==
gty
.
GuessGameStatusBet
{
//如果是下注状态,则有用户进行了下注操作
//用户下注,game表发生更新(game中下注信息有更新),user表新增下注记录
kvs
=
append
(
kvs
,
addGuessGameAddrIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameID
,
log
.
Index
))
game
:=
log
.
Game
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
log
.
Addr
,
log
.
GameID
,
log
.
Index
))
log
.
Game
=
nil
//如果发生了状态变化,则是从start->bet,对于老状态的记录进行删除操作,并增加新状态记录
userBet
:=
g
.
getUserBet
(
log
)
if
log
.
StatusChange
{
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameID
,
log
.
Index
))
err
=
tablejoin
.
MustGetTable
(
"game"
)
.
Replace
(
game
)
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
Index
))
if
err
!=
nil
{
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameID
,
log
.
Index
))
return
nil
}
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
PreIndex
))
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
PreIndex
))
err
=
tablejoin
.
MustGetTable
(
"user"
)
.
Replace
(
userBet
)
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
PreIndex
))
if
err
!=
nil
{
return
nil
}
}
kvs
,
_
=
tablejoin
.
Save
()
return
kvs
}
else
if
log
.
StatusChange
{
}
else
if
log
.
StatusChange
{
//其他状态时的状态发生变化,要将老状态对应的记录删除,同时加入新状态记录;对于每个地址的下注记录也需要遍历处理。
//其他状态,游戏状态变化,只需要更新game表
kvs
=
append
(
kvs
,
addGuessGameStatusIndexKey
(
log
.
Status
,
log
.
GameID
,
log
.
Index
))
game
:=
log
.
Game
kvs
=
append
(
kvs
,
addGuessGameAdminStatusIndexKey
(
log
.
Status
,
log
.
AdminAddr
,
log
.
GameID
,
log
.
Index
))
log
.
Game
=
nil
kvs
=
append
(
kvs
,
addGuessGameCategoryStatusIndexKey
(
log
.
Status
,
log
.
Category
,
log
.
GameID
,
log
.
Index
))
err
=
tablejoin
.
MustGetTable
(
"game"
)
.
Replace
(
game
)
kvs
=
append
(
kvs
,
delGuessGameStatusIndexKey
(
log
.
PreStatus
,
log
.
PreIndex
))
if
err
!=
nil
{
kvs
=
append
(
kvs
,
delGuessGameAdminStatusIndexKey
(
log
.
PreStatus
,
log
.
AdminAddr
,
log
.
PreIndex
))
return
nil
kvs
=
append
(
kvs
,
delGuessGameCategoryStatusIndexKey
(
log
.
PreStatus
,
log
.
Category
,
log
.
PreIndex
))
//从game中遍历每个地址的记录进行新状态记录的增和老状态记录的删除
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
log
.
GameID
)
if
err
==
nil
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
kvs
=
append
(
kvs
,
addGuessGameAddrStatusIndexKey
(
log
.
Status
,
player
.
Addr
,
log
.
GameID
,
log
.
Index
))
kvs
=
append
(
kvs
,
delGuessGameAddrStatusIndexKey
(
log
.
PreStatus
,
player
.
Addr
,
player
.
Bet
.
PreIndex
))
}
}
}
kvs
,
_
=
tablejoin
.
Save
()
return
kvs
}
}
return
kvs
return
kvs
...
@@ -61,22 +85,6 @@ func (g *Guess) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error)
...
@@ -61,22 +85,6 @@ func (g *Guess) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error)
return
dbSet
,
nil
return
dbSet
,
nil
}
}
/*
for i := 0; i < len(receipt.Logs); i++ {
item := receipt.Logs[i]
if item.Ty >= gty.TyLogGuessGameStart && item.Ty <= gty.TyLogGuessGameTimeout {
var Gamelog gty.ReceiptGuessGame
err := types.Decode(item.Log, &Gamelog)
if err != nil {
panic(err) //数据错误了,已经被修改了
}
kv := g.updateIndex(&Gamelog)
dbSet.KV = append(dbSet.KV, kv...)
}
}
*/
table
:=
gty
.
NewTable
(
g
.
GetLocalDB
())
for
_
,
item
:=
range
receipt
.
Logs
{
for
_
,
item
:=
range
receipt
.
Logs
{
if
item
.
Ty
>=
gty
.
TyLogGuessGameStart
&&
item
.
Ty
<=
gty
.
TyLogGuessGameTimeout
{
if
item
.
Ty
>=
gty
.
TyLogGuessGameStart
&&
item
.
Ty
<=
gty
.
TyLogGuessGameTimeout
{
var
gameLog
gty
.
ReceiptGuessGame
var
gameLog
gty
.
ReceiptGuessGame
...
@@ -84,14 +92,7 @@ func (g *Guess) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error)
...
@@ -84,14 +92,7 @@ func (g *Guess) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
err
=
table
.
Replace
(
&
gameLog
)
kvs
:=
g
.
updateIndex
(
&
gameLog
)
if
err
!=
nil
{
return
nil
,
err
}
kvs
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
dbSet
.
KV
=
append
(
dbSet
.
KV
,
kvs
...
)
}
}
}
}
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
4da6c484
...
@@ -7,6 +7,8 @@ package executor
...
@@ -7,6 +7,8 @@ package executor
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"strings"
"strings"
"time"
"time"
...
@@ -62,7 +64,7 @@ type Action struct {
...
@@ -62,7 +64,7 @@ type Action struct {
blocktime
int64
blocktime
int64
height
int64
height
int64
execaddr
string
execaddr
string
localDB
dbm
.
Lister
localDB
dbm
.
KVDB
index
int
index
int
api
client
.
QueueProtocolAPI
api
client
.
QueueProtocolAPI
conn
*
grpc
.
ClientConn
conn
*
grpc
.
ClientConn
...
@@ -120,184 +122,117 @@ func Key(id string) (key []byte) {
...
@@ -120,184 +122,117 @@ func Key(id string) (key []byte) {
return
key
return
key
}
}
func
readGame
(
db
dbm
.
KV
,
id
string
)
(
*
gty
.
GuessGame
,
error
)
{
data
,
err
:=
db
.
Get
(
Key
(
id
))
if
err
!=
nil
{
logger
.
Error
(
"query data have err:"
,
err
.
Error
())
return
nil
,
err
}
var
game
gty
.
GuessGame
//decode
err
=
types
.
Decode
(
data
,
&
game
)
if
err
!=
nil
{
logger
.
Error
(
"decode game have err:"
,
err
.
Error
())
return
nil
,
err
}
return
&
game
,
nil
}
//Infos 根据游戏id列表查询多个游戏详情信息
//Infos 根据游戏id列表查询多个游戏详情信息
func
Infos
(
db
dbm
.
KV
,
infos
*
gty
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
func
QueryGameInfos
(
kvdb
db
.
KVDB
,
infos
*
gty
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
var
games
[]
*
gty
.
GuessGame
var
games
[]
*
gty
.
GuessGame
gameTable
:=
gty
.
NewGuessGameTable
(
kvdb
)
query
:=
gameTable
.
GetQuery
(
kvdb
)
for
i
:=
0
;
i
<
len
(
infos
.
GameIDs
);
i
++
{
for
i
:=
0
;
i
<
len
(
infos
.
GameIDs
);
i
++
{
id
:=
infos
.
GameIDs
[
i
]
rows
,
err
:=
query
.
ListIndex
(
"gameid"
,
[]
byte
(
infos
.
GameIDs
[
i
]),
nil
,
1
,
0
)
game
,
err
:=
readGame
(
db
,
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
game
:=
rows
[
0
]
.
Data
.
(
*
gty
.
GuessGame
)
games
=
append
(
games
,
game
)
games
=
append
(
games
,
game
)
}
}
return
&
gty
.
ReplyGuessGameInfos
{
Games
:
games
},
nil
return
&
gty
.
ReplyGuessGameInfos
{
Games
:
games
},
nil
}
}
func
getGameListByAddr
(
db
dbm
.
Lister
,
addr
string
,
index
int64
)
(
types
.
Message
,
error
)
{
//QueryGameInfo 根据gameid查询game信息
var
values
[][]
byte
func
QueryGameInfo
(
kvdb
db
.
KVDB
,
gameID
[]
byte
)
(
*
gty
.
GuessGame
,
error
)
{
var
err
error
gameTable
:=
gty
.
NewGuessGameTable
(
kvdb
)
if
index
==
0
{
query
:=
gameTable
.
GetQuery
(
kvdb
)
values
,
err
=
db
.
List
(
calcGuessGameAddrPrefix
(
addr
),
nil
,
DefaultCount
,
ListDESC
)
rows
,
err
:=
query
.
ListIndex
(
"gameid"
,
gameID
,
nil
,
1
,
0
)
}
else
{
values
,
err
=
db
.
List
(
calcGuessGameAddrPrefix
(
addr
),
calcGuessGameAddrKey
(
addr
,
index
),
DefaultCount
,
ListDESC
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
records
[]
*
gty
.
GuessGameRecord
game
:=
rows
[
0
]
.
Data
.
(
*
gty
.
GuessGame
)
for
_
,
value
:=
range
values
{
var
record
gty
.
GuessGameRecord
err
:=
types
.
Decode
(
value
,
&
record
)
if
err
!=
nil
{
continue
}
records
=
append
(
records
,
&
record
)
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
}
,
nil
return
game
,
nil
}
}
func
getGameListByAdminAddr
(
db
dbm
.
Lister
,
addr
string
,
index
int64
)
(
types
.
Message
,
error
)
{
//QueryUserTableData 查询user表数据
var
values
[][]
byte
func
QueryUserTableData
(
query
*
table
.
Query
,
indexName
string
,
prefix
,
primaryKey
[]
byte
)
(
types
.
Message
,
error
)
{
var
err
error
rows
,
err
:=
query
.
ListIndex
(
indexName
,
prefix
,
primaryKey
,
DefaultCount
,
0
)
if
index
==
0
{
values
,
err
=
db
.
List
(
calcGuessGameAdminPrefix
(
addr
),
nil
,
DefaultCount
,
ListDESC
)
}
else
{
values
,
err
=
db
.
List
(
calcGuessGameAdminPrefix
(
addr
),
calcGuessGameAdminKey
(
addr
,
index
),
DefaultCount
,
ListDESC
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
records
[]
*
gty
.
GuessGameRecord
var
records
[]
*
gty
.
GuessGameRecord
for
_
,
value
:=
range
values
{
for
i
:=
0
;
i
<
len
(
rows
);
i
++
{
userBet
:=
rows
[
i
]
.
Data
.
(
*
gty
.
UserBet
)
var
record
gty
.
GuessGameRecord
var
record
gty
.
GuessGameRecord
err
:=
types
.
Decode
(
value
,
&
record
)
record
.
GameID
=
userBet
.
GameID
if
err
!=
nil
{
record
.
StartIndex
=
userBet
.
StartIndex
continue
}
records
=
append
(
records
,
&
record
)
records
=
append
(
records
,
&
record
)
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
},
nil
var
primary
[]
byte
}
if
len
(
rows
)
==
int
(
DefaultCount
)
{
primary
=
rows
[
len
(
rows
)
-
1
]
.
Primary
func
getGameListByStatus
(
db
dbm
.
Lister
,
status
int32
,
index
int64
)
(
types
.
Message
,
error
)
{
var
values
[][]
byte
var
err
error
if
index
==
0
{
values
,
err
=
db
.
List
(
calcGuessGameStatusPrefix
(
status
),
nil
,
DefaultCount
,
ListDESC
)
}
else
{
}
else
{
values
,
err
=
db
.
List
(
calcGuessGameStatusPrefix
(
status
),
calcGuessGameStatusKey
(
status
,
index
),
DefaultCount
,
ListDESC
)
primary
=
nil
}
if
err
!=
nil
{
return
nil
,
err
}
var
records
[]
*
gty
.
GuessGameRecord
for
_
,
value
:=
range
values
{
var
record
gty
.
GuessGameRecord
err
:=
types
.
Decode
(
value
,
&
record
)
if
err
!=
nil
{
continue
}
records
=
append
(
records
,
&
record
)
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
},
nil
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
}
}
func
getGameListByAddrStatus
(
db
dbm
.
Lister
,
addr
string
,
status
int32
,
index
int64
)
(
types
.
Message
,
error
)
{
//QueryGameTableData 查询game表数据
var
values
[][]
byte
func
QueryGameTableData
(
query
*
table
.
Query
,
indexName
string
,
prefix
,
primaryKey
[]
byte
)
(
types
.
Message
,
error
)
{
var
err
error
rows
,
err
:=
query
.
ListIndex
(
indexName
,
prefix
,
primaryKey
,
DefaultCount
,
0
)
if
index
==
0
{
values
,
err
=
db
.
List
(
calcGuessGameAddrStatusPrefix
(
addr
,
status
),
nil
,
DefaultCount
,
ListDESC
)
}
else
{
values
,
err
=
db
.
List
(
calcGuessGameAddrStatusPrefix
(
addr
,
status
),
calcGuessGameAddrStatusKey
(
addr
,
status
,
index
),
DefaultCount
,
ListDESC
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
records
[]
*
gty
.
GuessGameRecord
var
records
[]
*
gty
.
GuessGameRecord
for
_
,
value
:=
range
values
{
for
i
:=
0
;
i
<
len
(
rows
);
i
++
{
game
:=
rows
[
i
]
.
Data
.
(
*
gty
.
GuessGame
)
var
record
gty
.
GuessGameRecord
var
record
gty
.
GuessGameRecord
err
:=
types
.
Decode
(
value
,
&
record
)
record
.
GameID
=
game
.
GameID
if
err
!=
nil
{
record
.
StartIndex
=
game
.
StartIndex
continue
}
records
=
append
(
records
,
&
record
)
records
=
append
(
records
,
&
record
)
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
},
nil
var
primary
[]
byte
}
if
len
(
rows
)
==
int
(
DefaultCount
)
{
primary
=
rows
[
len
(
rows
)
-
1
]
.
Primary
func
getGameListByAdminStatus
(
db
dbm
.
Lister
,
admin
string
,
status
int32
,
index
int64
)
(
types
.
Message
,
error
)
{
var
values
[][]
byte
var
err
error
if
index
==
0
{
values
,
err
=
db
.
List
(
calcGuessGameAdminStatusPrefix
(
admin
,
status
),
nil
,
DefaultCount
,
ListDESC
)
}
else
{
}
else
{
values
,
err
=
db
.
List
(
calcGuessGameAdminStatusPrefix
(
admin
,
status
),
calcGuessGameAdminStatusKey
(
admin
,
status
,
index
),
DefaultCount
,
ListDESC
)
primary
=
nil
}
if
err
!=
nil
{
return
nil
,
err
}
var
records
[]
*
gty
.
GuessGameRecord
for
_
,
value
:=
range
values
{
var
record
gty
.
GuessGameRecord
err
:=
types
.
Decode
(
value
,
&
record
)
if
err
!=
nil
{
continue
}
records
=
append
(
records
,
&
record
)
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
},
nil
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
}
}
func
getGameListByCategoryStatus
(
db
dbm
.
Lister
,
category
string
,
status
int32
,
index
int64
)
(
types
.
Message
,
error
)
{
//QueryJoinTableData 查询join表数据
var
values
[][]
byte
func
QueryJoinTableData
(
talbeJoin
*
table
.
JoinTable
,
indexName
string
,
prefix
,
primaryKey
[]
byte
)
(
types
.
Message
,
error
)
{
var
err
error
rows
,
err
:=
talbeJoin
.
ListIndex
(
indexName
,
prefix
,
primaryKey
,
DefaultCount
,
0
)
if
index
==
0
{
values
,
err
=
db
.
List
(
calcGuessGameCategoryStatusPrefix
(
category
,
status
),
nil
,
DefaultCount
,
ListDESC
)
}
else
{
values
,
err
=
db
.
List
(
calcGuessGameCategoryStatusPrefix
(
category
,
status
),
calcGuessGameCategoryStatusKey
(
category
,
status
,
index
),
DefaultCount
,
ListDESC
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
var
records
[]
*
gty
.
GuessGameRecord
var
records
[]
*
gty
.
GuessGameRecord
for
_
,
value
:=
range
values
{
for
i
:=
0
;
i
<
len
(
rows
);
i
++
{
game
:=
rows
[
i
]
.
Data
.
(
*
table
.
JoinData
)
.
Right
.
(
*
gty
.
GuessGame
)
var
record
gty
.
GuessGameRecord
var
record
gty
.
GuessGameRecord
err
:=
types
.
Decode
(
value
,
&
record
)
record
.
GameID
=
game
.
GameID
if
err
!=
nil
{
record
.
StartIndex
=
game
.
StartIndex
continue
}
records
=
append
(
records
,
&
record
)
records
=
append
(
records
,
&
record
)
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
},
nil
var
primary
[]
byte
if
len
(
rows
)
==
int
(
DefaultCount
)
{
primary
=
rows
[
len
(
rows
)
-
1
]
.
Primary
}
else
{
primary
=
nil
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
}
}
func
(
action
*
Action
)
saveGame
(
game
*
gty
.
GuessGame
)
(
kvset
[]
*
types
.
KeyValue
)
{
func
(
action
*
Action
)
saveGame
(
game
*
gty
.
GuessGame
)
(
kvset
[]
*
types
.
KeyValue
)
{
...
@@ -311,8 +246,8 @@ func (action *Action) getIndex() int64 {
...
@@ -311,8 +246,8 @@ func (action *Action) getIndex() int64 {
return
action
.
height
*
types
.
MaxTxsPerBlock
+
int64
(
action
.
index
)
return
action
.
height
*
types
.
MaxTxsPerBlock
+
int64
(
action
.
index
)
}
}
//
G
etReceiptLog 根据游戏信息生成收据记录
//
g
etReceiptLog 根据游戏信息生成收据记录
func
(
action
*
Action
)
GetReceiptLog
(
game
*
gty
.
GuessGame
,
statusChange
bool
)
*
types
.
ReceiptLog
{
func
(
action
*
Action
)
getReceiptLog
(
game
*
gty
.
GuessGame
,
statusChange
bool
,
bet
*
gty
.
GuessGameBet
)
*
types
.
ReceiptLog
{
log
:=
&
types
.
ReceiptLog
{}
log
:=
&
types
.
ReceiptLog
{}
r
:=
&
gty
.
ReceiptGuessGame
{}
r
:=
&
gty
.
ReceiptGuessGame
{}
r
.
Addr
=
action
.
fromaddr
r
.
Addr
=
action
.
fromaddr
...
@@ -330,7 +265,8 @@ func (action *Action) GetReceiptLog(game *gty.GuessGame, statusChange bool) *typ
...
@@ -330,7 +265,8 @@ func (action *Action) GetReceiptLog(game *gty.GuessGame, statusChange bool) *typ
log
.
Ty
=
gty
.
TyLogGuessGameTimeout
log
.
Ty
=
gty
.
TyLogGuessGameTimeout
}
}
r
.
Index
=
game
.
Index
r
.
StartIndex
=
game
.
StartIndex
r
.
Index
=
action
.
getIndex
()
r
.
GameID
=
game
.
GameID
r
.
GameID
=
game
.
GameID
r
.
Status
=
game
.
Status
r
.
Status
=
game
.
Status
r
.
AdminAddr
=
game
.
AdminAddr
r
.
AdminAddr
=
game
.
AdminAddr
...
@@ -338,6 +274,12 @@ func (action *Action) GetReceiptLog(game *gty.GuessGame, statusChange bool) *typ
...
@@ -338,6 +274,12 @@ func (action *Action) GetReceiptLog(game *gty.GuessGame, statusChange bool) *typ
r
.
StatusChange
=
statusChange
r
.
StatusChange
=
statusChange
r
.
PreIndex
=
game
.
PreIndex
r
.
PreIndex
=
game
.
PreIndex
r
.
Category
=
game
.
Category
r
.
Category
=
game
.
Category
if
nil
!=
bet
{
r
.
Bet
=
true
r
.
Option
=
bet
.
Option
r
.
BetsNumber
=
bet
.
BetsNum
}
r
.
Game
=
game
log
.
Log
=
types
.
Encode
(
r
)
log
.
Log
=
types
.
Encode
(
r
)
return
log
return
log
}
}
...
@@ -412,14 +354,14 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
...
@@ -412,14 +354,14 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
options
,
ok
:=
G
etOptions
(
start
.
Options
)
options
,
ok
:=
g
etOptions
(
start
.
Options
)
if
!
ok
{
if
!
ok
{
logger
.
Error
(
"GameStart"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
logger
.
Error
(
"GameStart"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"err"
,
fmt
.
Sprintf
(
"The options is illegal:%s"
,
start
.
Options
))
"err"
,
fmt
.
Sprintf
(
"The options is illegal:%s"
,
start
.
Options
))
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
if
!
action
.
C
heckTime
(
start
)
{
if
!
action
.
c
heckTime
(
start
)
{
logger
.
Error
(
"GameStart"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
logger
.
Error
(
"GameStart"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"err"
,
fmt
.
Sprintf
(
"The height and time parameters are illegal:MaxHeight %d ,ExpireHeight %d"
,
start
.
MaxBetHeight
,
start
.
ExpireHeight
))
"err"
,
fmt
.
Sprintf
(
"The height and time parameters are illegal:MaxHeight %d ,ExpireHeight %d"
,
start
.
MaxBetHeight
,
start
.
ExpireHeight
))
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
@@ -449,6 +391,7 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
...
@@ -449,6 +391,7 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
game
.
AdminAddr
=
action
.
fromaddr
game
.
AdminAddr
=
action
.
fromaddr
game
.
PreIndex
=
0
game
.
PreIndex
=
0
game
.
Index
=
action
.
getIndex
()
game
.
Index
=
action
.
getIndex
()
game
.
StartIndex
=
game
.
Index
game
.
Status
=
gty
.
GuessGameStatusStart
game
.
Status
=
gty
.
GuessGameStatusStart
game
.
BetStat
=
&
gty
.
GuessBetStat
{
TotalBetTimes
:
0
,
TotalBetsNumber
:
0
}
game
.
BetStat
=
&
gty
.
GuessBetStat
{
TotalBetTimes
:
0
,
TotalBetsNumber
:
0
}
for
i
:=
0
;
i
<
len
(
options
);
i
++
{
for
i
:=
0
;
i
<
len
(
options
);
i
++
{
...
@@ -456,8 +399,10 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
...
@@ -456,8 +399,10 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
game
.
BetStat
.
Items
=
append
(
game
.
BetStat
.
Items
,
item
)
game
.
BetStat
.
Items
=
append
(
game
.
BetStat
.
Items
,
item
)
}
}
receiptLog
:=
action
.
GetReceiptLog
(
game
,
false
)
receiptLog
:=
action
.
getReceiptLog
(
game
,
false
,
nil
)
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
//对于写入statedb中的信息,去除下注信息,只记录主要信息,因为参与用户量大时在不同区块中反复记录这些数据会占用比较多的存储空间,意义不大
game
.
Plays
=
nil
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
...
@@ -468,8 +413,8 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -468,8 +413,8 @@ func (action *Action) GameBet(pbBet *gty.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
.
GetGameID
(
))
game
,
err
:=
QueryGameInfo
(
action
.
localDB
,
[]
byte
(
pbBet
.
GetGameID
()
))
if
err
!=
nil
{
if
err
!=
nil
||
game
==
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
.
GetGameID
(),
"err"
,
err
)
pbBet
.
GetGameID
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -482,16 +427,16 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -482,16 +427,16 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
return
nil
,
gty
.
ErrGuessStatus
return
nil
,
gty
.
ErrGuessStatus
}
}
canBet
:=
action
.
R
efreshStatusByTime
(
game
)
canBet
:=
action
.
r
efreshStatusByTime
(
game
)
if
!
canBet
{
if
!
canBet
{
var
receiptLog
*
types
.
ReceiptLog
var
receiptLog
*
types
.
ReceiptLog
if
prevStatus
!=
game
.
Status
{
if
prevStatus
!=
game
.
Status
{
//状态发生了变化,且是变到了不可下注的状态,那么对于所有下注的addr来说,其addr:status主键的数据都需要更新
//状态发生了变化,且是变到了不可下注的状态,那么对于所有下注的addr来说,其addr:status主键的数据都需要更新
action
.
C
hangeAllAddrIndex
(
game
)
action
.
c
hangeAllAddrIndex
(
game
)
receiptLog
=
action
.
GetReceiptLog
(
game
,
true
)
receiptLog
=
action
.
getReceiptLog
(
game
,
true
,
nil
)
}
else
{
}
else
{
receiptLog
=
action
.
GetReceiptLog
(
game
,
false
)
receiptLog
=
action
.
getReceiptLog
(
game
,
false
,
nil
)
}
}
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
...
@@ -501,14 +446,14 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -501,14 +446,14 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
}
}
//检查竞猜选项是否合法
//检查竞猜选项是否合法
options
,
legal
:=
G
etOptions
(
game
.
GetOptions
())
options
,
legal
:=
g
etOptions
(
game
.
GetOptions
())
if
!
legal
||
len
(
options
)
==
0
{
if
!
legal
||
len
(
options
)
==
0
{
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Game Options illegal"
,
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Game Options illegal"
,
game
.
GetOptions
())
game
.
GetOptions
())
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
if
!
I
sLegalOption
(
options
,
pbBet
.
GetOption
())
{
if
!
i
sLegalOption
(
options
,
pbBet
.
GetOption
())
{
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Option illegal"
,
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Option illegal"
,
pbBet
.
GetOption
())
pbBet
.
GetOption
())
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
@@ -519,7 +464,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -519,7 +464,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
pbBet
.
BetsNum
=
game
.
GetMaxBetsOneTime
()
pbBet
.
BetsNum
=
game
.
GetMaxBetsOneTime
()
}
}
if
game
.
BetsNumber
+
pbBet
.
GetBetsNum
()
>
game
.
MaxBetsNumber
{
if
game
.
BetsNumber
+
pbBet
.
GetBetsNum
()
>
game
.
MaxBetsNumber
{
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"MaxBetsNumber over limit"
,
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"MaxBetsNumber over limit"
,
game
.
MaxBetsNumber
,
"current Bets Number"
,
game
.
BetsNumber
)
game
.
MaxBetsNumber
,
"current Bets Number"
,
game
.
BetsNumber
)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
@@ -543,15 +488,17 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -543,15 +488,17 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
var
receiptLog
*
types
.
ReceiptLog
var
receiptLog
*
types
.
ReceiptLog
if
prevStatus
!=
gty
.
GuessGameStatusBet
{
if
prevStatus
!=
gty
.
GuessGameStatusBet
{
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusBet
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusBet
)
action
.
A
ddGuessBet
(
game
,
pbBet
)
action
.
a
ddGuessBet
(
game
,
pbBet
)
receiptLog
=
action
.
GetReceiptLog
(
game
,
true
)
receiptLog
=
action
.
getReceiptLog
(
game
,
true
,
pbBet
)
}
else
{
}
else
{
action
.
A
ddGuessBet
(
game
,
pbBet
)
action
.
a
ddGuessBet
(
game
,
pbBet
)
receiptLog
=
action
.
GetReceiptLog
(
game
,
false
)
receiptLog
=
action
.
getReceiptLog
(
game
,
false
,
pbBet
)
}
}
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
//对于写入statedb中的信息,去除下注信息,只记录主要信息,因为参与用户量大时在不同区块中反复记录这些数据会占用比较多的存储空间,意义不大
game
.
Plays
=
nil
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
...
@@ -562,8 +509,8 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
...
@@ -562,8 +509,8 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameID
(
))
game
,
err
:=
QueryGameInfo
(
action
.
localDB
,
[]
byte
(
pbBet
.
GetGameID
()
))
if
err
!=
nil
{
if
err
!=
nil
||
game
==
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
.
GetGameID
(),
"err"
,
err
)
pbBet
.
GetGameID
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -582,22 +529,24 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
...
@@ -582,22 +529,24 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
return
nil
,
gty
.
ErrNoPrivilege
return
nil
,
gty
.
ErrNoPrivilege
}
}
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusStopBet
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusStopBet
)
var
receiptLog
*
types
.
ReceiptLog
var
receiptLog
*
types
.
ReceiptLog
//状态发生变化,更新所有addr对应记录的index
//状态发生变化,更新所有addr对应记录的index
action
.
C
hangeAllAddrIndex
(
game
)
action
.
c
hangeAllAddrIndex
(
game
)
receiptLog
=
action
.
GetReceiptLog
(
game
,
true
)
receiptLog
=
action
.
getReceiptLog
(
game
,
true
,
nil
)
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
//对于写入statedb中的信息,去除下注信息,只记录主要信息,因为参与用户量大时在不同区块中反复记录这些数据会占用比较多的存储空间,意义不大
game
.
Plays
=
nil
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
//
A
ddGuessBet 向游戏结构中加入下注信息
//
a
ddGuessBet 向游戏结构中加入下注信息
func
(
action
*
Action
)
A
ddGuessBet
(
game
*
gty
.
GuessGame
,
pbBet
*
gty
.
GuessGameBet
)
{
func
(
action
*
Action
)
a
ddGuessBet
(
game
*
gty
.
GuessGame
,
pbBet
*
gty
.
GuessGameBet
)
{
bet
:=
&
gty
.
GuessBet
{
Option
:
pbBet
.
GetOption
(),
BetsNumber
:
pbBet
.
BetsNum
,
Index
:
game
.
Index
}
bet
:=
&
gty
.
GuessBet
{
Option
:
pbBet
.
GetOption
(),
BetsNumber
:
pbBet
.
BetsNum
,
Index
:
action
.
getIndex
()
}
player
:=
&
gty
.
GuessPlayer
{
Addr
:
action
.
fromaddr
,
Bet
:
bet
}
player
:=
&
gty
.
GuessPlayer
{
Addr
:
action
.
fromaddr
,
Bet
:
bet
}
game
.
Plays
=
append
(
game
.
Plays
,
player
)
game
.
Plays
=
append
(
game
.
Plays
,
player
)
...
@@ -622,8 +571,8 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
...
@@ -622,8 +571,8 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
var
logs
[]
*
types
.
ReceiptLog
var
logs
[]
*
types
.
ReceiptLog
var
kv
[]
*
types
.
KeyValue
var
kv
[]
*
types
.
KeyValue
game
,
err
:=
action
.
readGame
(
publish
.
GetGameID
(
))
game
,
err
:=
QueryGameInfo
(
action
.
localDB
,
[]
byte
(
publish
.
GetGameID
()
))
if
err
!=
nil
{
if
err
!=
nil
||
game
==
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
.
GetGameID
(),
"err"
,
err
)
publish
.
GetGameID
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -643,14 +592,14 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
...
@@ -643,14 +592,14 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
}
}
//检查竞猜选项是否合法
//检查竞猜选项是否合法
options
,
legal
:=
G
etOptions
(
game
.
GetOptions
())
options
,
legal
:=
g
etOptions
(
game
.
GetOptions
())
if
!
legal
||
len
(
options
)
==
0
{
if
!
legal
||
len
(
options
)
==
0
{
logger
.
Error
(
"GamePublish"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Game Options illegal"
,
logger
.
Error
(
"GamePublish"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Game Options illegal"
,
game
.
GetOptions
())
game
.
GetOptions
())
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
if
!
I
sLegalOption
(
options
,
publish
.
GetResult
())
{
if
!
i
sLegalOption
(
options
,
publish
.
GetResult
())
{
logger
.
Error
(
"GamePublish"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Option illegal"
,
logger
.
Error
(
"GamePublish"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Option illegal"
,
publish
.
GetResult
())
publish
.
GetResult
())
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
...
@@ -682,7 +631,7 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
...
@@ -682,7 +631,7 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
kv
=
append
(
kv
,
receipt
.
KV
...
)
kv
=
append
(
kv
,
receipt
.
KV
...
)
}
}
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusPublish
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusPublish
)
//计算竞猜正确的筹码总数
//计算竞猜正确的筹码总数
totalBetsNumber
:=
game
.
BetStat
.
TotalBetsNumber
totalBetsNumber
:=
game
.
BetStat
.
TotalBetsNumber
winBetsNumber
:=
int64
(
0
)
winBetsNumber
:=
int64
(
0
)
...
@@ -752,10 +701,12 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
...
@@ -752,10 +701,12 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
}
}
var
receiptLog
*
types
.
ReceiptLog
var
receiptLog
*
types
.
ReceiptLog
action
.
C
hangeAllAddrIndex
(
game
)
action
.
c
hangeAllAddrIndex
(
game
)
receiptLog
=
action
.
GetReceiptLog
(
game
,
true
)
receiptLog
=
action
.
getReceiptLog
(
game
,
true
,
nil
)
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
//对于写入statedb中的信息,去除下注信息,只记录主要信息,因为参与用户量大时在不同区块中反复记录这些数据会占用比较多的存储空间,意义不大
game
.
Plays
=
nil
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
...
@@ -766,8 +717,8 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
...
@@ -766,8 +717,8 @@ func (action *Action) GameAbort(pbend *gty.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
.
GetGameID
(
))
game
,
err
:=
QueryGameInfo
(
action
.
localDB
,
[]
byte
(
pbend
.
GetGameID
()
))
if
err
!=
nil
{
if
err
!=
nil
||
game
==
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
.
GetGameID
(),
"err"
,
err
)
pbend
.
GetGameID
(),
"err"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -782,7 +733,7 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
...
@@ -782,7 +733,7 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
preStatus
:=
game
.
Status
preStatus
:=
game
.
Status
//根据区块链高度或时间刷新游戏状态。
//根据区块链高度或时间刷新游戏状态。
action
.
R
efreshStatusByTime
(
game
)
action
.
r
efreshStatusByTime
(
game
)
//如果游戏超时,则任何地址都可以Abort,否则只有创建游戏的地址可以Abort
//如果游戏超时,则任何地址都可以Abort,否则只有创建游戏的地址可以Abort
if
game
.
Status
!=
gty
.
GuessGameStatusTimeOut
{
if
game
.
Status
!=
gty
.
GuessGameStatusTimeOut
{
...
@@ -814,20 +765,22 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
...
@@ -814,20 +765,22 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
//说明action.RefreshStatusByTime(game)调用时已经更新过状态和index了,这里直接再改状态就行了。
//说明action.RefreshStatusByTime(game)调用时已经更新过状态和index了,这里直接再改状态就行了。
game
.
Status
=
gty
.
GuessGameStatusAbort
game
.
Status
=
gty
.
GuessGameStatusAbort
}
else
{
}
else
{
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusAbort
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusAbort
)
}
}
//状态发生变化,统一更新所有addr记录的index
//状态发生变化,统一更新所有addr记录的index
action
.
C
hangeAllAddrIndex
(
game
)
action
.
c
hangeAllAddrIndex
(
game
)
receiptLog
:=
action
.
GetReceiptLog
(
game
,
true
)
receiptLog
:=
action
.
getReceiptLog
(
game
,
true
,
nil
)
logs
=
append
(
logs
,
receiptLog
)
logs
=
append
(
logs
,
receiptLog
)
//对于写入statedb中的信息,去除下注信息,只记录主要信息,因为参与用户量大时在不同区块中反复记录这些数据会占用比较多的存储空间,意义不大
game
.
Plays
=
nil
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
kv
=
append
(
kv
,
action
.
saveGame
(
game
)
...
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
}
}
//
G
etOptions 获得竞猜选项,并判断是否符合约定格式,类似"A:xxxx;B:xxxx;C:xxx",“:”前为选项名称,不能重复,":"后为选项说明。
//
g
etOptions 获得竞猜选项,并判断是否符合约定格式,类似"A:xxxx;B:xxxx;C:xxx",“:”前为选项名称,不能重复,":"后为选项说明。
func
G
etOptions
(
strOptions
string
)
(
options
[]
string
,
legal
bool
)
{
func
g
etOptions
(
strOptions
string
)
(
options
[]
string
,
legal
bool
)
{
legal
=
true
legal
=
true
items
:=
strings
.
Split
(
strOptions
,
";"
)
items
:=
strings
.
Split
(
strOptions
,
";"
)
for
i
:=
0
;
i
<
len
(
items
);
i
++
{
for
i
:=
0
;
i
<
len
(
items
);
i
++
{
...
@@ -845,8 +798,8 @@ func GetOptions(strOptions string) (options []string, legal bool) {
...
@@ -845,8 +798,8 @@ func GetOptions(strOptions string) (options []string, legal bool) {
return
options
,
legal
return
options
,
legal
}
}
//
I
sLegalOption 判断选项是否为合法选项
//
i
sLegalOption 判断选项是否为合法选项
func
I
sLegalOption
(
options
[]
string
,
option
string
)
bool
{
func
i
sLegalOption
(
options
[]
string
,
option
string
)
bool
{
for
i
:=
0
;
i
<
len
(
options
);
i
++
{
for
i
:=
0
;
i
<
len
(
options
);
i
++
{
if
options
[
i
]
==
option
{
if
options
[
i
]
==
option
{
return
true
return
true
...
@@ -856,8 +809,8 @@ func IsLegalOption(options []string, option string) bool {
...
@@ -856,8 +809,8 @@ func IsLegalOption(options []string, option string) bool {
return
false
return
false
}
}
//
C
hangeStatus 修改游戏状态,同步更新历史记录
//
c
hangeStatus 修改游戏状态,同步更新历史记录
func
(
action
*
Action
)
C
hangeStatus
(
game
*
gty
.
GuessGame
,
destStatus
int32
)
{
func
(
action
*
Action
)
c
hangeStatus
(
game
*
gty
.
GuessGame
,
destStatus
int32
)
{
if
game
.
Status
!=
destStatus
{
if
game
.
Status
!=
destStatus
{
game
.
PreStatus
=
game
.
Status
game
.
PreStatus
=
game
.
Status
game
.
PreIndex
=
game
.
Index
game
.
PreIndex
=
game
.
Index
...
@@ -866,17 +819,17 @@ func (action *Action) ChangeStatus(game *gty.GuessGame, destStatus int32) {
...
@@ -866,17 +819,17 @@ func (action *Action) ChangeStatus(game *gty.GuessGame, destStatus int32) {
}
}
}
}
//
C
hangeAllAddrIndex 状态更新时,更新下注记录的历史信息
//
c
hangeAllAddrIndex 状态更新时,更新下注记录的历史信息
func
(
action
*
Action
)
C
hangeAllAddrIndex
(
game
*
gty
.
GuessGame
)
{
func
(
action
*
Action
)
c
hangeAllAddrIndex
(
game
*
gty
.
GuessGame
)
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
for
i
:=
0
;
i
<
len
(
game
.
Plays
);
i
++
{
player
:=
game
.
Plays
[
i
]
player
:=
game
.
Plays
[
i
]
player
.
Bet
.
PreIndex
=
player
.
Bet
.
Index
player
.
Bet
.
PreIndex
=
player
.
Bet
.
Index
player
.
Bet
.
Index
=
game
.
Index
player
.
Bet
.
Index
=
action
.
getIndex
()
}
}
}
}
//
R
efreshStatusByTime 检测游戏是否过期,是否可以下注
//
r
efreshStatusByTime 检测游戏是否过期,是否可以下注
func
(
action
*
Action
)
R
efreshStatusByTime
(
game
*
gty
.
GuessGame
)
(
canBet
bool
)
{
func
(
action
*
Action
)
r
efreshStatusByTime
(
game
*
gty
.
GuessGame
)
(
canBet
bool
)
{
var
mainHeight
int64
var
mainHeight
int64
if
types
.
IsPara
()
{
if
types
.
IsPara
()
{
...
@@ -893,7 +846,7 @@ func (action *Action) RefreshStatusByTime(game *gty.GuessGame) (canBet bool) {
...
@@ -893,7 +846,7 @@ func (action *Action) RefreshStatusByTime(game *gty.GuessGame) (canBet bool) {
if
game
.
DrivenByAdmin
{
if
game
.
DrivenByAdmin
{
if
(
mainHeight
-
game
.
StartHeight
)
>=
game
.
ExpireHeight
{
if
(
mainHeight
-
game
.
StartHeight
)
>=
game
.
ExpireHeight
{
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusTimeOut
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusTimeOut
)
canBet
=
false
canBet
=
false
return
canBet
return
canBet
}
}
...
@@ -907,9 +860,9 @@ func (action *Action) RefreshStatusByTime(game *gty.GuessGame) (canBet bool) {
...
@@ -907,9 +860,9 @@ func (action *Action) RefreshStatusByTime(game *gty.GuessGame) (canBet bool) {
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Height over limit"
,
logger
.
Error
(
"GameBet"
,
"addr"
,
action
.
fromaddr
,
"execaddr"
,
action
.
execaddr
,
"Height over limit"
,
mainHeight
,
"startHeight"
,
game
.
StartHeight
,
"MaxHeightDiff"
,
game
.
GetMaxBetHeight
())
mainHeight
,
"startHeight"
,
game
.
StartHeight
,
"MaxHeightDiff"
,
game
.
GetMaxBetHeight
())
if
game
.
ExpireHeight
>
heightDiff
{
if
game
.
ExpireHeight
>
heightDiff
{
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusStopBet
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusStopBet
)
}
else
{
}
else
{
action
.
C
hangeStatus
(
game
,
gty
.
GuessGameStatusTimeOut
)
action
.
c
hangeStatus
(
game
,
gty
.
GuessGameStatusTimeOut
)
}
}
canBet
=
false
canBet
=
false
...
@@ -920,8 +873,8 @@ func (action *Action) RefreshStatusByTime(game *gty.GuessGame) (canBet bool) {
...
@@ -920,8 +873,8 @@ func (action *Action) RefreshStatusByTime(game *gty.GuessGame) (canBet bool) {
return
canBet
return
canBet
}
}
//
C
heckTime 检测游戏的过期设置。
//
c
heckTime 检测游戏的过期设置。
func
(
action
*
Action
)
C
heckTime
(
start
*
gty
.
GuessGameStart
)
bool
{
func
(
action
*
Action
)
c
heckTime
(
start
*
gty
.
GuessGameStart
)
bool
{
if
start
.
MaxBetHeight
==
0
&&
start
.
ExpireHeight
==
0
{
if
start
.
MaxBetHeight
==
0
&&
start
.
ExpireHeight
==
0
{
//如果上述字段都不携带,则认为完全由admin的指令驱动。
//如果上述字段都不携带,则认为完全由admin的指令驱动。
start
.
DrivenByAdmin
=
true
start
.
DrivenByAdmin
=
true
...
...
plugin/dapp/guess/executor/keys.go
deleted
100644 → 0
View file @
55e2f303
package
executor
import
(
"fmt"
"github.com/33cn/chain33/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
//addr prefix
func
calcGuessGameAddrPrefix
(
addr
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-addr:%s:"
,
addr
)
return
[]
byte
(
key
)
}
//addr index
func
calcGuessGameAddrKey
(
addr
string
,
index
int64
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-addr:%s:%018d"
,
addr
,
index
)
return
[]
byte
(
key
)
}
//status prefix
func
calcGuessGameStatusPrefix
(
status
int32
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-status-index:%d:"
,
status
)
return
[]
byte
(
key
)
}
//status index
func
calcGuessGameStatusKey
(
status
int32
,
index
int64
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-status-index:%d:%018d"
,
status
,
index
)
return
[]
byte
(
key
)
}
//addr status prefix
func
calcGuessGameAddrStatusPrefix
(
addr
string
,
status
int32
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-addr-status-index:%s:%d:"
,
addr
,
status
)
return
[]
byte
(
key
)
}
//addr status index
func
calcGuessGameAddrStatusKey
(
addr
string
,
status
int32
,
index
int64
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-addr-status-index:%s:%d:%018d"
,
addr
,
status
,
index
)
return
[]
byte
(
key
)
}
//admin prefix
func
calcGuessGameAdminPrefix
(
addr
string
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-admin:%s:"
,
addr
)
return
[]
byte
(
key
)
}
//admin index
func
calcGuessGameAdminKey
(
addr
string
,
index
int64
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-admin:%s:%018d"
,
addr
,
index
)
return
[]
byte
(
key
)
}
//admin status prefix
func
calcGuessGameAdminStatusPrefix
(
admin
string
,
status
int32
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-admin-status-index:%s:%d:"
,
admin
,
status
)
return
[]
byte
(
key
)
}
//admin status index
func
calcGuessGameAdminStatusKey
(
admin
string
,
status
int32
,
index
int64
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-admin-status-index:%s:%d:%018d"
,
admin
,
status
,
index
)
return
[]
byte
(
key
)
}
func
calcGuessGameCategoryStatusPrefix
(
category
string
,
status
int32
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-category-status-index:%s:%d:"
,
category
,
status
)
return
[]
byte
(
key
)
}
func
calcGuessGameCategoryStatusKey
(
category
string
,
status
int32
,
index
int64
)
[]
byte
{
key
:=
fmt
.
Sprintf
(
"LODB-guess-category-status-index:%s:%d:%018d"
,
category
,
status
,
index
)
return
[]
byte
(
key
)
}
func
addGuessGameAddrIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrKey
(
addr
,
index
)
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
return
kv
}
func
delGuessGameAddrIndexKey
(
addr
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrKey
(
addr
,
index
)
kv
.
Value
=
nil
return
kv
}
func
addGuessGameStatusIndexKey
(
status
int32
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameStatusKey
(
status
,
index
)
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
return
kv
}
func
delGuessGameStatusIndexKey
(
status
int32
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameStatusKey
(
status
,
index
)
kv
.
Value
=
nil
return
kv
}
func
addGuessGameAddrStatusIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrStatusKey
(
addr
,
status
,
index
)
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
return
kv
}
func
delGuessGameAddrStatusIndexKey
(
status
int32
,
addr
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAddrStatusKey
(
addr
,
status
,
index
)
kv
.
Value
=
nil
return
kv
}
func
addGuessGameAdminIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminKey
(
addr
,
index
)
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
return
kv
}
func
delGuessGameAdminIndexKey
(
addr
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminKey
(
addr
,
index
)
kv
.
Value
=
nil
return
kv
}
func
addGuessGameAdminStatusIndexKey
(
status
int32
,
addr
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminStatusKey
(
addr
,
status
,
index
)
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
return
kv
}
func
delGuessGameAdminStatusIndexKey
(
status
int32
,
addr
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameAdminStatusKey
(
addr
,
status
,
index
)
kv
.
Value
=
nil
return
kv
}
func
addGuessGameCategoryStatusIndexKey
(
status
int32
,
category
,
gameID
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameCategoryStatusKey
(
category
,
status
,
index
)
record
:=
&
gty
.
GuessGameRecord
{
GameID
:
gameID
,
Status
:
status
,
Index
:
index
,
}
kv
.
Value
=
types
.
Encode
(
record
)
return
kv
}
func
delGuessGameCategoryStatusIndexKey
(
status
int32
,
category
string
,
index
int64
)
*
types
.
KeyValue
{
kv
:=
&
types
.
KeyValue
{}
kv
.
Key
=
calcGuessGameCategoryStatusKey
(
category
,
status
,
index
)
kv
.
Value
=
nil
return
kv
}
plugin/dapp/guess/executor/query.go
View file @
4da6c484
...
@@ -5,80 +5,79 @@
...
@@ -5,80 +5,79 @@
package
executor
package
executor
import
(
import
(
"fmt"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
gty
"github.com/33cn/plugin/plugin/dapp/guess/types"
)
)
//Query_QueryGamesByIDs method
//Query_QueryGamesByIDs method
func
(
g
*
Guess
)
Query_QueryGamesByIDs
(
in
*
gty
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByIDs
(
in
*
gty
.
QueryGuessGameInfos
)
(
types
.
Message
,
error
)
{
return
Infos
(
g
.
GetState
DB
(),
in
)
return
QueryGameInfos
(
g
.
GetLocal
DB
(),
in
)
}
}
//Query_QueryGameByID method
//Query_QueryGameByID method
func
(
g
*
Guess
)
Query_QueryGameByID
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGameByID
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
game
,
err
:=
readGame
(
g
.
GetStateDB
(),
in
.
GetGameID
(
))
game
,
err
:=
QueryGameInfo
(
g
.
GetLocalDB
(),
[]
byte
(
in
.
GetGameID
()
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
&
gty
.
ReplyGuessGameInfo
{
Game
:
game
},
nil
return
&
gty
.
ReplyGuessGameInfo
{
Game
:
game
},
nil
}
}
//Query_QueryGamesByAddr method
//Query_QueryGamesByAddr method
func
(
g
*
Guess
)
Query_QueryGamesByAddr
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAddr
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAddr
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Index
)
gameTable
:=
gty
.
NewGuessUserTable
(
g
.
GetLocalDB
())
if
err
!=
nil
{
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
nil
,
err
}
return
records
,
nil
return
QueryUserTableData
(
query
,
"addr"
,
[]
byte
(
in
.
Addr
),
in
.
PrimaryKey
)
}
}
//Query_QueryGamesByStatus method
//Query_QueryGamesByStatus method
func
(
g
*
Guess
)
Query_QueryGamesByStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByStatus
(
g
.
GetLocalDB
(),
in
.
Status
,
in
.
Index
)
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
if
err
!=
nil
{
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
nil
,
err
}
return
records
,
nil
return
QueryGameTableData
(
query
,
"status"
,
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
in
.
Status
)),
in
.
PrimaryKey
)
}
}
//Query_QueryGamesByAdminAddr method
//Query_QueryGamesByAdminAddr method
func
(
g
*
Guess
)
Query_QueryGamesByAdminAddr
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAdminAddr
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAdminAddr
(
g
.
GetLocalDB
(),
in
.
AdminAddr
,
in
.
Index
)
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
if
err
!=
nil
{
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
nil
,
err
prefix
:=
[]
byte
(
in
.
AdminAddr
)
}
return
QueryGameTableData
(
query
,
"admin"
,
prefix
,
in
.
PrimaryKey
)
return
records
,
nil
}
}
//Query_QueryGamesByAddrStatus method
//Query_QueryGamesByAddrStatus method
func
(
g
*
Guess
)
Query_QueryGamesByAddrStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAddrStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAddrStatus
(
g
.
GetLocalDB
(),
in
.
Addr
,
in
.
Status
,
in
.
Index
)
userTable
:=
gty
.
NewGuessUserTable
(
g
.
GetLocalDB
())
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
tableJoin
,
err
:=
table
.
NewJoinTable
(
userTable
,
gameTable
,
[]
string
{
"addr#status"
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
records
,
nil
prefix
:=
table
.
JoinKey
([]
byte
(
fmt
.
Sprintf
(
"%s"
,
in
.
Addr
)),
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
in
.
Status
)))
return
QueryJoinTableData
(
tableJoin
,
"addr#status"
,
prefix
,
in
.
PrimaryKey
)
}
}
//Query_QueryGamesByAdminStatus method
//Query_QueryGamesByAdminStatus method
func
(
g
*
Guess
)
Query_QueryGamesByAdminStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByAdminStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByAdminStatus
(
g
.
GetLocalDB
(),
in
.
AdminAddr
,
in
.
Status
,
in
.
Index
)
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
if
err
!=
nil
{
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
nil
,
err
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
in
.
AdminAddr
,
in
.
Status
))
}
return
records
,
nil
return
QueryGameTableData
(
query
,
"admin_status"
,
prefix
,
in
.
PrimaryKey
)
}
}
//Query_QueryGamesByCategoryStatus method
//Query_QueryGamesByCategoryStatus method
func
(
g
*
Guess
)
Query_QueryGamesByCategoryStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
func
(
g
*
Guess
)
Query_QueryGamesByCategoryStatus
(
in
*
gty
.
QueryGuessGameInfo
)
(
types
.
Message
,
error
)
{
records
,
err
:=
getGameListByCategoryStatus
(
g
.
GetLocalDB
(),
in
.
Category
,
in
.
Status
,
in
.
Index
)
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
if
err
!=
nil
{
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
nil
,
err
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
in
.
Category
,
in
.
Status
))
}
return
records
,
nil
return
QueryGameTableData
(
query
,
"category_status"
,
prefix
,
in
.
PrimaryKey
)
}
}
plugin/dapp/guess/proto/guess.proto
View file @
4da6c484
...
@@ -12,25 +12,26 @@ message GuessGame {
...
@@ -12,25 +12,26 @@ message GuessGame {
int64
startTime
=
4
;
//创建游戏的时间
int64
startTime
=
4
;
//创建游戏的时间
int64
startHeight
=
5
;
//创建游戏的时间
int64
startHeight
=
5
;
//创建游戏的时间
string
startTxHash
=
6
;
//创建游戏的交易hash
string
startTxHash
=
6
;
//创建游戏的交易hash
string
topic
=
7
;
//主题
int64
startIndex
=
7
;
//创建游戏的交易index
string
category
=
8
;
//分类
string
topic
=
8
;
//主题
string
options
=
9
;
//选项
string
category
=
9
;
//分类
int64
maxBetHeight
=
10
;
//截止下注的块高
string
options
=
10
;
//选项
int64
maxBetsOneTime
=
11
;
//单次可以下多少注,默认100
int64
maxBetHeight
=
11
;
//截止下注的块高
int64
maxBetsNumber
=
12
;
//最多可以下多少注
int64
maxBetsOneTime
=
12
;
//单次可以下多少注,默认100
int64
devFeeFactor
=
13
;
//开发者抽成比例
int64
maxBetsNumber
=
13
;
//最多可以下多少注
string
devFeeAddr
=
14
;
//开发者地址
int64
devFeeFactor
=
14
;
//开发者抽成比例
int64
platFeeFactor
=
15
;
//平台抽成比例
string
devFeeAddr
=
15
;
//开发者地址
string
platFeeAddr
=
16
;
//平台地址
int64
platFeeFactor
=
16
;
//平台抽成比例
int64
expireHeight
=
17
;
//游戏过期区块高度
string
platFeeAddr
=
17
;
//平台地址
string
adminAddr
=
18
;
//游戏创建者地址,只有该地址可以开奖
int64
expireHeight
=
18
;
//游戏过期区块高度
int64
betsNumber
=
19
;
//已下注数,如果数量达到maxBetsNumber,则不允许再下注
string
adminAddr
=
19
;
//游戏创建者地址,只有该地址可以开奖
repeated
GuessPlayer
plays
=
20
;
//参与游戏下注的玩家投注信息
int64
betsNumber
=
20
;
//已下注数,如果数量达到maxBetsNumber,则不允许再下注
string
result
=
21
;
//公布的中奖结果
repeated
GuessPlayer
plays
=
21
;
//参与游戏下注的玩家投注信息
GuessBetStat
betStat
=
22
;
string
result
=
22
;
//公布的中奖结果
int64
index
=
23
;
GuessBetStat
betStat
=
23
;
int64
preIndex
=
24
;
int64
index
=
24
;
bool
drivenByAdmin
=
25
;
int64
preIndex
=
25
;
bool
drivenByAdmin
=
26
;
}
}
//GuessPlayer 竞猜玩家信息
//GuessPlayer 竞猜玩家信息
...
@@ -129,6 +130,7 @@ message QueryGuessGameInfo {
...
@@ -129,6 +130,7 @@ message QueryGuessGameInfo {
int64
index
=
4
;
int64
index
=
4
;
string
adminAddr
=
5
;
string
adminAddr
=
5
;
string
category
=
6
;
string
category
=
6
;
bytes
primaryKey
=
7
;
}
}
//ReplyGuessGameInfo 游戏信息查询响应消息
//ReplyGuessGameInfo 游戏信息查询响应消息
...
@@ -148,15 +150,30 @@ message ReplyGuessGameInfos {
...
@@ -148,15 +150,30 @@ message ReplyGuessGameInfos {
//ReceiptGuessGame 竞猜游戏收据信息
//ReceiptGuessGame 竞猜游戏收据信息
message
ReceiptGuessGame
{
message
ReceiptGuessGame
{
string
gameID
=
1
;
int64
startIndex
=
1
;
int32
preStatus
=
2
;
string
gameID
=
2
;
int32
status
=
3
;
int32
preStatus
=
3
;
int32
status
=
4
;
string
addr
=
5
;
string
adminAddr
=
6
;
int64
preIndex
=
7
;
int64
index
=
8
;
string
category
=
9
;
bool
statusChange
=
10
;
bool
bet
=
11
;
string
option
=
12
;
int64
betsNumber
=
13
;
GuessGame
game
=
14
;
}
//UserBet 用户下注信息
message
UserBet
{
int64
startIndex
=
1
;
int64
index
=
2
;
string
gameID
=
3
;
string
addr
=
4
;
string
addr
=
4
;
string
adminAddr
=
5
;
string
option
=
5
;
int64
preIndex
=
6
;
int64
betsNumber
=
6
;
int64
index
=
7
;
string
category
=
8
;
bool
statusChange
=
9
;
}
}
//GuessStartTxReq 构造start交易的请求
//GuessStartTxReq 构造start交易的请求
...
@@ -206,13 +223,13 @@ message GuessPublishTxReq {
...
@@ -206,13 +223,13 @@ message GuessPublishTxReq {
// GuessGameRecord game信息查询记录
// GuessGameRecord game信息查询记录
message
GuessGameRecord
{
message
GuessGameRecord
{
string
gameID
=
1
;
string
gameID
=
1
;
int32
status
=
2
;
int64
startIndex
=
2
;
int64
index
=
3
;
}
}
// GuessGameRecords game信息查询记录集
// GuessGameRecords game信息查询记录集
message
GuessGameRecords
{
message
GuessGameRecords
{
repeated
GuessGameRecord
records
=
1
;
repeated
GuessGameRecord
records
=
1
;
bytes
primaryKey
=
2
;
}
}
...
...
plugin/dapp/guess/types/errors.go
View file @
4da6c484
...
@@ -11,4 +11,8 @@ var (
...
@@ -11,4 +11,8 @@ var (
ErrNoPrivilege
=
errors
.
New
(
"ErrNoPrivilege"
)
ErrNoPrivilege
=
errors
.
New
(
"ErrNoPrivilege"
)
ErrGuessStatus
=
errors
.
New
(
"ErrGuessStatus"
)
ErrGuessStatus
=
errors
.
New
(
"ErrGuessStatus"
)
ErrOverBetsLimit
=
errors
.
New
(
"ErrOverBetsLimit"
)
ErrOverBetsLimit
=
errors
.
New
(
"ErrOverBetsLimit"
)
ErrParamStatusInvalid
=
errors
.
New
(
"ErrParamStatusInvalid"
)
ErrParamAddressMustnotEmpty
=
errors
.
New
(
"ErrParamAddressMustnotEmpty"
)
ErrGameNotExist
=
errors
.
New
(
"ErrGameNotExist"
)
ErrSaveTable
=
errors
.
New
(
"ErrSaveTable"
)
)
)
plugin/dapp/guess/types/guess.pb.go
View file @
4da6c484
...
@@ -6,11 +6,10 @@ package types
...
@@ -6,11 +6,10 @@ package types
import
(
import
(
context
"context"
context
"context"
fmt
"fmt"
fmt
"fmt"
math
"math"
types
"github.com/33cn/chain33/types"
types
"github.com/33cn/chain33/types"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
grpc
"google.golang.org/grpc"
grpc
"google.golang.org/grpc"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
@@ -32,25 +31,26 @@ type GuessGame struct {
...
@@ -32,25 +31,26 @@ type GuessGame struct {
StartTime
int64
`protobuf:"varint,4,opt,name=startTime,proto3" json:"startTime,omitempty"`
StartTime
int64
`protobuf:"varint,4,opt,name=startTime,proto3" json:"startTime,omitempty"`
StartHeight
int64
`protobuf:"varint,5,opt,name=startHeight,proto3" json:"startHeight,omitempty"`
StartHeight
int64
`protobuf:"varint,5,opt,name=startHeight,proto3" json:"startHeight,omitempty"`
StartTxHash
string
`protobuf:"bytes,6,opt,name=startTxHash,proto3" json:"startTxHash,omitempty"`
StartTxHash
string
`protobuf:"bytes,6,opt,name=startTxHash,proto3" json:"startTxHash,omitempty"`
Topic
string
`protobuf:"bytes,7,opt,name=topic,proto3" json:"topic,omitempty"`
StartIndex
int64
`protobuf:"varint,7,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
Category
string
`protobuf:"bytes,8,opt,name=category,proto3" json:"category,omitempty"`
Topic
string
`protobuf:"bytes,8,opt,name=topic,proto3" json:"topic,omitempty"`
Options
string
`protobuf:"bytes,9,opt,name=options,proto3" json:"options,omitempty"`
Category
string
`protobuf:"bytes,9,opt,name=category,proto3" json:"category,omitempty"`
MaxBetHeight
int64
`protobuf:"varint,10,opt,name=maxBetHeight,proto3" json:"maxBetHeight,omitempty"`
Options
string
`protobuf:"bytes,10,opt,name=options,proto3" json:"options,omitempty"`
MaxBetsOneTime
int64
`protobuf:"varint,11,opt,name=maxBetsOneTime,proto3" json:"maxBetsOneTime,omitempty"`
MaxBetHeight
int64
`protobuf:"varint,11,opt,name=maxBetHeight,proto3" json:"maxBetHeight,omitempty"`
MaxBetsNumber
int64
`protobuf:"varint,12,opt,name=maxBetsNumber,proto3" json:"maxBetsNumber,omitempty"`
MaxBetsOneTime
int64
`protobuf:"varint,12,opt,name=maxBetsOneTime,proto3" json:"maxBetsOneTime,omitempty"`
DevFeeFactor
int64
`protobuf:"varint,13,opt,name=devFeeFactor,proto3" json:"devFeeFactor,omitempty"`
MaxBetsNumber
int64
`protobuf:"varint,13,opt,name=maxBetsNumber,proto3" json:"maxBetsNumber,omitempty"`
DevFeeAddr
string
`protobuf:"bytes,14,opt,name=devFeeAddr,proto3" json:"devFeeAddr,omitempty"`
DevFeeFactor
int64
`protobuf:"varint,14,opt,name=devFeeFactor,proto3" json:"devFeeFactor,omitempty"`
PlatFeeFactor
int64
`protobuf:"varint,15,opt,name=platFeeFactor,proto3" json:"platFeeFactor,omitempty"`
DevFeeAddr
string
`protobuf:"bytes,15,opt,name=devFeeAddr,proto3" json:"devFeeAddr,omitempty"`
PlatFeeAddr
string
`protobuf:"bytes,16,opt,name=platFeeAddr,proto3" json:"platFeeAddr,omitempty"`
PlatFeeFactor
int64
`protobuf:"varint,16,opt,name=platFeeFactor,proto3" json:"platFeeFactor,omitempty"`
ExpireHeight
int64
`protobuf:"varint,17,opt,name=expireHeight,proto3" json:"expireHeight,omitempty"`
PlatFeeAddr
string
`protobuf:"bytes,17,opt,name=platFeeAddr,proto3" json:"platFeeAddr,omitempty"`
AdminAddr
string
`protobuf:"bytes,18,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
ExpireHeight
int64
`protobuf:"varint,18,opt,name=expireHeight,proto3" json:"expireHeight,omitempty"`
BetsNumber
int64
`protobuf:"varint,19,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
AdminAddr
string
`protobuf:"bytes,19,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
Plays
[]
*
GuessPlayer
`protobuf:"bytes,20,rep,name=plays,proto3" json:"plays,omitempty"`
BetsNumber
int64
`protobuf:"varint,20,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
Result
string
`protobuf:"bytes,21,opt,name=result,proto3" json:"result,omitempty"`
Plays
[]
*
GuessPlayer
`protobuf:"bytes,21,rep,name=plays,proto3" json:"plays,omitempty"`
BetStat
*
GuessBetStat
`protobuf:"bytes,22,opt,name=betStat,proto3" json:"betStat,omitempty"`
Result
string
`protobuf:"bytes,22,opt,name=result,proto3" json:"result,omitempty"`
Index
int64
`protobuf:"varint,23,opt,name=index,proto3" json:"index,omitempty"`
BetStat
*
GuessBetStat
`protobuf:"bytes,23,opt,name=betStat,proto3" json:"betStat,omitempty"`
PreIndex
int64
`protobuf:"varint,24,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
Index
int64
`protobuf:"varint,24,opt,name=index,proto3" json:"index,omitempty"`
DrivenByAdmin
bool
`protobuf:"varint,25,opt,name=drivenByAdmin,proto3" json:"drivenByAdmin,omitempty"`
PreIndex
int64
`protobuf:"varint,25,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
DrivenByAdmin
bool
`protobuf:"varint,26,opt,name=drivenByAdmin,proto3" json:"drivenByAdmin,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
@@ -123,6 +123,13 @@ func (m *GuessGame) GetStartTxHash() string {
...
@@ -123,6 +123,13 @@ func (m *GuessGame) GetStartTxHash() string {
return
""
return
""
}
}
func
(
m
*
GuessGame
)
GetStartIndex
()
int64
{
if
m
!=
nil
{
return
m
.
StartIndex
}
return
0
}
func
(
m
*
GuessGame
)
GetTopic
()
string
{
func
(
m
*
GuessGame
)
GetTopic
()
string
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Topic
return
m
.
Topic
...
@@ -1151,6 +1158,7 @@ type QueryGuessGameInfo struct {
...
@@ -1151,6 +1158,7 @@ type QueryGuessGameInfo struct {
Index
int64
`protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`
Index
int64
`protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`
AdminAddr
string
`protobuf:"bytes,5,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
AdminAddr
string
`protobuf:"bytes,5,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
Category
string
`protobuf:"bytes,6,opt,name=category,proto3" json:"category,omitempty"`
Category
string
`protobuf:"bytes,6,opt,name=category,proto3" json:"category,omitempty"`
PrimaryKey
[]
byte
`protobuf:"bytes,7,opt,name=primaryKey,proto3" json:"primaryKey,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
@@ -1223,6 +1231,13 @@ func (m *QueryGuessGameInfo) GetCategory() string {
...
@@ -1223,6 +1231,13 @@ func (m *QueryGuessGameInfo) GetCategory() string {
return
""
return
""
}
}
func
(
m
*
QueryGuessGameInfo
)
GetPrimaryKey
()
[]
byte
{
if
m
!=
nil
{
return
m
.
PrimaryKey
}
return
nil
}
//ReplyGuessGameInfo 游戏信息查询响应消息
//ReplyGuessGameInfo 游戏信息查询响应消息
type
ReplyGuessGameInfo
struct
{
type
ReplyGuessGameInfo
struct
{
Game
*
GuessGame
`protobuf:"bytes,1,opt,name=game,proto3" json:"game,omitempty"`
Game
*
GuessGame
`protobuf:"bytes,1,opt,name=game,proto3" json:"game,omitempty"`
...
@@ -1345,18 +1360,23 @@ func (m *ReplyGuessGameInfos) GetGames() []*GuessGame {
...
@@ -1345,18 +1360,23 @@ func (m *ReplyGuessGameInfos) GetGames() []*GuessGame {
//ReceiptGuessGame 竞猜游戏收据信息
//ReceiptGuessGame 竞猜游戏收据信息
type
ReceiptGuessGame
struct
{
type
ReceiptGuessGame
struct
{
GameID
string
`protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
StartIndex
int64
`protobuf:"varint,1,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
PreStatus
int32
`protobuf:"varint,2,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
GameID
string
`protobuf:"bytes,2,opt,name=gameID,proto3" json:"gameID,omitempty"`
Status
int32
`protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
PreStatus
int32
`protobuf:"varint,3,opt,name=preStatus,proto3" json:"preStatus,omitempty"`
Addr
string
`protobuf:"bytes,4,opt,name=addr,proto3" json:"addr,omitempty"`
Status
int32
`protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"`
AdminAddr
string
`protobuf:"bytes,5,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
Addr
string
`protobuf:"bytes,5,opt,name=addr,proto3" json:"addr,omitempty"`
PreIndex
int64
`protobuf:"varint,6,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
AdminAddr
string
`protobuf:"bytes,6,opt,name=adminAddr,proto3" json:"adminAddr,omitempty"`
Index
int64
`protobuf:"varint,7,opt,name=index,proto3" json:"index,omitempty"`
PreIndex
int64
`protobuf:"varint,7,opt,name=preIndex,proto3" json:"preIndex,omitempty"`
Category
string
`protobuf:"bytes,8,opt,name=category,proto3" json:"category,omitempty"`
Index
int64
`protobuf:"varint,8,opt,name=index,proto3" json:"index,omitempty"`
StatusChange
bool
`protobuf:"varint,9,opt,name=statusChange,proto3" json:"statusChange,omitempty"`
Category
string
`protobuf:"bytes,9,opt,name=category,proto3" json:"category,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
StatusChange
bool
`protobuf:"varint,10,opt,name=statusChange,proto3" json:"statusChange,omitempty"`
XXX_unrecognized
[]
byte
`json:"-"`
Bet
bool
`protobuf:"varint,11,opt,name=bet,proto3" json:"bet,omitempty"`
XXX_sizecache
int32
`json:"-"`
Option
string
`protobuf:"bytes,12,opt,name=option,proto3" json:"option,omitempty"`
BetsNumber
int64
`protobuf:"varint,13,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
Game
*
GuessGame
`protobuf:"bytes,14,opt,name=game,proto3" json:"game,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
}
func
(
m
*
ReceiptGuessGame
)
Reset
()
{
*
m
=
ReceiptGuessGame
{}
}
func
(
m
*
ReceiptGuessGame
)
Reset
()
{
*
m
=
ReceiptGuessGame
{}
}
...
@@ -1384,6 +1404,13 @@ func (m *ReceiptGuessGame) XXX_DiscardUnknown() {
...
@@ -1384,6 +1404,13 @@ func (m *ReceiptGuessGame) XXX_DiscardUnknown() {
var
xxx_messageInfo_ReceiptGuessGame
proto
.
InternalMessageInfo
var
xxx_messageInfo_ReceiptGuessGame
proto
.
InternalMessageInfo
func
(
m
*
ReceiptGuessGame
)
GetStartIndex
()
int64
{
if
m
!=
nil
{
return
m
.
StartIndex
}
return
0
}
func
(
m
*
ReceiptGuessGame
)
GetGameID
()
string
{
func
(
m
*
ReceiptGuessGame
)
GetGameID
()
string
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
GameID
return
m
.
GameID
...
@@ -1447,6 +1474,114 @@ func (m *ReceiptGuessGame) GetStatusChange() bool {
...
@@ -1447,6 +1474,114 @@ func (m *ReceiptGuessGame) GetStatusChange() bool {
return
false
return
false
}
}
func
(
m
*
ReceiptGuessGame
)
GetBet
()
bool
{
if
m
!=
nil
{
return
m
.
Bet
}
return
false
}
func
(
m
*
ReceiptGuessGame
)
GetOption
()
string
{
if
m
!=
nil
{
return
m
.
Option
}
return
""
}
func
(
m
*
ReceiptGuessGame
)
GetBetsNumber
()
int64
{
if
m
!=
nil
{
return
m
.
BetsNumber
}
return
0
}
func
(
m
*
ReceiptGuessGame
)
GetGame
()
*
GuessGame
{
if
m
!=
nil
{
return
m
.
Game
}
return
nil
}
//UserBet 用户下注信息
type
UserBet
struct
{
StartIndex
int64
`protobuf:"varint,1,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
Index
int64
`protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
GameID
string
`protobuf:"bytes,3,opt,name=gameID,proto3" json:"gameID,omitempty"`
Addr
string
`protobuf:"bytes,4,opt,name=addr,proto3" json:"addr,omitempty"`
Option
string
`protobuf:"bytes,5,opt,name=option,proto3" json:"option,omitempty"`
BetsNumber
int64
`protobuf:"varint,6,opt,name=betsNumber,proto3" json:"betsNumber,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
}
func
(
m
*
UserBet
)
Reset
()
{
*
m
=
UserBet
{}
}
func
(
m
*
UserBet
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
UserBet
)
ProtoMessage
()
{}
func
(
*
UserBet
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
17
}
}
func
(
m
*
UserBet
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
return
xxx_messageInfo_UserBet
.
Unmarshal
(
m
,
b
)
}
func
(
m
*
UserBet
)
XXX_Marshal
(
b
[]
byte
,
deterministic
bool
)
([]
byte
,
error
)
{
return
xxx_messageInfo_UserBet
.
Marshal
(
b
,
m
,
deterministic
)
}
func
(
m
*
UserBet
)
XXX_Merge
(
src
proto
.
Message
)
{
xxx_messageInfo_UserBet
.
Merge
(
m
,
src
)
}
func
(
m
*
UserBet
)
XXX_Size
()
int
{
return
xxx_messageInfo_UserBet
.
Size
(
m
)
}
func
(
m
*
UserBet
)
XXX_DiscardUnknown
()
{
xxx_messageInfo_UserBet
.
DiscardUnknown
(
m
)
}
var
xxx_messageInfo_UserBet
proto
.
InternalMessageInfo
func
(
m
*
UserBet
)
GetStartIndex
()
int64
{
if
m
!=
nil
{
return
m
.
StartIndex
}
return
0
}
func
(
m
*
UserBet
)
GetIndex
()
int64
{
if
m
!=
nil
{
return
m
.
Index
}
return
0
}
func
(
m
*
UserBet
)
GetGameID
()
string
{
if
m
!=
nil
{
return
m
.
GameID
}
return
""
}
func
(
m
*
UserBet
)
GetAddr
()
string
{
if
m
!=
nil
{
return
m
.
Addr
}
return
""
}
func
(
m
*
UserBet
)
GetOption
()
string
{
if
m
!=
nil
{
return
m
.
Option
}
return
""
}
func
(
m
*
UserBet
)
GetBetsNumber
()
int64
{
if
m
!=
nil
{
return
m
.
BetsNumber
}
return
0
}
//GuessStartTxReq 构造start交易的请求
//GuessStartTxReq 构造start交易的请求
type
GuessStartTxReq
struct
{
type
GuessStartTxReq
struct
{
Topic
string
`protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
Topic
string
`protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
...
@@ -1471,7 +1606,7 @@ func (m *GuessStartTxReq) Reset() { *m = GuessStartTxReq{} }
...
@@ -1471,7 +1606,7 @@ func (m *GuessStartTxReq) Reset() { *m = GuessStartTxReq{} }
func
(
m
*
GuessStartTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessStartTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessStartTxReq
)
ProtoMessage
()
{}
func
(
*
GuessStartTxReq
)
ProtoMessage
()
{}
func
(
*
GuessStartTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessStartTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
1
7
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
1
8
}
}
}
func
(
m
*
GuessStartTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessStartTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1598,7 +1733,7 @@ func (m *GuessBetTxReq) Reset() { *m = GuessBetTxReq{} }
...
@@ -1598,7 +1733,7 @@ func (m *GuessBetTxReq) Reset() { *m = GuessBetTxReq{} }
func
(
m
*
GuessBetTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessBetTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessBetTxReq
)
ProtoMessage
()
{}
func
(
*
GuessBetTxReq
)
ProtoMessage
()
{}
func
(
*
GuessBetTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessBetTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
1
8
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
1
9
}
}
}
func
(
m
*
GuessBetTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessBetTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1660,7 +1795,7 @@ func (m *GuessStopBetTxReq) Reset() { *m = GuessStopBetTxReq{} }
...
@@ -1660,7 +1795,7 @@ func (m *GuessStopBetTxReq) Reset() { *m = GuessStopBetTxReq{} }
func
(
m
*
GuessStopBetTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessStopBetTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessStopBetTxReq
)
ProtoMessage
()
{}
func
(
*
GuessStopBetTxReq
)
ProtoMessage
()
{}
func
(
*
GuessStopBetTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessStopBetTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
19
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
20
}
}
}
func
(
m
*
GuessStopBetTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessStopBetTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1708,7 +1843,7 @@ func (m *GuessAbortTxReq) Reset() { *m = GuessAbortTxReq{} }
...
@@ -1708,7 +1843,7 @@ func (m *GuessAbortTxReq) Reset() { *m = GuessAbortTxReq{} }
func
(
m
*
GuessAbortTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessAbortTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessAbortTxReq
)
ProtoMessage
()
{}
func
(
*
GuessAbortTxReq
)
ProtoMessage
()
{}
func
(
*
GuessAbortTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessAbortTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
0
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
1
}
}
}
func
(
m
*
GuessAbortTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessAbortTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1757,7 +1892,7 @@ func (m *GuessPublishTxReq) Reset() { *m = GuessPublishTxReq{} }
...
@@ -1757,7 +1892,7 @@ func (m *GuessPublishTxReq) Reset() { *m = GuessPublishTxReq{} }
func
(
m
*
GuessPublishTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessPublishTxReq
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessPublishTxReq
)
ProtoMessage
()
{}
func
(
*
GuessPublishTxReq
)
ProtoMessage
()
{}
func
(
*
GuessPublishTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessPublishTxReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
1
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
2
}
}
}
func
(
m
*
GuessPublishTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessPublishTxReq
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1802,8 +1937,7 @@ func (m *GuessPublishTxReq) GetFee() int64 {
...
@@ -1802,8 +1937,7 @@ func (m *GuessPublishTxReq) GetFee() int64 {
// GuessGameRecord game信息查询记录
// GuessGameRecord game信息查询记录
type
GuessGameRecord
struct
{
type
GuessGameRecord
struct
{
GameID
string
`protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
GameID
string
`protobuf:"bytes,1,opt,name=gameID,proto3" json:"gameID,omitempty"`
Status
int32
`protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"`
StartIndex
int64
`protobuf:"varint,2,opt,name=startIndex,proto3" json:"startIndex,omitempty"`
Index
int64
`protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
@@ -1813,7 +1947,7 @@ func (m *GuessGameRecord) Reset() { *m = GuessGameRecord{} }
...
@@ -1813,7 +1947,7 @@ func (m *GuessGameRecord) Reset() { *m = GuessGameRecord{} }
func
(
m
*
GuessGameRecord
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessGameRecord
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessGameRecord
)
ProtoMessage
()
{}
func
(
*
GuessGameRecord
)
ProtoMessage
()
{}
func
(
*
GuessGameRecord
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessGameRecord
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
2
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
3
}
}
}
func
(
m
*
GuessGameRecord
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessGameRecord
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1841,16 +1975,9 @@ func (m *GuessGameRecord) GetGameID() string {
...
@@ -1841,16 +1975,9 @@ func (m *GuessGameRecord) GetGameID() string {
return
""
return
""
}
}
func
(
m
*
GuessGameRecord
)
GetStatus
()
int32
{
func
(
m
*
GuessGameRecord
)
GetStartIndex
()
int64
{
if
m
!=
nil
{
return
m
.
Status
}
return
0
}
func
(
m
*
GuessGameRecord
)
GetIndex
()
int64
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Index
return
m
.
Start
Index
}
}
return
0
return
0
}
}
...
@@ -1858,6 +1985,7 @@ func (m *GuessGameRecord) GetIndex() int64 {
...
@@ -1858,6 +1985,7 @@ func (m *GuessGameRecord) GetIndex() int64 {
// GuessGameRecords game信息查询记录集
// GuessGameRecords game信息查询记录集
type
GuessGameRecords
struct
{
type
GuessGameRecords
struct
{
Records
[]
*
GuessGameRecord
`protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
Records
[]
*
GuessGameRecord
`protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
PrimaryKey
[]
byte
`protobuf:"bytes,2,opt,name=primaryKey,proto3" json:"primaryKey,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
@@ -1867,7 +1995,7 @@ func (m *GuessGameRecords) Reset() { *m = GuessGameRecords{} }
...
@@ -1867,7 +1995,7 @@ func (m *GuessGameRecords) Reset() { *m = GuessGameRecords{} }
func
(
m
*
GuessGameRecords
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
m
*
GuessGameRecords
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
GuessGameRecords
)
ProtoMessage
()
{}
func
(
*
GuessGameRecords
)
ProtoMessage
()
{}
func
(
*
GuessGameRecords
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GuessGameRecords
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
3
}
return
fileDescriptor_7574406c5d3430e8
,
[]
int
{
2
4
}
}
}
func
(
m
*
GuessGameRecords
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
func
(
m
*
GuessGameRecords
)
XXX_Unmarshal
(
b
[]
byte
)
error
{
...
@@ -1895,6 +2023,13 @@ func (m *GuessGameRecords) GetRecords() []*GuessGameRecord {
...
@@ -1895,6 +2023,13 @@ func (m *GuessGameRecords) GetRecords() []*GuessGameRecord {
return
nil
return
nil
}
}
func
(
m
*
GuessGameRecords
)
GetPrimaryKey
()
[]
byte
{
if
m
!=
nil
{
return
m
.
PrimaryKey
}
return
nil
}
func
init
()
{
func
init
()
{
proto
.
RegisterType
((
*
GuessGame
)(
nil
),
"types.GuessGame"
)
proto
.
RegisterType
((
*
GuessGame
)(
nil
),
"types.GuessGame"
)
proto
.
RegisterType
((
*
GuessPlayer
)(
nil
),
"types.GuessPlayer"
)
proto
.
RegisterType
((
*
GuessPlayer
)(
nil
),
"types.GuessPlayer"
)
...
@@ -1913,6 +2048,7 @@ func init() {
...
@@ -1913,6 +2048,7 @@ func init() {
proto
.
RegisterType
((
*
QueryGuessGameInfos
)(
nil
),
"types.QueryGuessGameInfos"
)
proto
.
RegisterType
((
*
QueryGuessGameInfos
)(
nil
),
"types.QueryGuessGameInfos"
)
proto
.
RegisterType
((
*
ReplyGuessGameInfos
)(
nil
),
"types.ReplyGuessGameInfos"
)
proto
.
RegisterType
((
*
ReplyGuessGameInfos
)(
nil
),
"types.ReplyGuessGameInfos"
)
proto
.
RegisterType
((
*
ReceiptGuessGame
)(
nil
),
"types.ReceiptGuessGame"
)
proto
.
RegisterType
((
*
ReceiptGuessGame
)(
nil
),
"types.ReceiptGuessGame"
)
proto
.
RegisterType
((
*
UserBet
)(
nil
),
"types.UserBet"
)
proto
.
RegisterType
((
*
GuessStartTxReq
)(
nil
),
"types.GuessStartTxReq"
)
proto
.
RegisterType
((
*
GuessStartTxReq
)(
nil
),
"types.GuessStartTxReq"
)
proto
.
RegisterType
((
*
GuessBetTxReq
)(
nil
),
"types.GuessBetTxReq"
)
proto
.
RegisterType
((
*
GuessBetTxReq
)(
nil
),
"types.GuessBetTxReq"
)
proto
.
RegisterType
((
*
GuessStopBetTxReq
)(
nil
),
"types.GuessStopBetTxReq"
)
proto
.
RegisterType
((
*
GuessStopBetTxReq
)(
nil
),
"types.GuessStopBetTxReq"
)
...
@@ -1925,86 +2061,93 @@ func init() {
...
@@ -1925,86 +2061,93 @@ func init() {
func
init
()
{
proto
.
RegisterFile
(
"guess.proto"
,
fileDescriptor_7574406c5d3430e8
)
}
func
init
()
{
proto
.
RegisterFile
(
"guess.proto"
,
fileDescriptor_7574406c5d3430e8
)
}
var
fileDescriptor_7574406c5d3430e8
=
[]
byte
{
var
fileDescriptor_7574406c5d3430e8
=
[]
byte
{
// 1254 bytes of a gzipped FileDescriptorProto
// 1367 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xac
,
0x58
,
0xcd
,
0x6e
,
0xdb
,
0x46
,
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xac
,
0x58
,
0xc9
,
0x8e
,
0xdb
,
0x46
,
0x10
,
0xb6
,
0x48
,
0x51
,
0x3f
,
0x23
,
0xf9
,
0x6f
,
0x9d
,
0x38
,
0xac
,
0x61
,
0x14
,
0x2a
,
0x11
,
0xa4
,
0x13
,
0x1e
,
0x92
,
0xa2
,
0x96
,
0x92
,
0x66
,
0x46
,
0xee
,
0xf1
,
0xc2
,
0x7f
,
0x60
,
0x18
,
0xfa
,
0x09
,
0x42
,
0x81
,
0xb8
,
0x85
,
0x02
,
0x14
,
0x45
,
0x8a
,
0x1c
,
0xac
,
0x1a
,
0x89
,
0x7d
,
0x69
,
0x53
,
0xda
,
0xc3
,
0x11
,
0x02
,
0xd8
,
0x09
,
0x64
,
0x20
,
0x08
,
0x1c
,
0xf8
,
0x30
,
0x8a
,
0x61
,
0x7b
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
,
0x6c
,
0xe6
,
0xa7
,
0x5c
,
0x53
,
0xaa
,
0x57
,
0xf0
,
0x5d
,
0x36
,
0xb3
,
0xa5
,
0x65
,
0xdb
,
0x2e
,
0x5e
,
0x71
,
0x76
,
0x54
,
0xa7
,
0x7f
,
0x77
,
0x9e
,
0xfe
,
0x13
,
0x00
,
0x00
,
0xff
,
0xff
,
0xcf
,
0xa9
,
0x8e
,
0x1b
,
0x06
,
0x12
,
0x00
,
0x00
,
}
}
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
plugin/dapp/guess/types/table.go
View file @
4da6c484
...
@@ -15,17 +15,17 @@ data: guess
...
@@ -15,17 +15,17 @@ data: guess
index: addr,status,addr_status,admin,admin_status,category_status
index: addr,status,addr_status,admin,admin_status,category_status
*/
*/
var
opt
=
&
table
.
Option
{
var
opt
_guess_user
=
&
table
.
Option
{
Prefix
:
"LODB"
,
Prefix
:
"LODB
_guess
"
,
Name
:
"
guess
"
,
Name
:
"
user
"
,
Primary
:
"
gameid
"
,
Primary
:
"
index
"
,
Index
:
[]
string
{
"addr"
,
"sta
tus"
,
"addr_status"
,
"admin"
,
"admin_status"
,
"category_status
"
},
Index
:
[]
string
{
"addr"
,
"sta
rtindex
"
},
}
}
//NewTable 新建表
//NewTable 新建表
func
NewTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
func
New
GuessUser
Table
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewGuessRow
()
rowmeta
:=
NewGuess
User
Row
()
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
opt
)
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
opt
_guess_user
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
@@ -33,39 +33,91 @@ func NewTable(kvdb db.KV) *table.Table {
...
@@ -33,39 +33,91 @@ func NewTable(kvdb db.KV) *table.Table {
}
}
//OracleRow table meta 结构
//OracleRow table meta 结构
type
GuessRow
struct
{
type
Guess
User
Row
struct
{
*
ReceiptGuessGame
*
UserBet
}
}
//NewOracleRow 新建一个meta 结构
//NewOracleRow 新建一个meta 结构
func
NewGuess
Row
()
*
Guess
Row
{
func
NewGuess
UserRow
()
*
GuessUser
Row
{
return
&
Guess
Row
{
ReceiptGuessGame
:
&
ReceiptGuessGame
{}}
return
&
Guess
UserRow
{
UserBet
:
&
UserBet
{}}
}
}
//CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存eventid)
//CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存eventid)
func
(
tx
*
GuessRow
)
CreateRow
()
*
table
.
Row
{
func
(
tx
*
Guess
User
Row
)
CreateRow
()
*
table
.
Row
{
return
&
table
.
Row
{
Data
:
&
ReceiptGuessGame
{}}
return
&
table
.
Row
{
Data
:
&
ReceiptGuessGame
{}}
}
}
//SetPayload 设置数据
//SetPayload 设置数据
func
(
tx
*
GuessRow
)
SetPayload
(
data
types
.
Message
)
error
{
func
(
tx
*
Guess
User
Row
)
SetPayload
(
data
types
.
Message
)
error
{
if
txdata
,
ok
:=
data
.
(
*
ReceiptGuessGame
);
ok
{
if
txdata
,
ok
:=
data
.
(
*
UserBet
);
ok
{
tx
.
ReceiptGuessGame
=
txdata
tx
.
UserBet
=
txdata
return
nil
return
nil
}
}
return
types
.
ErrTypeAsset
return
types
.
ErrTypeAsset
}
}
//Get 按照indexName 查询 indexValue
//Get 按照indexName 查询 indexValue
func
(
tx
*
GuessRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
func
(
tx
*
GuessUserRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"gameid"
{
if
key
==
"index"
{
return
[]
byte
(
tx
.
GameID
),
nil
return
[]
byte
(
fmt
.
Sprintf
(
"%018d"
,
tx
.
Index
)),
nil
}
else
if
key
==
"addr"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
tx
.
Addr
)),
nil
}
else
if
key
==
"startindex"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%018d"
,
tx
.
StartIndex
)),
nil
}
return
nil
,
types
.
ErrNotFound
}
var
opt_guess_game
=
&
table
.
Option
{
Prefix
:
"LODB_guess"
,
Name
:
"game"
,
Primary
:
"startindex"
,
Index
:
[]
string
{
"gameid"
,
"status"
,
"admin"
,
"admin_status"
,
"category_status"
},
}
//NewTable 新建表
func
NewGuessGameTable
(
kvdb
db
.
KV
)
*
table
.
Table
{
rowmeta
:=
NewGuessGameRow
()
table
,
err
:=
table
.
NewTable
(
rowmeta
,
kvdb
,
opt_guess_game
)
if
err
!=
nil
{
panic
(
err
)
}
return
table
}
//OracleRow table meta 结构
type
GuessGameRow
struct
{
*
GuessGame
}
//NewOracleRow 新建一个meta 结构
func
NewGuessGameRow
()
*
GuessGameRow
{
return
&
GuessGameRow
{
GuessGame
:
&
GuessGame
{}}
}
//CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存eventid)
func
(
tx
*
GuessGameRow
)
CreateRow
()
*
table
.
Row
{
return
&
table
.
Row
{
Data
:
&
GuessGame
{}}
}
//SetPayload 设置数据
func
(
tx
*
GuessGameRow
)
SetPayload
(
data
types
.
Message
)
error
{
if
txdata
,
ok
:=
data
.
(
*
GuessGame
);
ok
{
tx
.
GuessGame
=
txdata
return
nil
}
return
types
.
ErrTypeAsset
}
//Get 按照indexName 查询 indexValue
func
(
tx
*
GuessGameRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"startindex"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%018d"
,
tx
.
StartIndex
)),
nil
}
else
if
key
==
"gameid"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
tx
.
GameID
)),
nil
}
else
if
key
==
"status"
{
}
else
if
key
==
"status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
tx
.
Status
)),
nil
return
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
tx
.
Status
)),
nil
}
else
if
key
==
"addr"
{
return
[]
byte
(
tx
.
Addr
),
nil
}
else
if
key
==
"addr_status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
tx
.
Addr
,
tx
.
Status
)),
nil
}
else
if
key
==
"admin"
{
}
else
if
key
==
"admin"
{
return
[]
byte
(
tx
.
AdminAddr
),
nil
return
[]
byte
(
tx
.
AdminAddr
),
nil
}
else
if
key
==
"admin_status"
{
}
else
if
key
==
"admin_status"
{
...
@@ -73,5 +125,6 @@ func (tx *GuessRow) Get(key string) ([]byte, error) {
...
@@ -73,5 +125,6 @@ func (tx *GuessRow) Get(key string) ([]byte, error) {
}
else
if
key
==
"category_status"
{
}
else
if
key
==
"category_status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
tx
.
Category
,
tx
.
Status
)),
nil
return
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
tx
.
Category
,
tx
.
Status
)),
nil
}
}
return
nil
,
types
.
ErrNotFound
return
nil
,
types
.
ErrNotFound
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment