Skip to content

Commit

Permalink
add new block client
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoous committed Jul 16, 2024
1 parent 7a42ed2 commit 94b599a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions rpc/grpc/client_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,28 @@ func StartGRPCServer(ln net.Listener) error {
return grpcServer.Serve(ln)
}

type Client interface {
BroadcastAPIClient
BlockAPIClient
}

type client struct {
BroadcastAPIClient
BlockAPIClient
}

// StartGRPCClient dials the gRPC server using protoAddr and returns a new
// BroadcastAPIClient.
func StartGRPCClient(protoAddr string) BroadcastAPIClient {
func StartGRPCClient(protoAddr string) Client {
conn, err := grpc.Dial(protoAddr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(dialerFunc))
if err != nil {
panic(err)
}
return NewBroadcastAPIClient(conn)

return &client{
BroadcastAPIClient: NewBroadcastAPIClient(conn),
BlockAPIClient: NewBlockAPIClient(conn),
}
}

func dialerFunc(ctx context.Context, addr string) (net.Conn, error) {
Expand Down

0 comments on commit 94b599a

Please sign in to comment.