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
e22ff037
Commit
e22ff037
authored
Nov 27, 2018
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guess
parent
af1ce4be
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
56 deletions
+36
-56
exec.go
plugin/dapp/guess/executor/exec.go
+10
-4
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+0
-0
plugin.go
plugin/dapp/guess/plugin.go
+1
-1
guess.proto
plugin/dapp/guess/proto/guess.proto
+6
-5
rpc.go
plugin/dapp/guess/rpc/rpc.go
+1
-1
const.go
plugin/dapp/guess/types/const.go
+6
-2
guess.pb.go
plugin/dapp/guess/types/guess.pb.go
+0
-0
types.go
plugin/dapp/guess/types/types.go
+12
-43
No files found.
plugin/dapp/guess/executor/exec.go
View file @
e22ff037
...
@@ -14,12 +14,17 @@ func (c *Guess) Exec_Start(payload *pkt.GuessGameStart, tx *types.Transaction, i
...
@@ -14,12 +14,17 @@ func (c *Guess) Exec_Start(payload *pkt.GuessGameStart, tx *types.Transaction, i
return
action
.
GameStart
(
payload
)
return
action
.
GameStart
(
payload
)
}
}
func
(
c
*
Guess
)
Exec_
Continue
(
payload
*
pkt
.
PBGameContinue
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_
Bet
(
payload
*
pkt
.
GuessGameBet
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
Game
Continue
(
payload
)
return
action
.
Game
Bet
(
payload
)
}
}
func
(
c
*
Guess
)
Exec_
Quit
(
payload
*
pkt
.
PBGameQuit
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
c
*
Guess
)
Exec_
Publish
(
payload
*
pkt
.
GuessGamePublish
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameQuit
(
payload
)
return
action
.
GamePublish
(
payload
)
}
func
(
c
*
Guess
)
Exec_Abort
(
payload
*
pkt
.
GuessGameAbort
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
c
,
tx
,
index
)
return
action
.
GameAbort
(
payload
)
}
}
\ No newline at end of file
plugin/dapp/guess/executor/guessdb.go
View file @
e22ff037
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/plugin.go
View file @
e22ff037
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
func
init
()
{
func
init
()
{
pluginmgr
.
Register
(
&
pluginmgr
.
PluginBase
{
pluginmgr
.
Register
(
&
pluginmgr
.
PluginBase
{
Name
:
types
.
PokerBull
X
,
Name
:
types
.
Guess
X
,
ExecName
:
executor
.
GetName
(),
ExecName
:
executor
.
GetName
(),
Exec
:
executor
.
Init
,
Exec
:
executor
.
Init
,
Cmd
:
commands
.
GuessCmd
,
Cmd
:
commands
.
GuessCmd
,
...
...
plugin/dapp/guess/proto/guess.proto
View file @
e22ff037
...
@@ -14,7 +14,7 @@ message GuessGame {
...
@@ -14,7 +14,7 @@ message GuessGame {
string
category
=
6
;
//分类
string
category
=
6
;
//分类
string
options
=
7
;
//选项
string
options
=
7
;
//选项
string
maxTime
=
8
;
//截止下注时间
string
maxTime
=
8
;
//截止下注时间
uint32
maxHeight
=
9
;
//截止下注的块高
int64
maxHeight
=
9
;
//截止下注的块高
string
symbol
=
10
;
//bty或者具体token
string
symbol
=
10
;
//bty或者具体token
string
exec
=
11
;
//coins或者token
string
exec
=
11
;
//coins或者token
uint32
oneBet
=
12
;
//一注等于多少bty或者token
uint32
oneBet
=
12
;
//一注等于多少bty或者token
...
@@ -23,17 +23,18 @@ message GuessGame {
...
@@ -23,17 +23,18 @@ message GuessGame {
uint32
fee
=
15
;
//收取费用,不带则表示不收费
uint32
fee
=
15
;
//收取费用,不带则表示不收费
string
feeAddr
=
16
;
//收费地址
string
feeAddr
=
16
;
//收费地址
string
expire
=
17
;
//游戏过期时间
string
expire
=
17
;
//游戏过期时间
uint32
expireHeight
=
18
;
//游戏过期区块高度
int64
expireHeight
=
18
;
//游戏过期区块高度
string
adminAddr
=
19
;
//游戏创建者地址,只有该地址可以开奖
string
adminAddr
=
19
;
//游戏创建者地址,只有该地址可以开奖
uint32
betsNumber
=
20
;
//已下注数,如果数量达到maxBetsNumber,则不允许再下注
uint32
betsNumber
=
20
;
//已下注数,如果数量达到maxBetsNumber,则不允许再下注
repeated
GuessPlayer
plays
=
21
;
//参与游戏下注的玩家投注信息
repeated
GuessPlayer
plays
=
21
;
//参与游戏下注的玩家投注信息
string
result
=
22
;
string
result
=
22
;
repeated
GuessBet
bets
=
23
;
repeated
GuessBet
bets
=
23
;
int64
index
=
24
;
}
}
message
GuessPlayer
{
message
GuessPlayer
{
string
addr
=
1
;
string
addr
=
1
;
repeated
GuessBet
bets
=
2
;
GuessBet
bet
=
2
;
}
}
message
GuessBet
{
message
GuessBet
{
...
@@ -145,7 +146,7 @@ message GuessGameStart{
...
@@ -145,7 +146,7 @@ message GuessGameStart{
string
options
=
2
;
string
options
=
2
;
string
category
=
3
;
string
category
=
3
;
string
maxTime
=
4
;
string
maxTime
=
4
;
uint32
maxHeight
=
5
;
int64
maxHeight
=
5
;
string
symbol
=
6
;
string
symbol
=
6
;
string
exec
=
7
;
string
exec
=
7
;
uint32
oneBet
=
8
;
uint32
oneBet
=
8
;
...
@@ -154,7 +155,7 @@ message GuessGameStart{
...
@@ -154,7 +155,7 @@ message GuessGameStart{
uint64
fee
=
11
;
uint64
fee
=
11
;
string
feeAddr
=
12
;
string
feeAddr
=
12
;
string
expire
=
13
;
string
expire
=
13
;
uint32
expireHeight
=
14
;
int64
expireHeight
=
14
;
}
}
//参与游戏下注
//参与游戏下注
...
...
plugin/dapp/guess/rpc/rpc.go
View file @
e22ff037
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
pb
"github.com/33cn/plugin/plugin/dapp/guess/types"
pb
"github.com/33cn/plugin/plugin/dapp/guess/types"
"github.com/33cn/plugin/plugin/dapp/
pokerbull
/executor"
"github.com/33cn/plugin/plugin/dapp/
guess
/executor"
)
)
func
(
c
*
channelClient
)
GuessStart
(
ctx
context
.
Context
,
head
*
pb
.
GuessGameStart
)
(
*
types
.
UnsignTx
,
error
)
{
func
(
c
*
channelClient
)
GuessStart
(
ctx
context
.
Context
,
head
*
pb
.
GuessGameStart
)
(
*
types
.
UnsignTx
,
error
)
{
...
...
plugin/dapp/guess/types/const.go
View file @
e22ff037
...
@@ -13,8 +13,10 @@ const (
...
@@ -13,8 +13,10 @@ const (
GuessGameActionStart
=
iota
+
1
GuessGameActionStart
=
iota
+
1
GuessGameActionBet
GuessGameActionBet
GuessGameActionStopBet
GuessGameActionAbort
GuessGameActionAbort
GuessGameActionPublish
GuessGameActionPublish
GuessGameActionTimeOut
)
)
const
(
const
(
...
@@ -31,8 +33,10 @@ const (
...
@@ -31,8 +33,10 @@ const (
TyLogGuessGameStart
=
901
TyLogGuessGameStart
=
901
TyLogGuessGameBet
=
902
TyLogGuessGameBet
=
902
TyLogGuessGameAbort
=
903
TyLogGuessGameStopBet
=
903
TyLogGuessGamePublish
=
904
TyLogGuessGameAbort
=
904
TyLogGuessGamePublish
=
905
TyLogGuessGameTimeout
=
906
)
)
//包的名字可以通过配置文件来配置
//包的名字可以通过配置文件来配置
...
...
plugin/dapp/guess/types/guess.pb.go
View file @
e22ff037
This diff is collapsed.
Click to expand it.
plugin/dapp/guess/types/types.go
View file @
e22ff037
...
@@ -18,40 +18,6 @@ func init() {
...
@@ -18,40 +18,6 @@ func init() {
}
}
// exec
// exec
type
PokerBullType
struct
{
types
.
ExecTypeBase
}
func
NewType
()
*
PokerBullType
{
c
:=
&
PokerBullType
{}
c
.
SetChild
(
c
)
return
c
}
func
(
t
*
PokerBullType
)
GetPayload
()
types
.
Message
{
return
&
PBGameAction
{}
}
func
(
t
*
PokerBullType
)
GetTypeMap
()
map
[
string
]
int32
{
return
map
[
string
]
int32
{
"Start"
:
PBGameActionStart
,
"Continue"
:
PBGameActionContinue
,
"Quit"
:
PBGameActionQuit
,
"Query"
:
PBGameActionQuery
,
}
}
func
(
t
*
PokerBullType
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogPBGameStart
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameStart"
},
TyLogPBGameContinue
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameContinue"
},
TyLogPBGameQuit
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameQuit"
},
TyLogPBGameQuery
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameQuery"
},
}
}
// exec
type
GuessType
struct
{
type
GuessType
struct
{
types
.
ExecTypeBase
types
.
ExecTypeBase
}
}
...
@@ -68,20 +34,23 @@ func (t *GuessType) GetPayload() types.Message {
...
@@ -68,20 +34,23 @@ func (t *GuessType) GetPayload() types.Message {
func
(
t
*
GuessType
)
GetTypeMap
()
map
[
string
]
int32
{
func
(
t
*
GuessType
)
GetTypeMap
()
map
[
string
]
int32
{
return
map
[
string
]
int32
{
return
map
[
string
]
int32
{
"Start"
:
PB
GameActionStart
,
"Start"
:
Guess
GameActionStart
,
"
Continue"
:
PBGameActionContinue
,
"
Bet"
:
GuessGameActionBet
,
"
Quit"
:
PBGameActionQui
t
,
"
Abort"
:
GuessGameActionAbor
t
,
"
Query"
:
PBGameActionQuery
,
"
Publish"
:
GuessGameActionPublish
,
}
}
}
}
func
(
t
*
PokerBull
Type
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
func
(
t
*
Guess
Type
)
GetLogMap
()
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
return
map
[
int64
]
*
types
.
LogInfo
{
TyLogPBGameStart
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameStart"
},
TyLogGuessGameStart
:
{
reflect
.
TypeOf
(
ReceiptGuessGame
{}),
"TyLogGuessGameStart"
},
TyLogPBGameContinue
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameContinue"
},
TyLogGuessGameBet
:
{
reflect
.
TypeOf
(
ReceiptGuessGame
{}),
"TyLogGuessGameBet"
},
TyLogPBGameQuit
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameQuit"
},
TyLogGuessGameStopBet
:
{
reflect
.
TypeOf
(
ReceiptGuessGame
{}),
"TyLogGuessGameStopBet"
},
TyLogPBGameQuery
:
{
reflect
.
TypeOf
(
ReceiptPBGame
{}),
"TyLogPBGameQuery"
},
TyLogGuessGameAbort
:
{
reflect
.
TypeOf
(
ReceiptGuessGame
{}),
"TyLogGuessGameAbort"
},
TyLogGuessGamePublish
:
{
reflect
.
TypeOf
(
ReceiptGuessGame
{}),
"TyLogGuessGamePublish"
},
TyLogGuessGameTimeout
:
{
reflect
.
TypeOf
(
ReceiptGuessGame
{}),
"TyLogGuessGameTimeout"
},
}
}
}
}
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