fix UpdateStorage to write back state

This commit is contained in:
whyrusleeping 2019-08-16 13:24:37 -07:00
parent b2d425b891
commit d9eaca5527
2 changed files with 15 additions and 1 deletions

View File

@ -116,7 +116,8 @@ type UpdateStorageParams struct {
func (sma StorageMarketActor) UpdateStorage(act *types.Actor, vmctx types.VMContext, params *UpdateStorageParams) ([]byte, ActorError) {
var self StorageMarketState
if err := vmctx.Storage().Get(vmctx.Storage().GetHead(), &self); err != nil {
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
@ -126,6 +127,16 @@ func (sma StorageMarketActor) UpdateStorage(act *types.Actor, vmctx types.VMCont
}
self.TotalStorage = types.BigAdd(self.TotalStorage, params.Delta)
nroot, err := vmctx.Storage().Put(self)
if err != nil {
return nil, err
}
if err := vmctx.Storage().Commit(old, nroot); err != nil {
return nil, err
}
return nil, nil
}

View File

@ -187,6 +187,9 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
params = mustEnc(actors.UpdateStorageParams{Delta: types.NewInt(5000)})
_, err = doExec(ctx, vm, actors.StorageMarketAddress, maddr, actors.SMAMethods.UpdateStorage, params)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to update total storage: %w", err)
}
// UGLY HACKY MODIFICATION OF MINER POWER