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
13813d32
Commit
13813d32
authored
Jan 08, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
836a1f1c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
56 deletions
+41
-56
game.go
plugin/dapp/guess/commands/game.go
+10
-10
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+13
-27
query.go
plugin/dapp/guess/executor/query.go
+6
-6
guess.proto
plugin/dapp/guess/proto/guess.proto
+2
-2
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+10
-11
No files found.
plugin/dapp/guess/commands/game.go
View file @
13813d32
...
@@ -266,10 +266,10 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -266,10 +266,10 @@ func guessQuery(cmd *cobra.Command, args []string) {
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
category
,
_
:=
cmd
.
Flags
()
.
GetString
(
"category"
)
primary
,
_
:=
cmd
.
Flags
()
.
GetString
(
"primary"
)
primary
,
_
:=
cmd
.
Flags
()
.
GetString
(
"primary"
)
var
primaryKey
[]
byte
//
var primaryKey []byte
if
len
(
primary
)
>
0
{
//
if len(primary) > 0 {
primaryKey
=
[]
byte
(
primary
)
//
primaryKey = []byte(primary)
}
//
}
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
params
.
Execer
=
gty
.
GuessX
params
.
Execer
=
gty
.
GuessX
...
@@ -309,7 +309,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -309,7 +309,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
req
:=
&
gty
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Addr
:
addr
,
Addr
:
addr
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primary
Key
,
PrimaryKey
:
primary
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddr
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddr
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -321,7 +321,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -321,7 +321,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
req
:=
&
gty
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primary
Key
,
PrimaryKey
:
primary
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -333,7 +333,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -333,7 +333,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
req
:=
&
gty
.
QueryGuessGameInfo
{
req
:=
&
gty
.
QueryGuessGameInfo
{
AdminAddr
:
adminAddr
,
AdminAddr
:
adminAddr
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primary
Key
,
PrimaryKey
:
primary
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminAddr
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminAddr
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -346,7 +346,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -346,7 +346,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
Addr
:
addr
,
Addr
:
addr
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primary
Key
,
PrimaryKey
:
primary
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddrStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByAddrStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -359,7 +359,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -359,7 +359,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
AdminAddr
:
adminAddr
,
AdminAddr
:
adminAddr
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primary
Key
,
PrimaryKey
:
primary
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByAdminStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
@@ -372,7 +372,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
...
@@ -372,7 +372,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
Category
:
category
,
Category
:
category
,
Status
:
status
,
Status
:
status
,
Index
:
index
,
Index
:
index
,
PrimaryKey
:
primary
Key
,
PrimaryKey
:
primary
,
}
}
params
.
FuncName
=
gty
.
FuncNameQueryGameByCategoryStatus
params
.
FuncName
=
gty
.
FuncNameQueryGameByCategoryStatus
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
params
.
Payload
=
types
.
MustPBToJSON
(
req
)
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
13813d32
...
@@ -32,7 +32,7 @@ const (
...
@@ -32,7 +32,7 @@ const (
ListASC
=
int32
(
1
)
ListASC
=
int32
(
1
)
//DefaultCount 默认一次获取的记录数
//DefaultCount 默认一次获取的记录数
DefaultCount
=
int32
(
20
)
DefaultCount
=
int32
(
6
)
//DefaultCategory 默认分类
//DefaultCategory 默认分类
DefaultCategory
=
"default"
DefaultCategory
=
"default"
...
@@ -172,11 +172,9 @@ func queryUserTableData(query *table.Query, indexName string, prefix, primaryKey
...
@@ -172,11 +172,9 @@ func queryUserTableData(query *table.Query, indexName string, prefix, primaryKey
records
=
append
(
records
,
&
record
)
records
=
append
(
records
,
&
record
)
}
}
var
primary
[]
byte
var
primary
string
if
len
(
rows
)
==
int
(
DefaultCount
)
{
if
len
(
rows
)
==
int
(
DefaultCount
)
{
primary
=
rows
[
len
(
rows
)
-
1
]
.
Primary
primary
=
string
(
rows
[
len
(
rows
)
-
1
]
.
Primary
)
}
else
{
primary
=
nil
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
...
@@ -199,11 +197,9 @@ func queryGameTableData(query *table.Query, indexName string, prefix, primaryKey
...
@@ -199,11 +197,9 @@ func queryGameTableData(query *table.Query, indexName string, prefix, primaryKey
records
=
append
(
records
,
&
record
)
records
=
append
(
records
,
&
record
)
}
}
var
primary
[]
byte
var
primary
string
if
len
(
rows
)
==
int
(
DefaultCount
)
{
if
len
(
rows
)
==
int
(
DefaultCount
)
{
primary
=
rows
[
len
(
rows
)
-
1
]
.
Primary
primary
=
string
(
rows
[
len
(
rows
)
-
1
]
.
Primary
)
}
else
{
primary
=
nil
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
...
@@ -226,11 +222,9 @@ func queryJoinTableData(talbeJoin *table.JoinTable, indexName string, prefix, pr
...
@@ -226,11 +222,9 @@ func queryJoinTableData(talbeJoin *table.JoinTable, indexName string, prefix, pr
records
=
append
(
records
,
&
record
)
records
=
append
(
records
,
&
record
)
}
}
var
primary
[]
byte
var
primary
string
if
len
(
rows
)
==
int
(
DefaultCount
)
{
if
len
(
rows
)
==
int
(
DefaultCount
)
{
primary
=
rows
[
len
(
rows
)
-
1
]
.
Primary
primary
=
fmt
.
Sprintf
(
"%018d"
,
rows
[
len
(
rows
)
-
1
]
.
Data
.
(
*
table
.
JoinData
)
.
Left
.
(
*
gty
.
UserBet
)
.
Index
)
}
else
{
primary
=
nil
}
}
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
return
&
gty
.
GuessGameRecords
{
Records
:
records
,
PrimaryKey
:
primary
},
nil
...
@@ -288,12 +282,14 @@ func (action *Action) getReceiptLog(game *gty.GuessGame, statusChange bool, bet
...
@@ -288,12 +282,14 @@ func (action *Action) getReceiptLog(game *gty.GuessGame, statusChange bool, bet
func
(
action
*
Action
)
readGame
(
id
string
)
(
*
gty
.
GuessGame
,
error
)
{
func
(
action
*
Action
)
readGame
(
id
string
)
(
*
gty
.
GuessGame
,
error
)
{
data
,
err
:=
action
.
db
.
Get
(
Key
(
id
))
data
,
err
:=
action
.
db
.
Get
(
Key
(
id
))
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"readGame have err:"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
}
}
var
game
gty
.
GuessGame
var
game
gty
.
GuessGame
//decode
//decode
err
=
types
.
Decode
(
data
,
&
game
)
err
=
types
.
Decode
(
data
,
&
game
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"decode game have err:"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
}
}
return
&
game
,
nil
return
&
game
,
nil
...
@@ -402,8 +398,6 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
...
@@ -402,8 +398,6 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
receiptLog
:=
action
.
getReceiptLog
(
game
,
false
,
nil
)
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
...
@@ -414,7 +408,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -414,7 +408,7 @@ 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
:=
queryGameInfo
(
action
.
localDB
,
[]
byte
(
pbBet
.
GetGameID
()
))
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameID
(
))
if
err
!=
nil
||
game
==
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
)
...
@@ -498,8 +492,6 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
...
@@ -498,8 +492,6 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
}
}
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
...
@@ -510,7 +502,7 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
...
@@ -510,7 +502,7 @@ 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
:=
queryGameInfo
(
action
.
localDB
,
[]
byte
(
pbBet
.
GetGameID
()
))
game
,
err
:=
action
.
readGame
(
pbBet
.
GetGameID
(
))
if
err
!=
nil
||
game
==
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
)
...
@@ -538,8 +530,6 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
...
@@ -538,8 +530,6 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
receiptLog
=
action
.
getReceiptLog
(
game
,
true
,
nil
)
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
...
@@ -572,7 +562,7 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
...
@@ -572,7 +562,7 @@ 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
:=
queryGameInfo
(
action
.
localDB
,
[]
byte
(
publish
.
GetGameID
()
))
game
,
err
:=
action
.
readGame
(
publish
.
GetGameID
(
))
if
err
!=
nil
||
game
==
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
)
...
@@ -706,8 +696,6 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
...
@@ -706,8 +696,6 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
receiptLog
=
action
.
getReceiptLog
(
game
,
true
,
nil
)
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
...
@@ -718,7 +706,7 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
...
@@ -718,7 +706,7 @@ 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
:=
queryGameInfo
(
action
.
localDB
,
[]
byte
(
pbend
.
GetGameID
()
))
game
,
err
:=
action
.
readGame
(
pbend
.
GetGameID
(
))
if
err
!=
nil
||
game
==
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
)
...
@@ -774,8 +762,6 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
...
@@ -774,8 +762,6 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
receiptLog
:=
action
.
getReceiptLog
(
game
,
true
,
nil
)
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
}
}
...
...
plugin/dapp/guess/executor/query.go
View file @
13813d32
...
@@ -32,7 +32,7 @@ func (g *Guess) Query_QueryGamesByAddr(in *gty.QueryGuessGameInfo) (types.Messag
...
@@ -32,7 +32,7 @@ func (g *Guess) Query_QueryGamesByAddr(in *gty.QueryGuessGameInfo) (types.Messag
gameTable
:=
gty
.
NewGuessUserTable
(
g
.
GetLocalDB
())
gameTable
:=
gty
.
NewGuessUserTable
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
queryUserTableData
(
query
,
"addr"
,
[]
byte
(
in
.
Addr
),
in
.
PrimaryKey
)
return
queryUserTableData
(
query
,
"addr"
,
[]
byte
(
in
.
Addr
),
[]
byte
(
in
.
PrimaryKey
)
)
}
}
//Query_QueryGamesByStatus method
//Query_QueryGamesByStatus method
...
@@ -40,7 +40,7 @@ func (g *Guess) Query_QueryGamesByStatus(in *gty.QueryGuessGameInfo) (types.Mess
...
@@ -40,7 +40,7 @@ func (g *Guess) Query_QueryGamesByStatus(in *gty.QueryGuessGameInfo) (types.Mess
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
return
queryGameTableData
(
query
,
"status"
,
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
in
.
Status
)),
in
.
PrimaryKey
)
return
queryGameTableData
(
query
,
"status"
,
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
in
.
Status
)),
[]
byte
(
in
.
PrimaryKey
)
)
}
}
//Query_QueryGamesByAdminAddr method
//Query_QueryGamesByAdminAddr method
...
@@ -48,7 +48,7 @@ func (g *Guess) Query_QueryGamesByAdminAddr(in *gty.QueryGuessGameInfo) (types.M
...
@@ -48,7 +48,7 @@ func (g *Guess) Query_QueryGamesByAdminAddr(in *gty.QueryGuessGameInfo) (types.M
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
gameTable
:=
gty
.
NewGuessGameTable
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
prefix
:=
[]
byte
(
in
.
AdminAddr
)
prefix
:=
[]
byte
(
in
.
AdminAddr
)
return
queryGameTableData
(
query
,
"admin"
,
prefix
,
in
.
PrimaryKey
)
return
queryGameTableData
(
query
,
"admin"
,
prefix
,
[]
byte
(
in
.
PrimaryKey
)
)
}
}
//Query_QueryGamesByAddrStatus method
//Query_QueryGamesByAddrStatus method
...
@@ -62,7 +62,7 @@ func (g *Guess) Query_QueryGamesByAddrStatus(in *gty.QueryGuessGameInfo) (types.
...
@@ -62,7 +62,7 @@ func (g *Guess) Query_QueryGamesByAddrStatus(in *gty.QueryGuessGameInfo) (types.
prefix
:=
table
.
JoinKey
([]
byte
(
in
.
Addr
),
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
in
.
Status
)))
prefix
:=
table
.
JoinKey
([]
byte
(
in
.
Addr
),
[]
byte
(
fmt
.
Sprintf
(
"%2d"
,
in
.
Status
)))
return
queryJoinTableData
(
tableJoin
,
"addr#status"
,
prefix
,
in
.
PrimaryKey
)
return
queryJoinTableData
(
tableJoin
,
"addr#status"
,
prefix
,
[]
byte
(
in
.
PrimaryKey
)
)
}
}
//Query_QueryGamesByAdminStatus method
//Query_QueryGamesByAdminStatus method
...
@@ -71,7 +71,7 @@ func (g *Guess) Query_QueryGamesByAdminStatus(in *gty.QueryGuessGameInfo) (types
...
@@ -71,7 +71,7 @@ func (g *Guess) Query_QueryGamesByAdminStatus(in *gty.QueryGuessGameInfo) (types
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
in
.
AdminAddr
,
in
.
Status
))
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
in
.
AdminAddr
,
in
.
Status
))
return
queryGameTableData
(
query
,
"admin_status"
,
prefix
,
in
.
PrimaryKey
)
return
queryGameTableData
(
query
,
"admin_status"
,
prefix
,
[]
byte
(
in
.
PrimaryKey
)
)
}
}
//Query_QueryGamesByCategoryStatus method
//Query_QueryGamesByCategoryStatus method
...
@@ -80,5 +80,5 @@ func (g *Guess) Query_QueryGamesByCategoryStatus(in *gty.QueryGuessGameInfo) (ty
...
@@ -80,5 +80,5 @@ func (g *Guess) Query_QueryGamesByCategoryStatus(in *gty.QueryGuessGameInfo) (ty
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
query
:=
gameTable
.
GetQuery
(
g
.
GetLocalDB
())
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
in
.
Category
,
in
.
Status
))
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s:%2d"
,
in
.
Category
,
in
.
Status
))
return
queryGameTableData
(
query
,
"category_status"
,
prefix
,
in
.
PrimaryKey
)
return
queryGameTableData
(
query
,
"category_status"
,
prefix
,
[]
byte
(
in
.
PrimaryKey
)
)
}
}
plugin/dapp/guess/proto/guess.proto
View file @
13813d32
...
@@ -130,7 +130,7 @@ message QueryGuessGameInfo {
...
@@ -130,7 +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
;
string
primaryKey
=
7
;
}
}
//ReplyGuessGameInfo 游戏信息查询响应消息
//ReplyGuessGameInfo 游戏信息查询响应消息
...
@@ -229,7 +229,7 @@ message GuessGameRecord {
...
@@ -229,7 +229,7 @@ message GuessGameRecord {
// GuessGameRecords game信息查询记录集
// GuessGameRecords game信息查询记录集
message
GuessGameRecords
{
message
GuessGameRecords
{
repeated
GuessGameRecord
records
=
1
;
repeated
GuessGameRecord
records
=
1
;
bytes
primaryKey
=
2
;
string
primaryKey
=
2
;
}
}
...
...
plugin/dapp/guess/types/guess.pb.go
View file @
13813d32
...
@@ -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.
...
@@ -1159,7 +1158,7 @@ type QueryGuessGameInfo struct {
...
@@ -1159,7 +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"`
PrimaryKey
string
`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:"-"`
...
@@ -1232,11 +1231,11 @@ func (m *QueryGuessGameInfo) GetCategory() string {
...
@@ -1232,11 +1231,11 @@ func (m *QueryGuessGameInfo) GetCategory() string {
return
""
return
""
}
}
func
(
m
*
QueryGuessGameInfo
)
GetPrimaryKey
()
[]
byte
{
func
(
m
*
QueryGuessGameInfo
)
GetPrimaryKey
()
string
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
PrimaryKey
return
m
.
PrimaryKey
}
}
return
nil
return
""
}
}
//ReplyGuessGameInfo 游戏信息查询响应消息
//ReplyGuessGameInfo 游戏信息查询响应消息
...
@@ -1986,7 +1985,7 @@ func (m *GuessGameRecord) GetStartIndex() int64 {
...
@@ -1986,7 +1985,7 @@ func (m *GuessGameRecord) GetStartIndex() 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"`
PrimaryKey
string
`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:"-"`
...
@@ -2024,11 +2023,11 @@ func (m *GuessGameRecords) GetRecords() []*GuessGameRecord {
...
@@ -2024,11 +2023,11 @@ func (m *GuessGameRecords) GetRecords() []*GuessGameRecord {
return
nil
return
nil
}
}
func
(
m
*
GuessGameRecords
)
GetPrimaryKey
()
[]
byte
{
func
(
m
*
GuessGameRecords
)
GetPrimaryKey
()
string
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
PrimaryKey
return
m
.
PrimaryKey
}
}
return
nil
return
""
}
}
func
init
()
{
func
init
()
{
...
@@ -2121,7 +2120,7 @@ var fileDescriptor_7574406c5d3430e8 = []byte{
...
@@ -2121,7 +2120,7 @@ var fileDescriptor_7574406c5d3430e8 = []byte{
0x63
,
0xac
,
0x6e
,
0xf7
,
0x4f
,
0x03
,
0x18
,
0x9d
,
0x58
,
0x9f
,
0xbf
,
0x0c
,
0xaf
,
0xa2
,
0xad
,
0xc7
,
0x63
,
0xac
,
0x6e
,
0xf7
,
0x4f
,
0x03
,
0x18
,
0x9d
,
0x58
,
0x9f
,
0xbf
,
0x0c
,
0xaf
,
0xa2
,
0xad
,
0xc7
,
0x33
,
0xb0
,
0x30
,
0x35
,
0xb0
,
0xc8
,
0x97
,
0x2f
,
0xab
,
0xb0
,
0x7c
,
0xad
,
0x07
,
0x75
,
0x4d
,
0x1f
,
0x33
,
0xb0
,
0x30
,
0x35
,
0xb0
,
0xc8
,
0x97
,
0x2f
,
0xab
,
0xb0
,
0x7c
,
0xad
,
0x07
,
0x75
,
0x4d
,
0x1f
,
0xd4
,
0x05
,
0x10
,
0xb6
,
0xcb
,
0x20
,
0xac
,
0x37
,
0x48
,
0xbd
,
0xd4
,
0x20
,
0x0f
,
0x00
,
0xe2
,
0x24
,
0xd4
,
0x05
,
0x10
,
0xb6
,
0xcb
,
0x20
,
0xac
,
0x37
,
0x48
,
0xbd
,
0xd4
,
0x20
,
0x0f
,
0x00
,
0xe2
,
0x24
,
0x98
,
0xfb
,
0xc9
,
0xea
,
0x3b
,
0x2e
,
0x1b
,
0xb4
,
0xe
3
,
0x69
,
0x1c
,
0xf7
,
0x19
,
0x30
,
0x8f
,
0xc7
,
0x98
,
0xfb
,
0xc9
,
0xea
,
0x3b
,
0x2e
,
0x1b
,
0xb4
,
0xe
5
,
0x69
,
0x1c
,
0xf7
,
0x19
,
0x30
,
0x8f
,
0xc7
,
0xb3
,
0xd2
,
0x4b
,
0x1e
,
0x42
,
0x0d
,
0x7d
,
0x57
,
0xd3
,
0xae
,
0x5b
,
0x6e
,
0x7e
,
0x8f
,
0xa4
,
0xee
,
0xb3
,
0xd2
,
0x4b
,
0x1e
,
0x42
,
0x0d
,
0x7d
,
0x57
,
0xd3
,
0xae
,
0x5b
,
0x6e
,
0x7e
,
0x8f
,
0xa4
,
0xee
,
0x17
,
0x70
,
0xb6
,
0x19
,
0x85
,
0x14
,
0x6b
,
0x41
,
0x3e
,
0x1c
,
0x21
,
0xc2
,
0xc2
,
0x4e
,
0x56
,
0xa4
,
0x17
,
0x70
,
0xb6
,
0x19
,
0x85
,
0x14
,
0x6b
,
0x41
,
0x3e
,
0x1c
,
0x21
,
0xc2
,
0xc2
,
0x4e
,
0x56
,
0xa4
,
0xfb
,
0x1c
,
0xce
,
0x36
,
0x8d
,
0xa5
,
0xec
,
0x11
,
0xd8
,
0xa8
,
0x21
,
0xd5
,
0xab
,
0xcc
,
0x49
,
0xb1
,
0xfb
,
0x1c
,
0xce
,
0x36
,
0x8d
,
0xa5
,
0xec
,
0x11
,
0xd8
,
0xa8
,
0x21
,
0xd5
,
0xab
,
0xcc
,
0x49
,
0xb1
,
...
@@ -2147,8 +2146,8 @@ var fileDescriptor_7574406c5d3430e8 = []byte{
...
@@ -2147,8 +2146,8 @@ var fileDescriptor_7574406c5d3430e8 = []byte{
0xf7
,
0xec
,
0xf3
,
0xec
,
0xc7
,
0xd5
,
0xfb
,
0x30
,
0x0d
,
0xa6
,
0xe1
,
0xbb
,
0xa5
,
0x7b
,
0xc4
,
0x06
,
0xf7
,
0xec
,
0xf3
,
0xec
,
0xc7
,
0xd5
,
0xfb
,
0x30
,
0x0d
,
0xa6
,
0xe1
,
0xbb
,
0xa5
,
0x7b
,
0xc4
,
0x06
,
0xda
,
0x0f
,
0xab
,
0xaa
,
0x85
,
0xbb
,
0xea
,
0xcc
,
0x33
,
0xb5
,
0xf4
,
0x64
,
0x6b
,
0xc9
,
0xb6
,
0xdd
,
0xda
,
0x0f
,
0xab
,
0xaa
,
0x85
,
0xbb
,
0xea
,
0xcc
,
0x33
,
0xb5
,
0xf4
,
0x64
,
0x6b
,
0xc9
,
0xb6
,
0xdd
,
0xbb
,
0xea
,
0x6c
,
0xe6
,
0xa7
,
0x5c
,
0x53
,
0xaa
,
0x57
,
0xf0
,
0x5d
,
0x36
,
0xb3
,
0xa5
,
0x65
,
0xdb
,
0xbb
,
0xea
,
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
,
0x
cf
,
0x2e
,
0x5e
,
0x71
,
0x76
,
0x54
,
0xa7
,
0x7f
,
0x77
,
0x9e
,
0xfe
,
0x13
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
d2
,
0x
a9
,
0x8e
,
0x1b
,
0x06
,
0x12
,
0x00
,
0x00
,
0x
0f
,
0x63
,
0x87
,
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.
...
...
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