Skip to content

Commit

Permalink
add grpcConnection to type Node and close it in Stop method (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
huichiaotsou authored Feb 23, 2022
1 parent 9ef5472 commit e4ed06a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions node/remote/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc"

constypes "github.com/tendermint/tendermint/consensus/types"
tmjson "github.com/tendermint/tendermint/libs/json"
Expand All @@ -34,6 +35,7 @@ type Node struct {
codec codec.Marshaler
client *httpclient.HTTP
txServiceClient tx.ServiceClient
grpcConnection *grpc.ClientConn
}

// NewNode allows to build a new Node instance
Expand Down Expand Up @@ -71,6 +73,7 @@ func NewNode(cfg *Details, codec codec.Marshaler) (*Node, error) {

client: rpcClient,
txServiceClient: tx.NewServiceClient(grpcConnection),
grpcConnection: grpcConnection,
}, nil
}

Expand Down Expand Up @@ -201,4 +204,9 @@ func (cp *Node) Stop() {
if err != nil {
panic(fmt.Errorf("error while stopping proxy: %s", err))
}

err = cp.grpcConnection.Close()
if err != nil {
panic(fmt.Errorf("error while closing gRPC connection: %s", err))
}
}

0 comments on commit e4ed06a

Please sign in to comment.