mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-06 21:36:26 +00:00
* build(deps): Bump google.golang.org/grpc from 1.42.0 to 1.43.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.42.0 to 1.43.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.42.0...v1.43.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package coregrpc
|
|
|
|
import (
|
|
"net"
|
|
|
|
"golang.org/x/net/context"
|
|
"google.golang.org/grpc"
|
|
|
|
tmnet "github.com/tendermint/tendermint/libs/net"
|
|
)
|
|
|
|
// Config is an gRPC server configuration.
|
|
type Config struct {
|
|
MaxOpenConnections int
|
|
}
|
|
|
|
// StartGRPCServer starts a new gRPC BroadcastAPIServer using the given
|
|
// net.Listener.
|
|
// NOTE: This function blocks - you may want to call it in a go-routine.
|
|
func StartGRPCServer(ln net.Listener) error {
|
|
grpcServer := grpc.NewServer()
|
|
RegisterBroadcastAPIServer(grpcServer, &broadcastAPI{})
|
|
return grpcServer.Serve(ln)
|
|
}
|
|
|
|
// StartGRPCClient dials the gRPC server using protoAddr and returns a new
|
|
// BroadcastAPIClient.
|
|
func StartGRPCClient(protoAddr string) BroadcastAPIClient {
|
|
//nolint:staticcheck // SA1019 Existing use of deprecated but supported dial option.
|
|
conn, err := grpc.Dial(protoAddr, grpc.WithInsecure(), grpc.WithContextDialer(dialerFunc))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return NewBroadcastAPIClient(conn)
|
|
}
|
|
|
|
func dialerFunc(ctx context.Context, addr string) (net.Conn, error) {
|
|
return tmnet.Connect(addr)
|
|
}
|