aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorbas-vk <bas-vk@users.noreply.github.com>2017-04-24 20:00:30 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-04-24 20:00:30 +0800
commit54253aae4cbb224d32386455673e19e240b95d3d (patch)
treebda7c18e0e26f1d01cd4a5ffaab38d4a4b34a6a5 /internal
parent09aabaea9fa53deee771388917180066d35e532d (diff)
downloadgo-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.tar
go-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.tar.gz
go-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.tar.bz2
go-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.tar.lz
go-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.tar.xz
go-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.tar.zst
go-tangerine-54253aae4cbb224d32386455673e19e240b95d3d.zip
internal/ethapi: return empty arrays instead of null (#14374)
* internal/ethapi: return empty arrays instead of null * internal/ethapi: minor comments to avoid future regressions
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 987e14419..f0bc3aa4b 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -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)
@@ -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)
@@ -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(),