Skip to content

Commit

Permalink
internal/ethapi: return empty arrays instead of null (ethereum#14374)
Browse files Browse the repository at this point in the history
* internal/ethapi: return empty arrays instead of null

* internal/ethapi: minor comments to avoid future regressions
  • Loading branch information
bas-vk authored and karalabe committed Apr 24, 2017
1 parent 09aabae commit 54253aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func NewPublicAccountAPI(am *accounts.Manager) *PublicAccountAPI {

// Accounts returns the collection of accounts this node manages
func (s *PublicAccountAPI) Accounts() []common.Address {
var addresses []common.Address
addresses := make([]common.Address, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() {
for _, account := range wallet.Accounts() {
addresses = append(addresses, account.Address)
Expand All @@ -218,7 +218,7 @@ func NewPrivateAccountAPI(b Backend) *PrivateAccountAPI {

// ListAccounts will return a list of addresses for accounts this node manages.
func (s *PrivateAccountAPI) ListAccounts() []common.Address {
var addresses []common.Address
addresses := make([]common.Address, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() {
for _, account := range wallet.Accounts() {
addresses = append(addresses, account.Address)
Expand All @@ -237,7 +237,7 @@ type rawWallet struct {

// ListWallets will return a list of wallets this node manages.
func (s *PrivateAccountAPI) ListWallets() []rawWallet {
var wallets []rawWallet
wallets := make([]rawWallet, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() {
wallets = append(wallets, rawWallet{
URL: wallet.URL().String(),
Expand Down

0 comments on commit 54253aa

Please sign in to comment.