github.com/tendermint/tmlibs@v0.9.0/db/remotedb/grpcdb/client.go (about) 1 package grpcdb 2 3 import ( 4 "google.golang.org/grpc" 5 "google.golang.org/grpc/credentials" 6 7 protodb "github.com/tendermint/tmlibs/db/remotedb/proto" 8 ) 9 10 // Security defines how the client will talk to the gRPC server. 11 type Security uint 12 13 const ( 14 Insecure Security = iota 15 Secure 16 ) 17 18 // NewClient creates a gRPC client connected to the bound gRPC server at serverAddr. 19 // Use kind to set the level of security to either Secure or Insecure. 20 func NewClient(serverAddr, serverCert string) (protodb.DBClient, error) { 21 creds, err := credentials.NewClientTLSFromFile(serverCert, "") 22 if err != nil { 23 return nil, err 24 } 25 cc, err := grpc.Dial(serverAddr, grpc.WithTransportCredentials(creds)) 26 if err != nil { 27 return nil, err 28 } 29 return protodb.NewDBClient(cc), nil 30 }