storj/satellite/contact/client.go
Yingrong Zhao b7b19289d1 bump storj.io/common to latest
Change-Id: I16e337660ce8e1ef332cc842dbf4cfa067b9b98b
2020-03-25 09:08:40 -04:00

41 lines
874 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package contact
import (
"context"
"storj.io/common/pb"
"storj.io/common/rpc"
"storj.io/common/storj"
)
type client struct {
conn *rpc.Conn
client pb.DRPCContactClient
}
// dialNode dials the target contact endpoint
func dialNode(ctx context.Context, dialer rpc.Dialer, address string, id storj.NodeID) (*client, error) {
conn, err := dialer.DialAddressID(ctx, address, id)
if err != nil {
return nil, err
}
return &client{
conn: conn,
client: pb.NewDRPCContactClient(conn),
}, nil
}
// pingNode pings a node
func (client *client) pingNode(ctx context.Context, req *pb.ContactPingRequest) (*pb.ContactPingResponse, error) {
return client.client.PingNode(ctx, req)
}
// Close closes the connection
func (client *client) Close() error {
return client.conn.Close()
}