Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing market APIs #859

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type Boost interface {
MarketCancelDataTransfer(ctx context.Context, transferID datatransfer.TransferID, otherPeer peer.ID, isInitiator bool) error //perm:write
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error //perm:write
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error) //perm:read
MarketPendingDeals(ctx context.Context) (lapi.PendingDealInfo, error) //perm:write
SectorsRefs(context.Context) (map[string][]lapi.SealedRef, error) //perm:read

PiecesListPieces(ctx context.Context) ([]cid.Cid, error) //perm:read
PiecesListCidInfos(ctx context.Context) ([]cid.Cid, error) //perm:read
Expand Down
11 changes: 10 additions & 1 deletion api/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/multiformats/go-multiaddr"

datatransfer "github.com/filecoin-project/go-data-transfer"
filestore "github.com/filecoin-project/go-fil-markets/filestore"
"github.com/filecoin-project/go-fil-markets/filestore"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-jsonrpc/auth"
textselector "github.com/ipld/go-ipld-selector-text-lite"
Expand Down Expand Up @@ -298,6 +298,15 @@ func init() {
addExample(dealcheckpoints.Transferred)
addExample(lapi.SubsystemMarkets)
addExample(types2.DealRetryAuto)
addExample(map[string][]lapi.SealedRef{
"98000": {
lapi.SealedRef{
SectorID: 100,
Offset: 10 << 20,
Size: 1 << 20,
},
},
})
}

func GetAPIType(name, pkg string) (i interface{}, t reflect.Type, permStruct []reflect.Type) {
Expand Down
26 changes: 26 additions & 0 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/openrpc/boost.json.gz
Binary file not shown.
64 changes: 64 additions & 0 deletions documentation/en/api-v1-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* [MarketListDataTransfers](#marketlistdatatransfers)
* [MarketListIncompleteDeals](#marketlistincompletedeals)
* [MarketListRetrievalDeals](#marketlistretrievaldeals)
* [MarketPendingDeals](#marketpendingdeals)
* [MarketRestartDataTransfer](#marketrestartdatatransfer)
* [MarketSetAsk](#marketsetask)
* [MarketSetRetrievalAsk](#marketsetretrievalask)
Expand Down Expand Up @@ -82,6 +83,8 @@
* [PiecesListPieces](#pieceslistpieces)
* [Runtime](#runtime)
* [RuntimeSubsystems](#runtimesubsystems)
* [Sectors](#sectors)
* [SectorsRefs](#sectorsrefs)
## Actor


Expand Down Expand Up @@ -992,6 +995,44 @@ Response:
]
```

### MarketPendingDeals


Perms: write

Inputs: `null`

Response:
```json
{
"Deals": [
{
"Proposal": {
"PieceCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"PieceSize": 1032,
"VerifiedDeal": true,
"Client": "f01234",
"Provider": "f01234",
"Label": "",
"StartEpoch": 10101,
"EndEpoch": 10101,
"StoragePricePerEpoch": "0",
"ProviderCollateral": "0",
"ClientCollateral": "0"
},
"ClientSignature": {
"Type": 2,
"Data": "Ynl0ZSBhcnJheQ=="
}
}
],
"PublishPeriodStart": "0001-01-01T00:00:00Z",
"PublishPeriod": 60000000000
}
```

### MarketRestartDataTransfer


Expand Down Expand Up @@ -1688,3 +1729,26 @@ Response:
]
```

## Sectors


### SectorsRefs


Perms: read

Inputs: `null`

Response:
```json
{
"98000": [
{
"SectorID": 100,
"Offset": 10485760,
"Size": 1048576
}
]
}
```

28 changes: 25 additions & 3 deletions node/impl/boost_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package impl
import (
"context"
"fmt"
"github.com/filecoin-project/dagstore/shard"
"github.com/multiformats/go-multihash"
"os"
"strconv"
"time"

"github.com/filecoin-project/dagstore/shard"
"github.com/multiformats/go-multihash"

"github.com/filecoin-project/go-address"
datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-fil-markets/piecestore"
Expand All @@ -17,7 +19,7 @@ import (
lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peer"
)

func (sm *BoostAPI) MarketListDataTransfers(ctx context.Context) ([]lapi.DataTransferChannel, error) {
Expand Down Expand Up @@ -242,3 +244,23 @@ func (sm *BoostAPI) PiecesGetMaxOffset(ctx context.Context, pieceCid cid.Cid) (u
func (sm *BoostAPI) RuntimeSubsystems(context.Context) (res lapi.MinerSubsystems, err error) {
return []lapi.MinerSubsystem{lapi.SubsystemMarkets}, nil
}

func (sm *BoostAPI) MarketPendingDeals(ctx context.Context) (lapi.PendingDealInfo, error) {
return sm.DealPublisher.PendingDeals(), nil
}

func (sm *BoostAPI) SectorsRefs(ctx context.Context) (map[string][]lapi.SealedRef, error) {
// json can't handle cids as map keys
out := map[string][]lapi.SealedRef{}

refs, err := sm.SectorBlocks.List(ctx)
if err != nil {
return nil, err
}

for k, v := range refs {
out[strconv.FormatUint(k, 10)] = v
}

return out, nil
}