From 4aa30c1a512fc01a0b42b5573a615223f234c1b9 Mon Sep 17 00:00:00 2001 From: Ingar Shu Date: Thu, 9 Jul 2020 13:02:12 -0700 Subject: [PATCH] Plumb piece cid in miner-specific query functions --- api/api_full.go | 2 +- api/apistruct/struct.go | 30 +++++++++++++++--------------- cli/client.go | 2 +- node/impl/client/client.go | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index 09cd01eff..8ec713b8a 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -205,7 +205,7 @@ type FullNode interface { // ClientFindData identifies peers that have a certain file, and returns QueryOffers (one per peer). ClientFindData(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]QueryOffer, error) // ClientMinerQueryOffer returns a QueryOffer for the specific miner and file. - ClientMinerQueryOffer(ctx context.Context, root cid.Cid, miner address.Address) (QueryOffer, error) + ClientMinerQueryOffer(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (QueryOffer, error) // ClientRetrieve initiates the retrieval of a file, as specified in the order. ClientRetrieve(ctx context.Context, order RetrievalOrder, ref *FileRef) error // ClientQueryAsk returns a signed StorageAsk from the specified miner. diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 9f57b27a4..c0b4d9e6b 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -111,19 +111,19 @@ type FullNodeStruct struct { WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"` WalletDelete func(context.Context, address.Address) error `perm:"write"` - ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"` - ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"` - ClientRemoveImport func(ctx context.Context, importID int64) error `perm:"admin"` - ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"` - ClientFindData func(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]api.QueryOffer, error) `perm:"read"` - ClientMinerQueryOffer func(ctx context.Context, root cid.Cid, miner address.Address) (api.QueryOffer, error) `perm:"read"` - ClientStartDeal func(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) `perm:"admin"` - ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"` - ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"` - ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error `perm:"admin"` - ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) `perm:"read"` - ClientCalcCommP func(ctx context.Context, inpath string, miner address.Address) (*api.CommPRet, error) `perm:"read"` - ClientGenCar func(ctx context.Context, ref api.FileRef, outpath string) error `perm:"write"` + ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"` + ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"` + ClientRemoveImport func(ctx context.Context, importID int64) error `perm:"admin"` + ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"` + ClientFindData func(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]api.QueryOffer, error) `perm:"read"` + ClientMinerQueryOffer func(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (api.QueryOffer, error) `perm:"read"` + ClientStartDeal func(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) `perm:"admin"` + ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"` + ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"` + ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error `perm:"admin"` + ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) `perm:"read"` + ClientCalcCommP func(ctx context.Context, inpath string, miner address.Address) (*api.CommPRet, error) `perm:"read"` + ClientGenCar func(ctx context.Context, ref api.FileRef, outpath string) error `perm:"write"` StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"` StateMinerSectors func(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"` @@ -362,8 +362,8 @@ func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid, piece return c.Internal.ClientFindData(ctx, root, piece) } -func (c *FullNodeStruct) ClientMinerQueryOffer(ctx context.Context, root cid.Cid, miner address.Address) (api.QueryOffer, error) { - return c.Internal.ClientMinerQueryOffer(ctx, root, miner) +func (c *FullNodeStruct) ClientMinerQueryOffer(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (api.QueryOffer, error) { + return c.Internal.ClientMinerQueryOffer(ctx, miner, root, piece) } func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) { diff --git a/cli/client.go b/cli/client.go index 40b017265..8c2ad7eb8 100644 --- a/cli/client.go +++ b/cli/client.go @@ -575,7 +575,7 @@ var clientRetrieveCmd = &cli.Command{ if err != nil { return err } - offer, err = fapi.ClientMinerQueryOffer(ctx, file, minerAddr) + offer, err = fapi.ClientMinerQueryOffer(ctx, minerAddr, file, pieceCid) if err != nil { return err } diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 6abec382a..e7a0ba800 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -228,7 +228,7 @@ func (a *API) ClientFindData(ctx context.Context, root cid.Cid, piece *cid.Cid) return out, nil } -func (a *API) ClientMinerQueryOffer(ctx context.Context, payload cid.Cid, miner address.Address) (api.QueryOffer, error) { +func (a *API) ClientMinerQueryOffer(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (api.QueryOffer, error) { mi, err := a.StateMinerInfo(ctx, miner, types.EmptyTSK) if err != nil { return api.QueryOffer{}, err @@ -237,7 +237,7 @@ func (a *API) ClientMinerQueryOffer(ctx context.Context, payload cid.Cid, miner Address: miner, ID: mi.PeerId, } - return a.makeRetrievalQuery(ctx, rp, payload, nil, rm.QueryParams{}), nil + return a.makeRetrievalQuery(ctx, rp, root, piece, rm.QueryParams{}), nil } func (a *API) makeRetrievalQuery(ctx context.Context, rp rm.RetrievalPeer, payload cid.Cid, piece *cid.Cid, qp rm.QueryParams) api.QueryOffer {