multiwallet: Don't fail if key is found in any wallet

This commit is contained in:
Łukasz Magiera 2021-06-25 12:17:53 +02:00
parent 3f3336340f
commit c10d99e3fd

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"go.uber.org/fx" "go.uber.org/fx"
"go.uber.org/multierr"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
@ -56,18 +57,18 @@ func nonNil(wallets ...getif) []api.Wallet {
func (m MultiWallet) find(ctx context.Context, address address.Address, wallets ...getif) (api.Wallet, error) { func (m MultiWallet) find(ctx context.Context, address address.Address, wallets ...getif) (api.Wallet, error) {
ws := nonNil(wallets...) ws := nonNil(wallets...)
var merr error
for _, w := range ws { for _, w := range ws {
have, err := w.WalletHas(ctx, address) have, err := w.WalletHas(ctx, address)
if err != nil { merr = multierr.Append(merr, err)
return nil, err
}
if have { if err == nil && have {
return w, nil return w, nil
} }
} }
return nil, nil return nil, merr
} }
func (m MultiWallet) WalletNew(ctx context.Context, keyType types.KeyType) (address.Address, error) { func (m MultiWallet) WalletNew(ctx context.Context, keyType types.KeyType) (address.Address, error) {