Skip to content

Commit

Permalink
PublishDeal: do not return an error when lacking funds
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Oct 7, 2021
1 parent 36ed4dd commit eebce51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storagemarket/impl/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ func (p *Provider) GetStorageCollateral(ctx context.Context) (storagemarket.Bala
return p.spn.GetBalance(ctx, p.actor, tok)
}

func (p *Provider) RetryDealPublishing(propcid cid.Cid) error {
return p.deals.Send(propcid, storagemarket.ProviderEventRestart)
}

// ListLocalDeals lists deals processed by this storage provider
func (p *Provider) ListLocalDeals() ([]storagemarket.MinerDeal, error) {
var out []storagemarket.MinerDeal
Expand Down
6 changes: 6 additions & 0 deletions storagemarket/impl/providerstates/provider_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"strings"

"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
Expand Down Expand Up @@ -284,6 +285,11 @@ func PublishDeal(ctx fsm.Context, environment ProviderDealEnvironment, deal stor

mcid, err := environment.Node().PublishDeals(ctx.Context(), smDeal)
if err != nil {
if strings.Contains(err.Error(), "not enough funds") {
log.Warnf("publishing deal failed due to lack of funds: %s", err)

return nil
}
return ctx.Trigger(storagemarket.ProviderEventNodeErrored, xerrors.Errorf("publishing deal: %w", err))
}

Expand Down
2 changes: 2 additions & 0 deletions storagemarket/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ type StorageProvider interface {

// SubscribeToEvents listens for events that happen related to storage deals on a provider
SubscribeToEvents(subscriber ProviderSubscriber) shared.Unsubscribe

RetryDealPublishing(propCid cid.Cid) error
}

0 comments on commit eebce51

Please sign in to comment.