-
Notifications
You must be signed in to change notification settings - Fork 1
/
guess.go
71 lines (57 loc) · 1.65 KB
/
guess.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
60
61
62
63
64
65
66
67
68
69
70
71
// 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 executor
import (
log "github.com/assetcloud/chain/common/log/log15"
drivers "github.com/assetcloud/chain/system/dapp"
"github.com/assetcloud/chain/types"
gty "github.com/assetcloud/plugin/plugin/dapp/guess/types"
)
var logger = log.New("module", "execs.guess")
var driverName = gty.GuessX
// Init Guess
func Init(name string, cfg *types.ChainConfig, sub []byte) {
driverName := GetName()
if name != driverName {
panic("system dapp can't be rename")
}
drivers.Register(cfg, driverName, newGuessGame, cfg.GetDappFork(driverName, "Enable"))
InitExecType()
}
//InitExecType ...
func InitExecType() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&Guess{}))
}
//Guess 执行器,用于竞猜合约的具体执行
type Guess struct {
drivers.DriverBase
}
func newGuessGame() drivers.Driver {
t := &Guess{}
t.SetChild(t)
t.SetExecutorType(types.LoadExecutorType(driverName))
return t
}
//GetName 获取Guess执行器的名称
func GetName() string {
return newGuessGame().GetName()
}
//ExecutorOrder Exec 的时候 同时执行 ExecLocal
func (g *Guess) ExecutorOrder() int64 {
return drivers.ExecLocalSameTime
}
//GetDriverName 获取Guess执行器的名称
func (g *Guess) GetDriverName() string {
return gty.GuessX
}
/*
// GetPayloadValue GuessAction
func (g *Guess) GetPayloadValue() types.Message {
return &pkt.GuessGameAction{}
}*/
// CheckReceiptExecOk return true to check if receipt ty is ok
func (g *Guess) CheckReceiptExecOk() bool {
return true
}