Skip to content

Commit

Permalink
api to fetch a deal state (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Mar 8, 2022
1 parent b328bea commit 2957701
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions storagemarket/impl/provider.go
Expand Up @@ -463,6 +463,12 @@ func (p *Provider) ListLocalDeals() ([]storagemarket.MinerDeal, error) {
return out, nil
}

func (p *Provider) GetLocalDeal(propCid cid.Cid) (storagemarket.MinerDeal, error) {
var d storagemarket.MinerDeal
err := p.deals.Get(propCid).Get(&d)
return d, err
}

// SetAsk configures the storage miner's ask with the provided price,
// duration, and options. Any previously-existing ask is replaced.
func (p *Provider) SetAsk(price abi.TokenAmount, verifiedPrice abi.TokenAmount, duration abi.ChainEpoch, options ...storagemarket.StorageAskOption) error {
Expand Down
4 changes: 4 additions & 0 deletions storagemarket/integration_test.go
Expand Up @@ -166,6 +166,10 @@ func TestMakeDeal(t *testing.T) {
assert.True(t, pd.FastRetrieval)
shared_testutil.AssertDealState(t, storagemarket.StorageDealExpired, pd.State)

dl, err := h.Provider.GetLocalDeal(pd.ProposalCid)
require.NoError(t, err)
assert.True(t, dl.FastRetrieval)

// test out query protocol
status, err := h.Client.GetProviderDealState(ctx, proposalCid)
assert.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions storagemarket/provider.go
Expand Up @@ -39,6 +39,8 @@ type StorageProvider interface {
// ListLocalDeals lists deals processed by this storage provider
ListLocalDeals() ([]MinerDeal, error)

GetLocalDeal(propCid cid.Cid) (MinerDeal, error)

// AddStorageCollateral adds storage collateral
AddStorageCollateral(ctx context.Context, amount abi.TokenAmount) error

Expand Down

0 comments on commit 2957701

Please sign in to comment.