Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vms/platformvm/service: nits (preallocate address slice, error msg) #1477

Merged
merged 1 commit into from
May 6, 2023
Merged
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions vms/platformvm/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func (s *Service) GetUTXOs(_ *http.Request, args *api.GetUTXOsArgs, response *ap
}
response.UTXOs[i], err = formatting.Encode(args.Encoding, bytes)
if err != nil {
return fmt.Errorf("couldn't encode UTXO %s as string: %w", utxo.InputID(), err)
return fmt.Errorf("couldn't encode UTXO %s as %s: %w", utxo.InputID(), args.Encoding, err)
}
}

Expand Down Expand Up @@ -2160,7 +2160,7 @@ func (s *Service) GetTx(_ *http.Request, args *api.GetTxArgs, response *api.GetT

response.Tx, err = formatting.Encode(args.Encoding, txBytes)
if err != nil {
return fmt.Errorf("couldn't encode tx as a string: %w", err)
return fmt.Errorf("couldn't encode tx as %s: %w", args.Encoding, err)
}
return nil
}
Expand Down Expand Up @@ -2332,7 +2332,7 @@ func (s *Service) GetStake(_ *http.Request, args *GetStakeArgs, response *GetSta
}
response.Outputs[i], err = formatting.Encode(args.Encoding, bytes)
if err != nil {
return fmt.Errorf("couldn't encode output %s as string: %w", output.ID, err)
return fmt.Errorf("couldn't encode output %s as %s: %w", output.ID, args.Encoding, err)
}
}
response.Encoding = args.Encoding
Expand Down Expand Up @@ -2505,7 +2505,7 @@ func (s *Service) GetRewardUTXOs(_ *http.Request, args *api.GetTxArgs, reply *Ge

utxoStr, err := formatting.Encode(args.Encoding, utxoBytes)
if err != nil {
return fmt.Errorf("couldn't encode utxo as a string: %w", err)
return fmt.Errorf("couldn't encode utxo as %s: %w", args.Encoding, err)
}
reply.UTXOs[i] = utxoStr
}
Expand Down Expand Up @@ -2589,7 +2589,7 @@ func (s *Service) GetBlock(_ *http.Request, args *api.GetBlockArgs, response *ap

response.Block, err = formatting.Encode(args.Encoding, block.Bytes())
if err != nil {
return fmt.Errorf("couldn't encode block %s as string: %w", args.BlockID, err)
return fmt.Errorf("couldn't encode block %s as %s: %w", args.BlockID, args.Encoding, err)
}

return nil
Expand All @@ -2615,6 +2615,7 @@ func (s *Service) getAPIOwner(owner *secp256k1fx.OutputOwners) (*platformapi.Own
apiOwner := &platformapi.Owner{
Locktime: json.Uint64(owner.Locktime),
Threshold: json.Uint32(owner.Threshold),
Addresses: make([]string, 0, len(owner.Addrs)),
}
for _, addr := range owner.Addrs {
addrStr, err := s.addrManager.FormatLocalAddress(addr)
Expand Down