-
Notifications
You must be signed in to change notification settings - Fork 0
/
valnode.go
75 lines (60 loc) · 1.74 KB
/
valnode.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
72
73
74
75
// 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 (
"fmt"
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.valnode")
var driverName = "valnode"
func init() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&ValNode{}))
}
// Init method
func Init(name string, sub []byte) {
clog.Debug("register valnode execer")
drivers.Register(GetName(), newValNode, 0)
}
// GetName method
func GetName() string {
return newValNode().GetName()
}
// ValNode strucyt
type ValNode struct {
drivers.DriverBase
}
func newValNode() drivers.Driver {
n := &ValNode{}
n.SetChild(n)
n.SetIsFree(true)
n.SetExecutorType(types.LoadExecutorType(driverName))
return n
}
// GetDriverName method
func (val *ValNode) GetDriverName() string {
return driverName
}
// CheckTx method
func (val *ValNode) CheckTx(tx *types.Transaction, index int) error {
return nil
}
// CalcValNodeUpdateHeightIndexKey method
func CalcValNodeUpdateHeightIndexKey(height int64, index int) []byte {
return []byte(fmt.Sprintf("LODB-valnode-Update:%18d:%18d", height, int64(index)))
}
// CalcValNodeUpdateHeightKey method
func CalcValNodeUpdateHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-valnode-Update:%18d:", height))
}
// CalcValNodeBlockInfoHeightKey method
func CalcValNodeBlockInfoHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-valnode-BlockInfo:%18d:", height))
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func (val *ValNode) CheckReceiptExecOk() bool {
return true
}