Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Jun 7, 2023
1 parent a5340e9 commit 2cbcd9e
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 192 deletions.
5 changes: 4 additions & 1 deletion gql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/filecoin-project/boost/node/modules/dtypes"
"github.com/filecoin-project/boost/piecedirectory"
"github.com/filecoin-project/boost/retrievalmarket/rtvllog"
"github.com/filecoin-project/boost/sectorstatemgr"
"github.com/filecoin-project/boost/storagemanager"
"github.com/filecoin-project/boost/storagemarket"
"github.com/filecoin-project/boost/storagemarket/sealingpipeline"
Expand Down Expand Up @@ -62,14 +63,15 @@ type resolver struct {
legacyProv gfm_storagemarket.StorageProvider
legacyDT dtypes.ProviderDataTransfer
ps piecestore.PieceStore
ssm *sectorstatemgr.SectorStateMgr
sa retrievalmarket.SectorAccessor
piecedirectory *piecedirectory.PieceDirectory
publisher *storageadapter.DealPublisher
spApi sealingpipeline.API
fullNode v1api.FullNode
}

func NewResolver(ctx context.Context, cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, spApi sealingpipeline.API, provider *storagemarket.Provider, legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer, ps piecestore.PieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, publisher *storageadapter.DealPublisher, fullNode v1api.FullNode) *resolver {
func NewResolver(ctx context.Context, cfg *config.Boost, r lotus_repo.LockedRepo, h host.Host, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, spApi sealingpipeline.API, provider *storagemarket.Provider, legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer, ps piecestore.PieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, publisher *storageadapter.DealPublisher, fullNode v1api.FullNode, ssm *sectorstatemgr.SectorStateMgr) *resolver {
return &resolver{
ctx: ctx,
cfg: cfg,
Expand All @@ -91,6 +93,7 @@ func NewResolver(ctx context.Context, cfg *config.Boost, r lotus_repo.LockedRepo
publisher: publisher,
spApi: spApi,
fullNode: fullNode,
ssm: ssm,
}
}

Expand Down
64 changes: 64 additions & 0 deletions gql/resolver_lid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package gql

import (
"context"

gqltypes "github.com/filecoin-project/boost/gql/types"
)

type dealData struct {
Indexed gqltypes.Uint64
FlaggedUnsealed gqltypes.Uint64
FlaggedSealed gqltypes.Uint64
}

type pieces struct {
Indexed int32
FlaggedUnsealed int32
FlaggedSealed int32
}

type sectorUnsealedCopies struct {
Unsealed int32
Sealed int32
}

type sectorProvingState struct {
Active int32
Inactive int32
}

type lidState struct {
DealData dealData
Pieces pieces
SectorUnsealedCopies sectorUnsealedCopies
SectorProvingState sectorProvingState
FlaggedPieces int32
}

// query: lid: [LID]
func (r *resolver) LID(ctx context.Context) (*lidState, error) {
ls := &lidState{
FlaggedPieces: 3654,
DealData: dealData{
Indexed: gqltypes.Uint64(12094627905536),
FlaggedUnsealed: gqltypes.Uint64(1094627905536),
FlaggedSealed: gqltypes.Uint64(18094627905536),
},
Pieces: pieces{
Indexed: 360,
FlaggedUnsealed: 33,
FlaggedSealed: 480,
},
SectorUnsealedCopies: sectorUnsealedCopies{
Sealed: 340,
Unsealed: 340,
},
SectorProvingState: sectorProvingState{
Active: 340,
Inactive: 340,
},
}

return ls, nil
}
33 changes: 33 additions & 0 deletions gql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,36 @@ type SealingPipeline {
Workers: [Worker]!
}

type DealData {
Indexed: Uint64!
FlaggedUnsealed: Uint64!
FlaggedSealed: Uint64!
}

type Pieces {
Indexed: Int!
FlaggedUnsealed: Int!
FlaggedSealed: Int!
}

type SectorUnsealedCopies {
Unsealed: Int!
Sealed: Int!
}

type SectorProvingState {
Active: Int!
Inactive: Int!
}

type LID {
DealData: DealData!
Pieces: Pieces!
SectorUnsealedCopies: SectorUnsealedCopies!
SectorProvingState: SectorProvingState!
FlaggedPieces: Int!
}

type FundsEscrow {
Available: BigInt!
Locked: BigInt!
Expand Down Expand Up @@ -476,6 +506,9 @@ type RootQuery {
"""Get sealing pipeline state"""
sealingpipeline: SealingPipeline!

"""Get LID state"""
lid: LID!

"""Get funds available"""
funds: Funds!

Expand Down
7 changes: 4 additions & 3 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/filecoin-project/boost/piecedirectory"
brm "github.com/filecoin-project/boost/retrievalmarket/lib"
"github.com/filecoin-project/boost/retrievalmarket/rtvllog"
"github.com/filecoin-project/boost/sectorstatemgr"
"github.com/filecoin-project/boost/storagemanager"
"github.com/filecoin-project/boost/storagemarket"
"github.com/filecoin-project/boost/storagemarket/logs"
Expand Down Expand Up @@ -628,14 +629,14 @@ func NewStorageMarketProvider(provAddr address.Address, cfg *config.Boost) func(
}
}

func NewGraphqlServer(cfg *config.Boost) func(lc fx.Lifecycle, r repo.LockedRepo, h host.Host, prov *storagemarket.Provider, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, publisher *storageadapter.DealPublisher, spApi sealingpipeline.API, legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer, ps dtypes.ProviderPieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, fullNode v1api.FullNode, bg gql.BlockGetter) *gql.Server {
func NewGraphqlServer(cfg *config.Boost) func(lc fx.Lifecycle, r repo.LockedRepo, h host.Host, prov *storagemarket.Provider, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager, storageMgr *storagemanager.StorageManager, publisher *storageadapter.DealPublisher, spApi sealingpipeline.API, legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer, ps dtypes.ProviderPieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, fullNode v1api.FullNode, bg gql.BlockGetter, ssm *sectorstatemgr.SectorStateMgr) *gql.Server {
return func(lc fx.Lifecycle, r repo.LockedRepo, h host.Host, prov *storagemarket.Provider, dealsDB *db.DealsDB, logsDB *db.LogsDB, retDB *rtvllog.RetrievalLogDB, plDB *db.ProposalLogsDB, fundsDB *db.FundsDB, fundMgr *fundmanager.FundManager,
storageMgr *storagemanager.StorageManager, publisher *storageadapter.DealPublisher, spApi sealingpipeline.API,
legacyProv gfm_storagemarket.StorageProvider, legacyDT dtypes.ProviderDataTransfer,
ps dtypes.ProviderPieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, fullNode v1api.FullNode, bg gql.BlockGetter) *gql.Server {
ps dtypes.ProviderPieceStore, sa retrievalmarket.SectorAccessor, piecedirectory *piecedirectory.PieceDirectory, fullNode v1api.FullNode, bg gql.BlockGetter, ssm *sectorstatemgr.SectorStateMgr) *gql.Server {

resolverCtx, cancel := context.WithCancel(context.Background())
resolver := gql.NewResolver(resolverCtx, cfg, r, h, dealsDB, logsDB, retDB, plDB, fundsDB, fundMgr, storageMgr, spApi, prov, legacyProv, legacyDT, ps, sa, piecedirectory, publisher, fullNode)
resolver := gql.NewResolver(resolverCtx, cfg, r, h, dealsDB, logsDB, retDB, plDB, fundsDB, fundMgr, storageMgr, spApi, prov, legacyProv, legacyDT, ps, sa, piecedirectory, publisher, fullNode, ssm)
server := gql.NewServer(resolver, bg)

lc.Append(fx.Hook{
Expand Down
Loading

0 comments on commit 2cbcd9e

Please sign in to comment.