Skip to content

Commit

Permalink
Add context to NewDealStatusStream
Browse files Browse the repository at this point in the history
  • Loading branch information
ingar committed Jul 1, 2020
1 parent e5131ce commit f6be2d4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion storagemarket/impl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (c *Client) GetProviderDealState(ctx context.Context, proposalCid cid.Cid)
return nil, xerrors.Errorf("could not get client deal state: %w", err)
}

s, err := c.net.NewDealStatusStream(deal.Miner)
s, err := c.net.NewDealStatusStream(ctx, deal.Miner)
if err != nil {
return nil, xerrors.Errorf("failed to open stream to miner: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions storagemarket/network/libp2p_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (impl *libp2pStorageMarketNetwork) NewDealStream(ctx context.Context, id pe
return &dealStream{p: id, rw: s, buffered: buffered, host: impl.host}, nil
}

func (impl *libp2pStorageMarketNetwork) NewDealStatusStream(id peer.ID) (DealStatusStream, error) {
s, err := impl.host.NewStream(context.Background(), id, storagemarket.DealStatusProtocolID)
func (impl *libp2pStorageMarketNetwork) NewDealStatusStream(ctx context.Context, id peer.ID) (DealStatusStream, error) {
s, err := impl.host.NewStream(ctx, id, storagemarket.DealStatusProtocolID)
if err != nil {
log.Warn(err)
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions storagemarket/network/libp2p_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestDealStatusStreamSendReceiveMultipleSuccessful(t *testing.T) {
ctx, cancel := context.WithTimeout(ctxBg, 10*time.Second)
defer cancel()

qs, err := nw1.NewDealStatusStream(td.Host2.ID())
qs, err := nw1.NewDealStatusStream(ctx, td.Host2.ID())
require.NoError(t, err)

var resp network.DealStatusResponse
Expand Down Expand Up @@ -439,7 +439,7 @@ func assertDealStatusRequestReceived(inCtx context.Context, t *testing.T, fromNe
ctx, cancel := context.WithTimeout(inCtx, 10*time.Second)
defer cancel()

as1, err := fromNetwork.NewDealStatusStream(toHost)
as1, err := fromNetwork.NewDealStatusStream(ctx, toHost)
require.NoError(t, err)

// send query to host2
Expand All @@ -465,7 +465,7 @@ func assertDealStatusResponseReceived(inCtx context.Context, t *testing.T,
defer cancel()

// setup query stream host1 --> host 2
as1, err := fromNetwork.NewDealStatusStream(toHost)
as1, err := fromNetwork.NewDealStatusStream(ctx, toHost)
require.NoError(t, err)

// send queryresponse to host2
Expand Down
2 changes: 1 addition & 1 deletion storagemarket/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type StorageReceiver interface {
type StorageMarketNetwork interface {
NewAskStream(context.Context, peer.ID) (StorageAskStream, error)
NewDealStream(context.Context, peer.ID) (StorageDealStream, error)
NewDealStatusStream(peer.ID) (DealStatusStream, error)
NewDealStatusStream(context.Context, peer.ID) (DealStatusStream, error)
SetDelegate(StorageReceiver) error
StopHandlingRequests() error
ID() peer.ID
Expand Down

0 comments on commit f6be2d4

Please sign in to comment.