Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
13 changes: 6 additions & 7 deletions clients/stellarcore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ type GenSorobanConfig struct {
}

func GenSorobanConfigUpgradeTxAndKey(
config GenSorobanConfig, upgradeConfig xdr.ConfigUpgradeSet) ([]xdr.TransactionEnvelope, xdr.ConfigUpgradeSetKey, error) {
config GenSorobanConfig, upgradeConfig xdr.ConfigUpgradeSet,
) ([]xdr.TransactionEnvelope, xdr.ConfigUpgradeSetKey, error) {
upgradeConfigB64, err := xdr.MarshalBase64(upgradeConfig)
if err != nil {
return nil, xdr.ConfigUpgradeSetKey{}, err
Expand All @@ -99,7 +100,7 @@ func GenSorobanConfigUpgradeTxAndKey(
cmd := exec.Command("docker", "pull", config.StellarCoreImage)
_, err = cmd.Output()
if err != nil {
return nil, xdr.ConfigUpgradeSetKey{}, err
return nil, xdr.ConfigUpgradeSetKey{}, fmt.Errorf("docker pull failed (is docker running?): %v", err)
}

cmd = exec.Command("docker",
Expand All @@ -116,7 +117,7 @@ func GenSorobanConfigUpgradeTxAndKey(
cmd.Stdin = strings.NewReader(inputStr)
out, err := cmd.Output()
if err != nil {
return nil, xdr.ConfigUpgradeSetKey{}, err
return nil, xdr.ConfigUpgradeSetKey{}, fmt.Errorf("docker run failed: %v", err)
}
lines := strings.Split(string(out), "\n")
if len(lines) < 9 {
Expand All @@ -129,7 +130,7 @@ func GenSorobanConfigUpgradeTxAndKey(
for i, txB64 := range txsB64 {
err = xdr.SafeUnmarshalBase64(txB64, &txs[i])
if err != nil {
return nil, xdr.ConfigUpgradeSetKey{}, err
return nil, xdr.ConfigUpgradeSetKey{}, fmt.Errorf("failed to unmarshal transaction envelope: %v", err)
}
}
var key xdr.ConfigUpgradeSetKey
Expand Down Expand Up @@ -199,7 +200,7 @@ func (c *Client) Info(ctx context.Context) (resp *proto.InfoResponse, err error)
}
defer drainReponse(hresp, true, &err) //nolint:errcheck

if !(hresp.StatusCode >= 200 && hresp.StatusCode < 300) {
if hresp.StatusCode < 200 || hresp.StatusCode >= 300 {
err = errors.New("http request failed with non-200 status code")
return
}
Expand All @@ -220,7 +221,6 @@ func (c *Client) SetCursor(ctx context.Context, id string, cursor int32) (err er
"id": []string{id},
"cursor": []string{fmt.Sprintf("%d", cursor)},
})

if err != nil {
return errors.Wrap(err, "failed to create request")
}
Expand Down Expand Up @@ -300,7 +300,6 @@ func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp *
func (c *Client) WaitForNetworkSync(ctx context.Context) error {
for {
info, err := c.Info(ctx)

if err != nil {
return errors.Wrap(err, "info request failed")
}
Expand Down
1 change: 0 additions & 1 deletion clients/stellarcore/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ func ExampleClient_Info() {
client := &Client{URL: "http://localhost:11626"}

info, err := client.Info(context.Background())

if err != nil {
panic(err)
}
Expand Down
7 changes: 4 additions & 3 deletions protocols/rpc/get_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const GetNetworkMethodName = "getNetwork"
type GetNetworkRequest struct{}

type GetNetworkResponse struct {
FriendbotURL string `json:"friendbotUrl,omitempty"`
Passphrase string `json:"passphrase"`
ProtocolVersion int `json:"protocolVersion"`
FriendbotURL string `json:"friendbotUrl,omitempty"`
Passphrase string `json:"passphrase"`
ProtocolVersion int `json:"protocolVersion"`
CoreSupportedProtocolVersion int `json:"coreSupportedProtocolVersion"`
}
5 changes: 1 addition & 4 deletions protocols/stellarcore/info_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ type InfoResponse struct {
ProtocolVersion int `json:"protocol_version"`
State string `json:"state"`
Ledger LedgerInfo `json:"ledger"`

// TODO: all the other fields
}
}

Expand All @@ -27,8 +25,7 @@ type LedgerInfo struct {
Version int `json:"version"`
}

// IsSynced returns a boolean indicating whether stellarcore is synced with the
// network.
// bool indicating whether stellarcore is synced with the network.
func (resp *InfoResponse) IsSynced() bool {
return resp.Info.State == "Synced!"
}