diff --git a/cmd/droplet/run.go b/cmd/droplet/run.go index cb134ca3..8c181272 100644 --- a/cmd/droplet/run.go +++ b/cmd/droplet/run.go @@ -192,12 +192,16 @@ func runDaemon(cctx *cli.Context) error { authClient, _ = jwtclient.NewAuthClient(cfg.AuthNode.Url, cfg.AuthNode.Token) } + var iAuthClient jwtclient.IAuthClient = authClient + if authClient == nil { + iAuthClient = &models.IAuthClientStub{} + } + resAPI := &impl.MarketNodeImpl{} shutdownChan := make(chan struct{}) closeFunc, err := builder.New(ctx, // defaults - builder.Override(new(*jwtclient.AuthClient), authClient), - builder.Override(new(jwtclient.IAuthClient), authClient), + builder.Override(new(jwtclient.IAuthClient), iAuthClient), builder.Override(new(journal.DisabledEvents), journal.EnvDisabledEvents), builder.Override(new(journal.Journal), func(lc fx.Lifecycle, home config.IHome, disabled journal.DisabledEvents) (journal.Journal, error) { return journal.OpenFilesystemJournal(lc, home.MustHomePath(), "droplet", disabled) @@ -215,7 +219,7 @@ func runDaemon(cctx *cli.Context) error { minermgr.MinerMgrOpts(), // clients - clients.ClientsOpts(true, &cfg.Messager, &cfg.Signer, authClient), + clients.ClientsOpts(true, &cfg.Messager, &cfg.Signer, iAuthClient), models.DBOptions(true, &cfg.Mysql), network.NetworkOpts(true, cfg.SimultaneousTransfersForRetrieval, cfg.SimultaneousTransfersForStoragePerClient, cfg.SimultaneousTransfersForStorage), piecestorage.PieceStorageOpts(&cfg.PieceStorage), diff --git a/models/auth.go b/models/auth.go new file mode 100644 index 00000000..ad394b2e --- /dev/null +++ b/models/auth.go @@ -0,0 +1,87 @@ +package models + +import ( + "context" + + "github.com/filecoin-project/go-address" + "github.com/ipfs-force-community/sophon-auth/auth" + "github.com/ipfs-force-community/sophon-auth/core" + "github.com/ipfs-force-community/sophon-auth/jwtclient" +) + +type IAuthClientStub struct { +} + +var _ jwtclient.IAuthClient = (*IAuthClientStub)(nil) + +func (*IAuthClientStub) MinerExistInUser(ctx context.Context, user string, miner address.Address) (bool, error) { + return true, nil +} + +func (*IAuthClientStub) SignerExistInUser(ctx context.Context, user string, signer address.Address) (bool, error) { + return true, nil +} + +func (ia *IAuthClientStub) Verify(ctx context.Context, token string) (*auth.VerifyResponse, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) VerifyUsers(ctx context.Context, names []string) error { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) HasUser(ctx context.Context, name string) (bool, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) GetUser(ctx context.Context, name string) (*auth.OutputUser, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) GetUserByMiner(ctx context.Context, miner address.Address) (*auth.OutputUser, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) GetUserBySigner(ctx context.Context, signer address.Address) (auth.ListUsersResponse, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) ListUsers(ctx context.Context, skip int64, limit int64, state core.UserState) (auth.ListUsersResponse, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) ListUsersWithMiners(ctx context.Context, skip int64, limit int64, state core.UserState) (auth.ListUsersResponse, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) GetUserRateLimit(ctx context.Context, name string, id string) (auth.GetUserRateLimitResponse, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) HasMiner(ctx context.Context, miner address.Address) (bool, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) ListMiners(ctx context.Context, user string) (auth.ListMinerResp, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) UpsertMiner(ctx context.Context, user string, miner string, openMining bool) (bool, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) HasSigner(ctx context.Context, signer address.Address) (bool, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) ListSigners(ctx context.Context, user string) (auth.ListSignerResp, error) { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) RegisterSigners(ctx context.Context, user string, addrs []address.Address) error { + panic("not implemented") // TODO: Implement +} + +func (ia *IAuthClientStub) UnregisterSigners(ctx context.Context, user string, addrs []address.Address) error { + panic("not implemented") // TODO: Implement +} diff --git a/retrievalprovider/event_stream.go b/retrievalprovider/event_stream.go index 67b0aeea..3a22103c 100644 --- a/retrievalprovider/event_stream.go +++ b/retrievalprovider/event_stream.go @@ -14,7 +14,7 @@ import ( gatewayAPIV2 "github.com/filecoin-project/venus/venus-shared/api/gateway/v2" ) -func NewMarketEventStream(mCtx metrics.MetricsCtx, authClient *jwtclient.AuthClient) gatewayAPIV2.IMarketEvent { +func NewMarketEventStream(mCtx metrics.MetricsCtx, authClient jwtclient.IAuthClient) gatewayAPIV2.IMarketEvent { marketStream := marketevent.NewMarketEventStream(mCtx, validator.NewMinerValidator(authClient), &types.RequestConfig{ RequestQueueSize: 30,