client: make wallet addr be a param in ClientStartDeal

Signed-off-by: jsign <jsign.uy@gmail.com>
This commit is contained in:
jsign
2019-12-13 16:15:56 -03:00
parent 71011d03fe
commit 40289848c6
5 changed files with 29 additions and 19 deletions
+7 -5
View File
@@ -53,11 +53,13 @@ type API struct {
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) {
// TODO: make this a param
self, err := a.WalletDefaultAddress(ctx)
func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
exist, err := a.WalletHas(ctx, addr)
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)
@@ -75,7 +77,7 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.A
PricePerEpoch: epochPrice,
ProposalExpiration: math.MaxUint64, // TODO: set something reasonable
Duration: blocksDuration,
Client: self,
Client: addr,
ProviderAddress: miner,
MinerWorker: mw,
MinerID: pid,