-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestStorage.go
47 lines (32 loc) · 1.04 KB
/
TestStorage.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
package main
import (
"github.com/PlatONnetwork/PlatON-Go/core/state"
"github.com/PlatONnetwork/PlatON-Go/common"
"encoding/json"
"fmt"
)
func main() {
store := make(state.Storage)
valStore := make(state.ValueStorage)
store["A"] = common.BytesToHash([]byte("a"))
valStore[common.BytesToHash([]byte("a"))] = []byte("Aa")
store["B"] = common.BytesToHash([]byte("b"))
valStore[common.BytesToHash([]byte("b"))] = []byte("Bb")
store["C"] = common.BytesToHash([]byte("c"))
valStore[common.BytesToHash([]byte("c"))] = []byte("Cc")
originStore := make(state.Storage)
originValStore := make(state.ValueStorage)
sb, _ := json.Marshal(store)
svb, _ := json.Marshal(valStore)
fmt.Println("store", string(sb))
fmt.Println("valStore", string(svb))
for key, valueKey := range store {
value := valStore[valueKey]
originStore[key] = valueKey
originValStore[valueKey] = value
}
ob, _ := json.Marshal(originStore)
ovb, _ := json.Marshal(originValStore)
fmt.Println("originStore", string(ob))
fmt.Println("originValStore", string(ovb))
}