mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-30 02:36:42 +00:00
Update client.go
This commit is contained in:
parent
ce05a503f8
commit
fc4c2d4c19
@ -2,17 +2,17 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/server"
|
"github.com/fabbez/topiad/cmd/topiawallet/daemon/server"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/kaspanet/kaspad/cmd/kaspawallet/daemon/pb"
|
"github.com/fabbez/topiad/cmd/topiawallet/daemon/pb"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Connect connects to the kaspawalletd server, and returns the client instance
|
// Connect connects to the topiawalletd server, and returns the client instance
|
||||||
func Connect(address string) (pb.KaspawalletdClient, func(), error) {
|
func Connect(address string) (pb.topiawalletdClient, func(), error) {
|
||||||
// Connection is local, so 1 second timeout is sufficient
|
// Connection is local, so 1 second timeout is sufficient
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -20,12 +20,12 @@ func Connect(address string) (pb.KaspawalletdClient, func(), error) {
|
|||||||
conn, err := grpc.DialContext(ctx, address, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(server.MaxDaemonSendMsgSize)))
|
conn, err := grpc.DialContext(ctx, address, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(server.MaxDaemonSendMsgSize)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, context.DeadlineExceeded) {
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
return nil, nil, errors.New("kaspawallet daemon is not running, start it with `kaspawallet start-daemon`")
|
return nil, nil, errors.New("topiawallet daemon is not running, start it with `topiawallet start-daemon`")
|
||||||
}
|
}
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return pb.NewKaspawalletdClient(conn), func() {
|
return pb.NewtopiawalletdClient(conn), func() {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user