Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wallet): query incremental timeout #1395

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions wallet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"errors"
"time"

"github.com/pactus-project/pactus/crypto/hash"
"github.com/pactus-project/pactus/types/amount"
Expand All @@ -18,17 +19,19 @@ import (
// It is used to get information such as account balance or transaction data from the server.
type grpcClient struct {
ctx context.Context
cancel context.CancelFunc
servers []string
conn *grpc.ClientConn
blockchainClient pactus.BlockchainClient
transactionClient pactus.TransactionClient
}

func newGrpcClient() *grpcClient {
ctx := context.WithoutCancel(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)

return &grpcClient{
ctx: ctx,
cancel: cancel,
conn: nil,
blockchainClient: nil,
transactionClient: nil,
Expand All @@ -46,7 +49,8 @@ func (c *grpcClient) connect() error {

for _, server := range c.servers {
conn, err := grpc.NewClient(server,
grpc.WithTransportCredentials(insecure.NewCredentials()))
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
continue
}
Expand Down
Loading