From 94b599ac6bd2f59ba08f7dfbc48d34d5d1fb76dc Mon Sep 17 00:00:00 2001 From: 0xEclair <38656355+0xEclair@users.noreply.github.com> Date: Wed, 17 Jul 2024 05:05:15 +0800 Subject: [PATCH] add new block client --- rpc/grpc/client_server.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rpc/grpc/client_server.go b/rpc/grpc/client_server.go index 3f9eef52f8..5101b0cbb2 100644 --- a/rpc/grpc/client_server.go +++ b/rpc/grpc/client_server.go @@ -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) {