Fundmanager shouldn't try to add zero

This commit is contained in:
Aayush Rajasekaran 2020-07-29 20:27:22 -04:00
parent 7b567c77e9
commit 74dd01a8db

View File

@ -2,6 +2,7 @@ package market
import (
"context"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"sync"
"github.com/filecoin-project/specs-actors/actors/builtin"
@ -52,13 +53,16 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr, wallet address.Add
if avail.LessThan(types.NewInt(0)) {
// TODO: some rules around adding more to avoid doing stuff on-chain
// all the time
toAdd = types.BigSub(toAdd, avail)
toAdd = avail.Neg()
avail = types.NewInt(0)
}
fm.available[addr] = avail
fm.lk.Unlock()
if toAdd.LessThanEqual(big.Zero()) {
return cid.Undef, nil
} else {
var err error
params, err := actors.SerializeParams(&addr)
if err != nil {
@ -78,3 +82,4 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr, wallet address.Add
return smsg.Cid(), nil
}
}