-
Notifications
You must be signed in to change notification settings - Fork 57
/
subscriber.go
59 lines (54 loc) · 1.69 KB
/
subscriber.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
package main
import (
"github.com/FISCO-BCOS/go-sdk/v3/client"
"github.com/sirupsen/logrus"
)
const (
privateKey1 = "b8ac1f6be271cd4ad5644615dea54823f7fa5d860fb8d3ae8b24141d9f1b9486"
privateKey2 = "0fe5e3ce06d6d48ec806ea17d13ce3d80e74b85f23c32c38f2c8e4180f539a7e"
privateKey3 = "13e3531ac291bcf5674acd1c8c7c77b725dc9bf56242b02ef76bf970190412aa"
)
func onPush(data []byte, response *[]byte) {
logrus.Printf("received: %s\n", string(data))
}
var (
c *client.Client
)
func main() {
//privateKey, _ := crypto.HexToECDSA(privateKey1)
//if len(os.Args) == 4 {
// fmt.Printf("use user specified private key %s\n", os.Args[3])
// keyBytes, _, err := client.LoadECPrivateKeyFromPEM(os.Args[3])
// if err != nil {
// fmt.Printf("parse private key failed, err: %v\n", err)
// return
// }
// privateKey, err = crypto.ToECDSA(keyBytes)
// if err != nil {
// fmt.Printf("HexToECDSA failed, err: %v\n", err)
// return
// }
//} else if len(os.Args) < 3 {
// logrus.Fatal("the number of arguments less than 3")
//}
//
//endpoint := os.Args[1]
//topic := os.Args[2]
//signKey, _ := hex.DecodeString("145e247e170ba3afd6ae97e88f00dbc976c2345d511b0f6713355d19d8b80b58")
//config := &client.Config{
// IsSMCrypto: false, GroupID: "group0", PrivateKey: signKey, NodeURL: endpoint}
//c, err := client.DialContext(context.Background(), config)
//if err != nil {
// logrus.Fatalf("init client failed, err: %v\n", err)
//}
//
//err = c.SubscribePrivateTopic(topic, privateKey, onPush)
//if err != nil {
// logrus.Fatalf("SubscribeAuthTopic failed, err: %v\n", err)
//}
//fmt.Println("Subscriber success")
//
//killSignal := make(chan os.Signal, 1)
//signal.Notify(killSignal, os.Interrupt)
//<-killSignal
}