Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup state of a deal #691

Merged
merged 1 commit into from Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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