-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(requestvalidation): use getsync in validation
fix a race condition where deal status in request validation could fall behind actual events dispatched
- Loading branch information
1 parent
1e15fa9
commit b60fb2d
Showing
9 changed files
with
275 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package storageimpl | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
datatransfer "github.com/filecoin-project/go-data-transfer" | ||
"github.com/filecoin-project/go-fil-markets/storagemarket" | ||
"github.com/filecoin-project/go-fil-markets/storagemarket/impl/funds" | ||
"github.com/filecoin-project/go-fil-markets/storagemarket/network" | ||
"github.com/filecoin-project/go-multistore" | ||
"github.com/ipfs/go-cid" | ||
"github.com/ipld/go-ipld-prime" | ||
"github.com/libp2p/go-libp2p-core/peer" | ||
) | ||
|
||
// ------- | ||
// clientDealEnvironment | ||
// ------- | ||
|
||
type clientDealEnvironment struct { | ||
c *Client | ||
} | ||
|
||
func (c *clientDealEnvironment) NewDealStream(ctx context.Context, p peer.ID) (network.StorageDealStream, error) { | ||
return c.c.net.NewDealStream(ctx, p) | ||
} | ||
|
||
func (c *clientDealEnvironment) Node() storagemarket.StorageClientNode { | ||
return c.c.node | ||
} | ||
|
||
func (c *clientDealEnvironment) StartDataTransfer(ctx context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) error { | ||
_, err := c.c.dataTransfer.OpenPushDataChannel(ctx, to, voucher, baseCid, selector) | ||
return err | ||
} | ||
|
||
func (c *clientDealEnvironment) GetProviderDealState(ctx context.Context, proposalCid cid.Cid) (*storagemarket.ProviderDealState, error) { | ||
return c.c.GetProviderDealState(ctx, proposalCid) | ||
} | ||
|
||
func (c *clientDealEnvironment) PollingInterval() time.Duration { | ||
return c.c.pollingInterval | ||
} | ||
|
||
func (c *clientDealEnvironment) DealFunds() funds.DealFunds { | ||
return c.c.dealFunds | ||
} | ||
|
||
type clientStoreGetter struct { | ||
c *Client | ||
} | ||
|
||
func (csg *clientStoreGetter) Get(proposalCid cid.Cid) (*multistore.Store, error) { | ||
var deal storagemarket.ClientDeal | ||
err := csg.c.statemachines.Get(proposalCid).Get(&deal) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if deal.StoreID == nil { | ||
return nil, nil | ||
} | ||
return csg.c.multiStore.Get(*deal.StoreID) | ||
} | ||
|
||
func (c *clientDealEnvironment) TagPeer(peer peer.ID, tag string) { | ||
c.c.net.TagPeer(peer, tag) | ||
} | ||
|
||
func (c *clientDealEnvironment) UntagPeer(peer peer.ID, tag string) { | ||
c.c.net.UntagPeer(peer, tag) | ||
} | ||
|
||
type clientPullDeals struct { | ||
c *Client | ||
} | ||
|
||
func (cpd *clientPullDeals) Get(proposalCid cid.Cid) (storagemarket.ClientDeal, error) { | ||
var deal storagemarket.ClientDeal | ||
err := cpd.c.statemachines.GetSync(context.TODO(), proposalCid, &deal) | ||
return deal, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.