ax(node): remove banned fmt import from lethean.go
Replace fmt.Sprintf endpoint construction with string concatenation and return errors directly, eliminating the banned fmt import. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
4bca7bcced
commit
96a450eff5
1 changed files with 4 additions and 5 deletions
|
|
@ -6,7 +6,6 @@ package node
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
|
@ -44,7 +43,7 @@ func GetChainInfo(daemonURL string) (*ChainInfo, error) {
|
|||
body := `{"jsonrpc":"2.0","id":"0","method":"getinfo","params":{}}`
|
||||
response, err := http.Post(daemonURL+"/json_rpc", "application/json", bytes.NewReader([]byte(body)))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("daemon RPC failed: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
defer response.Body.Close()
|
||||
responseBody, _ := io.ReadAll(response.Body)
|
||||
|
|
@ -53,7 +52,7 @@ func GetChainInfo(daemonURL string) (*ChainInfo, error) {
|
|||
Result ChainInfo `json:"result"`
|
||||
}
|
||||
if err := json.Unmarshal(responseBody, &result); err != nil {
|
||||
return nil, fmt.Errorf("parse getinfo: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
result.Result.Synced = result.Result.Height > 0
|
||||
return &result.Result, nil
|
||||
|
|
@ -91,7 +90,7 @@ func DiscoverPools(daemonURL string) []PoolGateway {
|
|||
Name: alias.Alias,
|
||||
Address: alias.Address,
|
||||
Capabilities: parsed["cap"],
|
||||
Endpoint: fmt.Sprintf("stratum+tcp://%s.lthn:5555", alias.Alias),
|
||||
Endpoint: "stratum+tcp://" + alias.Alias + ".lthn:5555",
|
||||
})
|
||||
}
|
||||
return pools
|
||||
|
|
@ -129,7 +128,7 @@ func DiscoverGateways(daemonURL string) []PoolGateway {
|
|||
Name: alias.Alias,
|
||||
Address: alias.Address,
|
||||
Capabilities: parsed["cap"],
|
||||
Endpoint: fmt.Sprintf("%s.lthn", alias.Alias),
|
||||
Endpoint: alias.Alias + ".lthn",
|
||||
})
|
||||
}
|
||||
return gateways
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue