forked from MixinNetwork/mobilecoin-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfog.go
35 lines (28 loc) · 738 Bytes
/
fog.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
package api
import (
"context"
"crypto/tls"
"fmt"
"net/url"
"github.com/MixinNetwork/mobilecoin-account/types"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
func GetFogReportResponse(address string) (*types.ReportResponse, error) {
uri, err := url.Parse(address)
if err != nil {
return nil, err
}
// Use system RootCAs
creds := credentials.NewTLS(&tls.Config{})
var opts []grpc.DialOption
opts = append(opts, grpc.WithTransportCredentials(creds))
conn, err := grpc.Dial(fmt.Sprintf("%s:443", uri.Host), opts...)
if err != nil {
return nil, err
}
defer conn.Close()
client := types.NewReportAPIClient(conn)
in := &types.ReportRequest{}
return client.GetReports(context.Background(), in)
}