Merge pull request #4827 from filecoin-project/fix/startup-migration-crash

Fix: dont crash on startup if funds migration fails
This commit is contained in:
Łukasz Magiera 2020-11-12 19:17:21 +01:00 committed by GitHub
commit a6d061d0f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -55,16 +55,20 @@ func HandleMigrateClientFunds(lc fx.Lifecycle, ds dtypes.MetadataDS, wallet full
if xerrors.Is(err, datastore.ErrNotFound) {
return nil
}
return err
log.Errorf("client funds migration - getting datastore value: %w", err)
return nil
}
var value abi.TokenAmount
if err = value.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return err
log.Errorf("client funds migration - unmarshalling datastore value: %w", err)
return nil
}
_, err = fundMgr.Reserve(ctx, addr, addr, value)
if err != nil {
return err
log.Errorf("client funds migration - reserving funds (wallet %s, addr %s, funds %d): %w",
addr, addr, value, err)
return nil
}
return ds.Delete(datastore.NewKey("/marketfunds/client"))

View File

@ -263,17 +263,21 @@ func HandleMigrateProviderFunds(lc fx.Lifecycle, ds dtypes.MetadataDS, node api.
}
ts, err := node.ChainHead(ctx)
if err != nil {
return err
log.Errorf("provider funds migration - getting chain head: %w", err)
return nil
}
mi, err := node.StateMinerInfo(ctx, address.Address(minerAddress), ts.Key())
if err != nil {
return err
log.Errorf("provider funds migration - getting miner info %s: %w", minerAddress, err)
return nil
}
_, err = node.MarketReserveFunds(ctx, mi.Worker, address.Address(minerAddress), value)
if err != nil {
return err
log.Errorf("provider funds migration - reserving funds (wallet %s, addr %s, funds %d): %w",
mi.Worker, minerAddress, value, err)
return nil
}
return ds.Delete(datastore.NewKey("/marketfunds/provider"))