You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
641 B

  1. package grpcdb
  2. import (
  3. "google.golang.org/grpc"
  4. "google.golang.org/grpc/credentials"
  5. protodb "github.com/tendermint/tendermint/libs/db/remotedb/proto"
  6. )
  7. // NewClient creates a gRPC client connected to the bound gRPC server at serverAddr.
  8. // Use kind to set the level of security to either Secure or Insecure.
  9. func NewClient(serverAddr, serverCert string) (protodb.DBClient, error) {
  10. creds, err := credentials.NewClientTLSFromFile(serverCert, "")
  11. if err != nil {
  12. return nil, err
  13. }
  14. cc, err := grpc.Dial(serverAddr, grpc.WithTransportCredentials(creds))
  15. if err != nil {
  16. return nil, err
  17. }
  18. return protodb.NewDBClient(cc), nil
  19. }