client: make wallet addr be a param in ClientStartDeal
Signed-off-by: jsign <jsign.uy@gmail.com>
This commit is contained in:
parent
71011d03fe
commit
40289848c6
@ -73,7 +73,7 @@ type FullNode interface {
|
|||||||
|
|
||||||
// ClientImport imports file under the specified path into filestore
|
// ClientImport imports file under the specified path into filestore
|
||||||
ClientImport(ctx context.Context, path string) (cid.Cid, error)
|
ClientImport(ctx context.Context, path string) (cid.Cid, error)
|
||||||
ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error)
|
ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error)
|
||||||
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error)
|
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error)
|
||||||
ClientListDeals(ctx context.Context) ([]DealInfo, error)
|
ClientListDeals(ctx context.Context) ([]DealInfo, error)
|
||||||
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
|
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
|
||||||
|
@ -81,7 +81,7 @@ type FullNodeStruct struct {
|
|||||||
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
||||||
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
|
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
|
||||||
ClientFindData func(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
|
ClientFindData func(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
|
||||||
ClientStartDeal func(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) `perm:"admin"`
|
ClientStartDeal func(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) `perm:"admin"`
|
||||||
ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"`
|
ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"`
|
||||||
ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"`
|
ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"`
|
||||||
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, path string) error `perm:"admin"`
|
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, path string) error `perm:"admin"`
|
||||||
@ -208,8 +208,8 @@ func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid) ([]ap
|
|||||||
return c.Internal.ClientFindData(ctx, root)
|
return c.Internal.ClientFindData(ctx, root)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
|
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
|
||||||
return c.Internal.ClientStartDeal(ctx, data, miner, price, blocksDuration)
|
return c.Internal.ClientStartDeal(ctx, data, addr, miner, price, blocksDuration)
|
||||||
}
|
}
|
||||||
func (c *FullNodeStruct) ClientGetDealInfo(ctx context.Context, deal cid.Cid) (*api.DealInfo, error) {
|
func (c *FullNodeStruct) ClientGetDealInfo(ctx context.Context, deal cid.Cid) (*api.DealInfo, error) {
|
||||||
return c.Internal.ClientGetDealInfo(ctx, deal)
|
return c.Internal.ClientGetDealInfo(ctx, deal)
|
||||||
|
@ -71,7 +71,11 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
deal, err := client.ClientStartDeal(ctx, fcid, maddr, types.NewInt(40000000), 100)
|
addr, err := client.WalletDefaultAddress(ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
deal, err := client.ClientStartDeal(ctx, fcid, addr, maddr, types.NewInt(40000000), 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,11 @@ var clientDealCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
proposal, err := api.ClientStartDeal(ctx, data, miner, types.BigInt(price), uint64(dur))
|
a, err := api.WalletDefaultAddress(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
proposal, err := api.ClientStartDeal(ctx, data, a, miner, types.BigInt(price), uint64(dur))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,13 @@ type API struct {
|
|||||||
Filestore dtypes.ClientFilestore `optional:"true"`
|
Filestore dtypes.ClientFilestore `optional:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
|
func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
|
||||||
// TODO: make this a param
|
exist, err := a.WalletHas(ctx, addr)
|
||||||
self, err := a.WalletDefaultAddress(ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to get default address: %w", err)
|
return nil, xerrors.Errorf("failed getting addr from wallet: %w", addr)
|
||||||
|
}
|
||||||
|
if !exist {
|
||||||
|
return nil, xerrors.Errorf("provided address doesn't exist in wallet")
|
||||||
}
|
}
|
||||||
|
|
||||||
pid, err := a.StateMinerPeerID(ctx, miner, nil)
|
pid, err := a.StateMinerPeerID(ctx, miner, nil)
|
||||||
@ -75,7 +77,7 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.A
|
|||||||
PricePerEpoch: epochPrice,
|
PricePerEpoch: epochPrice,
|
||||||
ProposalExpiration: math.MaxUint64, // TODO: set something reasonable
|
ProposalExpiration: math.MaxUint64, // TODO: set something reasonable
|
||||||
Duration: blocksDuration,
|
Duration: blocksDuration,
|
||||||
Client: self,
|
Client: addr,
|
||||||
ProviderAddress: miner,
|
ProviderAddress: miner,
|
||||||
MinerWorker: mw,
|
MinerWorker: mw,
|
||||||
MinerID: pid,
|
MinerID: pid,
|
||||||
|
Loading…
Reference in New Issue
Block a user