-
Notifications
You must be signed in to change notification settings - Fork 57
/
main.go
50 lines (39 loc) · 1.16 KB
/
main.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
//go:generate protoc --go_out=plugins=grpc:. proto/chainnode.proto
package main
import (
"flag"
"net"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"github.com/ethereum/go-ethereum/log"
"github.com/savour-labs/wallet-chain-node/config"
wallet2 "github.com/savour-labs/wallet-chain-node/rpc/wallet"
"github.com/savour-labs/wallet-chain-node/walletdispatcher"
)
func main() {
var f = flag.String("c", "config.yml", "config path")
flag.Parse()
conf, err := config.New(*f)
if err != nil {
panic(err)
}
dispatcher, err := walletdispatcher.New(conf)
if err != nil {
log.Error("Setup dispatcher failed", "err", err)
panic(err)
}
grpcServer := grpc.NewServer(grpc.UnaryInterceptor(dispatcher.Interceptor))
defer grpcServer.GracefulStop()
wallet2.RegisterWalletServiceServer(grpcServer, dispatcher)
listen, err := net.Listen("tcp", ":"+conf.Server.Port)
if err != nil {
log.Error("net listen failed", "err", err)
panic(err)
}
reflection.Register(grpcServer)
log.Info("savour dao start success", "port", conf.Server.Port)
if err := grpcServer.Serve(listen); err != nil {
log.Error("grpc server serve failed", "err", err)
panic(err)
}
}