Skip to content

Commit

Permalink
Merge pull request #4526 from filecoin-project/wallet-4464
Browse files Browse the repository at this point in the history
Delete wallet from local wallet cache
  • Loading branch information
magik6k authored Oct 22, 2020
2 parents b2510e5 + 7f98be2 commit c17e8e7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chain/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,17 @@ func (w *LocalWallet) WalletHas(ctx context.Context, addr address.Address) (bool

func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) error {
k, err := w.findKey(addr)

if err != nil {
return xerrors.Errorf("failed to delete key %s : %w", addr, err)
}
if k == nil {
return nil // already not there
}

w.lk.Lock()
defer w.lk.Unlock()

if err := w.keystore.Put(KTrashPrefix+k.Address.String(), k.KeyInfo); err != nil {
return xerrors.Errorf("failed to mark key %s as trashed: %w", addr, err)
}
Expand All @@ -295,6 +299,8 @@ func (w *LocalWallet) WalletDelete(ctx context.Context, addr address.Address) er
// TODO: Does this always error in the not-found case? Just ignoring an error return for now.
_ = w.keystore.Delete(KNamePrefix + tAddr)

delete(w.keys, addr)

return nil
}

Expand Down

0 comments on commit c17e8e7

Please sign in to comment.