deals: Show proposal cid in cli
This commit is contained in:
parent
821e03bcd7
commit
2114e8f555
@ -116,8 +116,7 @@ type FullNode interface {
|
||||
|
||||
// ClientImport imports file under the specified path into filestore
|
||||
ClientImport(ctx context.Context, path string) (cid.Cid, error)
|
||||
|
||||
ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, blocksDuration uint64) error
|
||||
ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error)
|
||||
|
||||
// ClientUnimport removes references to the specified file from filestore
|
||||
//ClientUnimport(path string)
|
||||
|
@ -62,9 +62,9 @@ type FullNodeStruct struct {
|
||||
WalletDefaultAddress func(context.Context) (address.Address, error) `perm:"write"`
|
||||
MpoolGetNonce func(context.Context, address.Address) (uint64, error) `perm:"read"`
|
||||
|
||||
ClientImport func(ctx context.Context, path string) (cid.Cid, error) `perm:"write"`
|
||||
ClientListImports func(ctx context.Context) ([]Import, error) `perm:"read"`
|
||||
ClientStartDeal func(ctx context.Context, data cid.Cid, miner address.Address, blocksDuration uint64) error `perm:"admin"`
|
||||
ClientImport func(ctx context.Context, path string) (cid.Cid, error) `perm:"write"`
|
||||
ClientListImports func(ctx context.Context) ([]Import, error) `perm:"read"`
|
||||
ClientStartDeal func(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) `perm:"admin"`
|
||||
|
||||
StateMinerSectors func(context.Context, address.Address) ([]*SectorInfo, error) `perm:"read"`
|
||||
StateMinerProvingSet func(context.Context, address.Address) ([]*SectorInfo, error) `perm:"read"`
|
||||
@ -129,8 +129,8 @@ func (c *FullNodeStruct) ClientImport(ctx context.Context, path string) (cid.Cid
|
||||
return c.Internal.ClientImport(ctx, path)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, blocksDuration uint64) error {
|
||||
return c.Internal.ClientStartDeal(ctx, data, miner, blocksDuration)
|
||||
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
|
||||
return c.Internal.ClientStartDeal(ctx, data, miner, price, blocksDuration)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) MpoolPending(ctx context.Context, ts *types.TipSet) ([]*types.SignedMessage, error) {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/chain/address"
|
||||
"github.com/filecoin-project/go-lotus/chain/types"
|
||||
)
|
||||
|
||||
var clientCmd = &cli.Command{
|
||||
@ -71,8 +72,8 @@ var clientDealCmd = &cli.Command{
|
||||
}
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
if cctx.NArg() != 3 {
|
||||
return xerrors.New("expected 3 args: dataCid, miner, duration")
|
||||
if cctx.NArg() != 4 {
|
||||
return xerrors.New("expected 4 args: dataCid, miner, price, duration")
|
||||
}
|
||||
|
||||
// [data, miner, dur]
|
||||
@ -87,11 +88,23 @@ var clientDealCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
dur, err := strconv.ParseInt(cctx.Args().Get(2), 10, 32)
|
||||
// TODO: parse bigint
|
||||
price, err := strconv.ParseInt(cctx.Args().Get(2), 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return api.ClientStartDeal(ctx, data, miner, uint64(dur))
|
||||
dur, err := strconv.ParseInt(cctx.Args().Get(3), 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
proposal, err := api.ClientStartDeal(ctx, data, miner, types.NewInt(uint64(price)), uint64(dur))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(proposal)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/filecoin-project/go-lotus/chain"
|
||||
"github.com/filecoin-project/go-lotus/chain/actors"
|
||||
@ -27,6 +25,7 @@ import (
|
||||
logging "github.com/ipfs/go-log"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
var log = logging.Logger("node")
|
||||
@ -43,10 +42,10 @@ type FullNodeAPI struct {
|
||||
Wallet *wallet.Wallet
|
||||
}
|
||||
|
||||
func (a *FullNodeAPI) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, blocksDuration uint64) error {
|
||||
func (a *FullNodeAPI) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
|
||||
self, err := a.WalletDefaultAddress(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
msg := &types.Message{
|
||||
@ -57,17 +56,16 @@ func (a *FullNodeAPI) ClientStartDeal(ctx context.Context, data cid.Cid, miner a
|
||||
|
||||
r, err := a.ChainCall(ctx, msg, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
pid, err := peer.IDFromBytes(r.Return)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
price := types.NewInt(10 * blocksDuration) // TODO: allow to actually specify this
|
||||
|
||||
_, err = a.DealClient.Start(ctx, data, price, self, miner, pid, blocksDuration)
|
||||
return err
|
||||
total := types.BigMul(price, types.NewInt(blocksDuration))
|
||||
c, err := a.DealClient.Start(ctx, data, total, self, miner, pid, blocksDuration)
|
||||
return &c, err
|
||||
}
|
||||
|
||||
func (a *FullNodeAPI) ChainNotify(ctx context.Context) (<-chan *store.HeadChange, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user