Cleanup GetBalance call and warn if actor does not exist

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2019-10-22 21:58:51 +02:00
parent 007edf7830
commit 7532f92c98
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
2 changed files with 6 additions and 2 deletions

View File

@ -217,7 +217,7 @@ func (sm *StateManager) GetActor(addr address.Address, ts *types.TipSet) (*types
func (sm *StateManager) GetBalance(addr address.Address, ts *types.TipSet) (types.BigInt, error) {
act, err := sm.GetActor(addr, ts)
if err != nil {
return types.BigInt{}, xerrors.Errorf("get actor: %w", err)
return types.NewInt(0), xerrors.Errorf("get actor: %w", err)
}
return act.Balance, nil

View File

@ -3,6 +3,7 @@ package cli
import (
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
@ -101,7 +102,10 @@ var walletBalance = &cli.Command{
}
balance, err := api.WalletBalance(ctx, addr)
if err != nil {
if errors.Is(err, types.ErrActorNotFound) {
log.Warnf("actor not found with address: %s", addr)
} else if err != nil {
return err
}