Skip to content

Commit

Permalink
Fix style nits in vm clients (#1449)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored May 3, 2023
1 parent 0d8c59e commit 99f35bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
9 changes: 1 addition & 8 deletions vms/avm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func (c *client) GetBlock(ctx context.Context, blkID ids.ID, options ...rpc.Opti
if err != nil {
return nil, err
}

return formatting.Decode(res.Encoding, res.Block)
}

Expand All @@ -256,7 +255,6 @@ func (c *client) GetBlockByHeight(ctx context.Context, height uint64, options ..
if err != nil {
return nil, err
}

return formatting.Decode(res.Encoding, res.Block)
}

Expand Down Expand Up @@ -316,12 +314,7 @@ func (c *client) GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option)
if err != nil {
return nil, err
}

txBytes, err := formatting.Decode(res.Encoding, res.Tx)
if err != nil {
return nil, err
}
return txBytes, nil
return formatting.Decode(res.Encoding, res.Tx)
}

func (c *client) GetUTXOs(
Expand Down
17 changes: 8 additions & 9 deletions vms/platformvm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ func (c *client) GetTx(ctx context.Context, txID ids.ID, options ...rpc.Option)
}

func (c *client) GetTxStatus(ctx context.Context, txID ids.ID, options ...rpc.Option) (*GetTxStatusResponse, error) {
res := new(GetTxStatusResponse)
res := &GetTxStatusResponse{}
err := c.requester.SendRequest(
ctx,
"platform.getTxStatus",
Expand Down Expand Up @@ -763,7 +763,7 @@ func (c *client) GetStake(
validatorsOnly bool,
options ...rpc.Option,
) (map[ids.ID]uint64, [][]byte, error) {
res := new(GetStakeReply)
res := &GetStakeReply{}
err := c.requester.SendRequest(ctx, "platform.getStake", &GetStakeArgs{
JSONAddresses: api.JSONAddresses{
Addresses: ids.ShortIDsToStrings(addrs),
Expand Down Expand Up @@ -792,15 +792,15 @@ func (c *client) GetStake(
}

func (c *client) GetMinStake(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, uint64, error) {
res := new(GetMinStakeReply)
res := &GetMinStakeReply{}
err := c.requester.SendRequest(ctx, "platform.getMinStake", &GetMinStakeArgs{
SubnetID: subnetID,
}, res, options...)
return uint64(res.MinValidatorStake), uint64(res.MinDelegatorStake), err
}

func (c *client) GetTotalStake(ctx context.Context, subnetID ids.ID, options ...rpc.Option) (uint64, error) {
res := new(GetTotalStakeReply)
res := &GetTotalStakeReply{}
err := c.requester.SendRequest(ctx, "platform.getTotalStake", &GetTotalStakeArgs{
SubnetID: subnetID,
}, res, options...)
Expand All @@ -814,7 +814,7 @@ func (c *client) GetTotalStake(ctx context.Context, subnetID ids.ID, options ...
}

func (c *client) GetMaxStakeAmount(ctx context.Context, subnetID ids.ID, nodeID ids.NodeID, startTime, endTime uint64, options ...rpc.Option) (uint64, error) {
res := new(GetMaxStakeAmountReply)
res := &GetMaxStakeAmountReply{}
err := c.requester.SendRequest(ctx, "platform.getMaxStakeAmount", &GetMaxStakeAmountArgs{
SubnetID: subnetID,
NodeID: nodeID,
Expand Down Expand Up @@ -857,13 +857,12 @@ func (c *client) GetValidatorsAt(ctx context.Context, subnetID ids.ID, height ui
}

func (c *client) GetBlock(ctx context.Context, blockID ids.ID, options ...rpc.Option) ([]byte, error) {
response := &api.FormattedBlock{}
res := &api.FormattedBlock{}
if err := c.requester.SendRequest(ctx, "platform.getBlock", &api.GetBlockArgs{
BlockID: blockID,
Encoding: formatting.Hex,
}, response, options...); err != nil {
}, res, options...); err != nil {
return nil, err
}

return formatting.Decode(response.Encoding, response.Block)
return formatting.Decode(res.Encoding, res.Block)
}

0 comments on commit 99f35bd

Please sign in to comment.