-
Notifications
You must be signed in to change notification settings - Fork 0
/
kv.go
131 lines (103 loc) · 4.02 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// 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/bnchain/bnchain/types"
)
var (
title string
titleHeight string
managerConfigNodes string //manager 合约配置的nodes
paraConfigNodes string //平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr string //平行链配置节点账户
paraNodeGroupStatusAddrs string //正在申请的addrs
paraNodeID string
paraNodeGroupID 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-"
paraNodeGroupStatusAddrs = "mavl-paracross-nodegroup-apply-title-"
paraNodeID = "mavl-paracross-title-nodeid-"
paraNodeGroupID = "mavl-paracross-title-nodegroupid-"
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 calcParaNodeGroupAddrsKey(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 calcParaNodeGroupStatusKey(title string) []byte {
return []byte(fmt.Sprintf(paraNodeGroupStatusAddrs+"%s", title))
}
func calcParaNodeIDKey(title, hash string) string {
return fmt.Sprintf(paraNodeID+"%s-%s", title, hash)
}
func calcParaNodeGroupIDKey(title, hash string) string {
return fmt.Sprintf(paraNodeGroupID+"%s-%s", title, hash)
}
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 string, status int32, id string) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-%02d-%s", title, status, id))
}
func calcLocalNodeStatusPrefix(title string, status int32) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-%02d-", title, status))
}
func calcLocalNodeTitlePrefix(title string) []byte {
return []byte(fmt.Sprintf(localNodeTitleStatus+"%s-", title))
}
func calcLocalNodeTitleDone(title, addr string) []byte {
return []byte(fmt.Sprintf(localNodeTitleDone+"%s-%s", title, addr))
}
func calcLocalNodeGroupStatusTitle(status int32, title, id string) []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle+"%02d-%s-%s", status, title, id))
}
func calcLocalNodeGroupStatusPrefix(status int32) []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle+"%02d-", status))
}
func calcLocalNodeGroupAllPrefix() []byte {
return []byte(fmt.Sprintf(localNodeGroupStatusTitle))
}