deals: API to list client deals

This commit is contained in:
Łukasz Magiera
2019-09-13 19:59:10 +02:00
parent 388e3ffa96
commit 1fc7a48759
11 changed files with 119 additions and 52 deletions
+7
View File
@@ -86,6 +86,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, price types.BigInt, blocksDuration uint64) (*cid.Cid, error)
ClientListDeals(ctx context.Context) ([]DealInfo, error)
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
ClientFindData(ctx context.Context, root cid.Cid) ([]QueryOffer, error) // TODO: specify serialization mode we want (defaults to unixfs for now)
ClientRetrieve(ctx context.Context, order RetrievalOrder, path string) error
@@ -161,6 +162,12 @@ type Import struct {
Size uint64
}
type DealInfo struct {
ProposalCid cid.Cid
State DealState
Miner peer.ID
}
type MsgWait struct {
InBlock cid.Cid
Receipt types.MessageReceipt
+5
View File
@@ -70,6 +70,7 @@ type FullNodeStruct struct {
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
ClientFindData func(ctx context.Context, root cid.Cid) ([]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"`
ClientListDeals func(ctx context.Context) ([]DealInfo, error) `perm:"write"`
ClientRetrieve func(ctx context.Context, order RetrievalOrder, path string) error `perm:"admin"`
StateMinerSectors func(context.Context, address.Address) ([]*SectorInfo, error) `perm:"read"`
@@ -169,6 +170,10 @@ func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, mine
return c.Internal.ClientStartDeal(ctx, data, miner, price, blocksDuration)
}
func (c *FullNodeStruct) ClientListDeals(ctx context.Context) ([]DealInfo, error) {
return c.Internal.ClientListDeals(ctx)
}
func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order RetrievalOrder, path string) error {
return c.Internal.ClientRetrieve(ctx, order, path)
}
+13
View File
@@ -6,6 +6,19 @@ import (
ma "github.com/multiformats/go-multiaddr"
)
type DealState int
const (
DealUnknown = iota
DealRejected
DealAccepted
DealStarted
DealFailed
DealStaged
DealSealing
DealComplete
)
// TODO: check if this exists anywhere else
type MultiaddrSlice []ma.Multiaddr