Skip to content

Commit 69bca0a

Browse files
committed
fix typos in client
1 parent 179e12d commit 69bca0a

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

node-registrar/client/account.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/vedhavyas/go-subkey/v2"
1414
)
1515

16-
var ErrorAccountNotFround = fmt.Errorf("failed to get requested account from node regiatrar")
16+
var ErrorAccountNotFound = fmt.Errorf("failed to get requested account from node registrar")
1717

1818
func (c *RegistrarClient) CreateAccount(relays []string, rmbEncKey string) (account Account, mnemonic string, err error) {
1919
return c.createAccount(relays, rmbEncKey)
@@ -141,7 +141,7 @@ func (c *RegistrarClient) getAccount(id uint64) (account Account, err error) {
141141
}
142142

143143
if resp.StatusCode == http.StatusNotFound {
144-
return account, ErrorAccountNotFround
144+
return account, ErrorAccountNotFound
145145
}
146146

147147
if resp.StatusCode != http.StatusOK {
@@ -182,7 +182,7 @@ func (c *RegistrarClient) getAccountByPK(pk []byte) (account Account, err error)
182182
defer resp.Body.Close()
183183

184184
if resp.StatusCode == http.StatusNotFound {
185-
return account, ErrorAccountNotFround
185+
return account, ErrorAccountNotFound
186186
}
187187

188188
if resp.StatusCode != http.StatusOK {
@@ -244,7 +244,7 @@ func (c *RegistrarClient) updateAccount(opts []UpdateAccountOpts) (err error) {
244244

245245
func (c *RegistrarClient) ensureAccount(relays []string, rmbEncKey string) (account Account, err error) {
246246
account, err = c.GetAccountByPK(c.keyPair.Public())
247-
if errors.Is(err, ErrorAccountNotFround) {
247+
if errors.Is(err, ErrorAccountNotFound) {
248248
account, _, err = c.CreateAccount(relays, rmbEncKey)
249249
}
250250
return account, err

node-registrar/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ func NewRegistrarClient(baseURL string, mnemonicOrSeed ...string) (cli Registrar
3737
cli.mnemonic = mnemonicOrSeed[0]
3838

3939
account, err := cli.GetAccountByPK(keyPair.Public())
40-
if errors.Is(err, ErrorAccountNotFround) {
40+
if errors.Is(err, ErrorAccountNotFound) {
4141
return cli, nil
4242
} else if err != nil {
4343
return cli, errors.Wrap(err, "failed to get account with public key")
4444
}
4545

4646
cli.twinID = account.TwinID
4747
node, err := cli.GetNodeByTwinID(account.TwinID)
48-
if errors.Is(err, ErrorNodeNotFround) {
48+
if errors.Is(err, ErrorNodeNotFound) {
4949
return cli, nil
5050
} else if err != nil {
5151
return cli, errors.Wrapf(err, "failed to get node with twin id %d", account.TwinID)

node-registrar/client/farm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/pkg/errors"
1414
)
1515

16-
var ErrorFarmNotFround = fmt.Errorf("failed to get requested farm from node regiatrar")
16+
var ErrorFarmNotFound = fmt.Errorf("failed to get requested farm from node registrar")
1717

1818
func (c *RegistrarClient) CreateFarm(farmName, stellarAddr string, dedicated bool) (farmID uint64, err error) {
1919
return c.createFarm(farmName, stellarAddr, dedicated)
@@ -216,7 +216,7 @@ func (c *RegistrarClient) getFarm(id uint64) (farm Farm, err error) {
216216
}
217217

218218
if resp.StatusCode == http.StatusNotFound {
219-
return farm, ErrorFarmNotFround
219+
return farm, ErrorFarmNotFound
220220
}
221221

222222
if resp.StatusCode != http.StatusOK {

node-registrar/client/node.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/pkg/errors"
1313
)
1414

15-
var ErrorNodeNotFround = fmt.Errorf("failed to get requested node from node regiatrar")
15+
var ErrorNodeNotFound = fmt.Errorf("failed to get requested node from node registrar")
1616

1717
func (c *RegistrarClient) RegisterNode(
1818
farmID uint64,
@@ -219,11 +219,15 @@ func (c *RegistrarClient) registerNode(
219219
return nodeID, errors.Wrap(err, "failed to send request to registrer the node")
220220
}
221221

222-
if resp == nil || resp.StatusCode != http.StatusCreated {
222+
if resp == nil {
223+
return 0, errors.New("no response received")
224+
}
225+
defer resp.Body.Close()
226+
227+
if resp.StatusCode != http.StatusCreated {
223228
err = parseResponseError(resp.Body)
224229
return 0, errors.Wrapf(err, "failed to create node on the registrar with status code %s", resp.Status)
225230
}
226-
defer resp.Body.Close()
227231

228232
result := struct {
229233
NodeID uint64 `json:"node_id"`
@@ -341,7 +345,7 @@ func (c *RegistrarClient) getNode(id uint64) (node Node, err error) {
341345
}
342346

343347
if resp.StatusCode == http.StatusNotFound {
344-
return node, ErrorNodeNotFround
348+
return node, ErrorNodeNotFound
345349
}
346350

347351
if resp.StatusCode != http.StatusOK {
@@ -365,7 +369,7 @@ func (c *RegistrarClient) getNodeByTwinID(id uint64) (node Node, err error) {
365369
}
366370

367371
if len(nodes) == 0 {
368-
return node, ErrorNodeNotFround
372+
return node, ErrorNodeNotFound
369373
}
370374

371375
return nodes[0], nil
@@ -401,7 +405,7 @@ func (c *RegistrarClient) listNodes(opts []ListNodeOpts) (nodes []Node, err erro
401405
}
402406

403407
if resp.StatusCode == http.StatusNotFound {
404-
return nodes, ErrorNodeNotFround
408+
return nodes, ErrorNodeNotFound
405409
}
406410

407411
if resp.StatusCode != http.StatusOK {

0 commit comments

Comments
 (0)