Skip to content

Commit

Permalink
Remove unneeded wait group
Browse files Browse the repository at this point in the history
NewRpcClient waits fot the auth token initialization before returning
  • Loading branch information
kerzhner committed Sep 1, 2023
1 parent 81908fc commit e4bf71c
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ type rpcClient struct {
nodeAddress common.Address
logger *slog.Logger
authToken string
authTokenReady *sync.WaitGroup
}

// response includes a payload or an error.
Expand All @@ -111,7 +110,6 @@ func NewRpcClient(trans transport.Requester) (RpcClientApi, error) {
cancel: cancel,
routineTracker: &sync.WaitGroup{},
nodeAddress: common.Address{},
authTokenReady: &sync.WaitGroup{},
logger: slog.Default(),
}

Expand All @@ -132,9 +130,7 @@ func NewRpcClient(trans transport.Requester) (RpcClientApi, error) {
c.routineTracker.Add(1)
go c.subscribeToNotifications(ctx, notificationChan)

c.authTokenReady.Add(1)
c.authToken, err = c.AuthToken()
c.authTokenReady.Done()
return c, err
}

Expand Down Expand Up @@ -321,7 +317,6 @@ func WaitForRequestNoAuth[T serde.RequestPayload, U serde.ResponsePayload](rc *r

// waitForAuthorizedRequest calls waitForRequest with the client auth token
func waitForAuthorizedRequest[T serde.RequestPayload, U serde.ResponsePayload](rc *rpcClient, method serde.RequestMethod, requestData T) (U, error) {
rc.authTokenReady.Wait()
return waitForRequest[T, U](rc, method, requestData, rc.authToken)
}

Expand Down

0 comments on commit e4bf71c

Please sign in to comment.