Golang implemented sidechain for Bytom
修订版 | 89067a56631a6c6bcf8eac2e58cccb12b521b9f3 (tree) |
---|---|
时间 | 2019-06-21 17:48:31 |
作者 | HAOYUatHZ <haoyu@prot...> |
Commiter | HAOYUatHZ |
good
@@ -1,13 +1,45 @@ | ||
1 | 1 | package main |
2 | 2 | |
3 | 3 | import ( |
4 | + "encoding/hex" | |
5 | + "encoding/json" | |
4 | 6 | "fmt" |
5 | 7 | ) |
6 | 8 | |
7 | 9 | func main() { |
8 | - bs := []byte{0} | |
9 | - inner(bs) | |
10 | - fmt.Println(bs) | |
10 | + // bs := []byte{0} | |
11 | + // inner(bs) | |
12 | + // fmt.Println(bs) | |
13 | + | |
14 | + // var | |
15 | + raw := [][]byte{[]byte{1, 3}, []byte{2}} | |
16 | + // // fmt.Println(raw) | |
17 | + | |
18 | + // str := "[" | |
19 | + // str += "]" | |
20 | + | |
21 | + var store []string | |
22 | + for _, part := range raw { | |
23 | + store = append(store, hex.EncodeToString(part)) | |
24 | + } | |
25 | + | |
26 | + b, _ /*err*/ := json.Marshal(store) | |
27 | + fmt.Println(string(b)) | |
28 | + // fmt.Println(b) | |
29 | + | |
30 | + var store2 []string | |
31 | + json.Unmarshal(b, &store2) | |
32 | + fmt.Println(store2) | |
33 | + | |
34 | + var raw2 [][]byte | |
35 | + for _, part := range store2 { | |
36 | + b, _ := hex.DecodeString(part) | |
37 | + raw2 = append(raw2, b) | |
38 | + } | |
39 | + | |
40 | + fmt.Println(raw) | |
41 | + fmt.Println(raw2) | |
42 | + | |
11 | 43 | } |
12 | 44 | |
13 | 45 | func inner(bs []byte) { |