/
hashlock.go
executable file
·61 lines (48 loc) · 1.31 KB
/
hashlock.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
// 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/33cn/chain33/common/log/log15"
drivers "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
)
var clog = log.New("module", "execs.hashlock")
const minLockTime = 60
var driverName = "hashlock"
// Init hashlock
func Init(name string, cfg *types.Chain33Config, sub []byte) {
drivers.Register(cfg, GetName(), newHashlock, cfg.GetDappFork(driverName, "Enable"))
InitExecType()
}
//InitExecType ...
func InitExecType() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&Hashlock{}))
}
// GetName for hashlock
func GetName() string {
return newHashlock().GetName()
}
// Hashlock driver
type Hashlock struct {
drivers.DriverBase
}
func newHashlock() drivers.Driver {
h := &Hashlock{}
h.SetChild(h)
h.SetExecutorType(types.LoadExecutorType(driverName))
return h
}
// GetDriverName driverName
func (h *Hashlock) GetDriverName() string {
return driverName
}
// CheckTx nil
func (h *Hashlock) CheckTx(tx *types.Transaction, index int) error {
return nil
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (h *Hashlock) CheckReceiptExecOk() bool {
return true
}