forked from 33cn/plugin
/
types.go
59 lines (50 loc) · 1.66 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package types
import (
"reflect"
"github.com/33cn/chain33/types"
)
func init() {
// init executor type
types.RegistorExecutor(GuessX, NewType())
types.AllowUserExec = append(types.AllowUserExec, ExecerGuess)
types.RegisterDappFork(GuessX, "Enable", 0)
}
// GuessType struct
type GuessType struct {
types.ExecTypeBase
}
// NewType method
func NewType() *GuessType {
c := &GuessType{}
c.SetChild(c)
return c
}
// GetPayload method
func (t *GuessType) GetPayload() types.Message {
return &GuessGameAction{}
}
// GetTypeMap method
func (t *GuessType) GetTypeMap() map[string]int32 {
return map[string]int32{
"Start": GuessGameActionStart,
"Bet": GuessGameActionBet,
"StopBet": GuessGameActionStopBet,
"Abort": GuessGameActionAbort,
"Publish": GuessGameActionPublish,
"Query": GuessGameActionQuery,
}
}
// GetLogMap method
func (t *GuessType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{
TyLogGuessGameStart: {Ty: reflect.TypeOf(ReceiptGuessGame{}), Name: "TyLogGuessGameStart"},
TyLogGuessGameBet: {Ty: reflect.TypeOf(ReceiptGuessGame{}), Name: "TyLogGuessGameBet"},
TyLogGuessGameStopBet: {Ty: reflect.TypeOf(ReceiptGuessGame{}), Name: "TyLogGuessGameStopBet"},
TyLogGuessGameAbort: {Ty: reflect.TypeOf(ReceiptGuessGame{}), Name: "TyLogGuessGameAbort"},
TyLogGuessGamePublish: {Ty: reflect.TypeOf(ReceiptGuessGame{}), Name: "TyLogGuessGamePublish"},
TyLogGuessGameTimeout: {Ty: reflect.TypeOf(ReceiptGuessGame{}), Name: "TyLogGuessGameTimeout"},
}
}