-
Notifications
You must be signed in to change notification settings - Fork 6
/
kv.go
111 lines (87 loc) · 3.37 KB
/
kv.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 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"
"github.com/33cn/chain33/types"
)
var (
title string
titleHeight string
managerConfigNodes string //manager 合约配置的nodes
paraConfigNodes string //平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr string //平行链配置节点账户
paraNodeGroupApplyAddrs string
localTx string
localTitle string
localTitleHeight string
localAssetKey string
localNodeTitleStatus string
localNodeTitleDone string
localNodeGroupStatusTitle string
)
func setPrefix() {
title = "mavl-paracross-title-"
titleHeight = "mavl-paracross-titleHeight-"
managerConfigNodes = "paracross-nodes-"
paraConfigNodes = "mavl-paracross-nodes-title-"
paraConfigNodeAddr = "mavl-paracross-nodes-titleAddr-"
paraNodeGroupApplyAddrs = "mavl-paracross-nodegroup-apply-title-"
localTx = "LODB-paracross-titleHeightAddr-"
localTitle = "LODB-paracross-title-"
localTitleHeight = "LODB-paracross-titleHeight-"
localAssetKey = "LODB-paracross-asset-"
localNodeTitleStatus = "LODB-paracross-nodesTitleStatus-"
localNodeTitleDone = "LODB-paracross-nodesTitleDone-"
localNodeGroupStatusTitle = "LODB-paracross-nodegroupStatusTitle-"
}
func calcTitleKey(t string) []byte {
return []byte(fmt.Sprintf(title+"%s", t))
}
func calcTitleHeightKey(title string, height int64) []byte {
return []byte(fmt.Sprintf(titleHeight+"%s-%d", title, height))
}
func calcLocalHeightKey(title string, height int64) []byte {
return []byte(fmt.Sprintf(localTitleHeight+"%s-%d", title, height))
}
func calcManageConfigNodesKey(title string) []byte {
key := managerConfigNodes + title
return []byte(types.ManageKey(key))
}
func calcParaNodeGroupKey(title string) []byte {
return []byte(fmt.Sprintf(paraConfigNodes+"%s", title))
}
func calcParaNodeAddrKey(title string, addr string) []byte {
return []byte(fmt.Sprintf(paraConfigNodeAddr+"%s-%s", title, addr))
}
func calcParaNodeGroupApplyKey(title string) []byte {
return []byte(fmt.Sprintf(paraNodeGroupApplyAddrs+"%s", title))
}
func calcLocalTxKey(title string, height int64, addr string) []byte {
return []byte(fmt.Sprintf(localTx+"%s-%012-%s", title, height, addr))
}
func calcLocalTitleKey(title string) []byte {
return []byte(fmt.Sprintf(localTitle+"%s", title))
}
func calcLocalTitlePrefix() []byte {
return []byte(localTitle)
}
func calcLocalAssetKey(hash []byte) []byte {
return []byte(fmt.Sprintf(localAssetKey+"%s", hash))
}
func calcLocalNodeTitleStatus(title, addr string, status int32) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-%02d-%s", title, status, addr))
}
func calcLocalNodeStatusPrefix(title string, status int32) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-%02d", title, status))
}
func calcLocalNodeTitleDone(title, addr string) []byte {
return []byte(fmt.Sprintf(localNodeTitleDone+"%s-%s", title, addr))
}
func calcLocalNodeGroupStatusTitle(status int32, title string) []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle+"%02d-%s", status, title))
}
func calcLocalNodeGroupStatusPrefix(status int32) []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle+"%02d", status))
}