forked from filecoin-project/boost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When disabled in config, completely disable index provider (filecoin-…
…project#558) * feat: completely disable index provider * fix: dont announce if index provider disabled
- Loading branch information
Showing
12 changed files
with
138 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package indexprovider | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/filecoin-project/index-provider" | ||
"github.com/filecoin-project/index-provider/metadata" | ||
"github.com/filecoin-project/storetheindex/api/v0/ingest/schema" | ||
"github.com/ipfs/go-cid" | ||
) | ||
|
||
type DisabledIndexProvider struct { | ||
} | ||
|
||
func NewDisabledIndexProvider() *DisabledIndexProvider { | ||
return &DisabledIndexProvider{} | ||
} | ||
|
||
func (d DisabledIndexProvider) PublishLocal(ctx context.Context, advertisement schema.Advertisement) (cid.Cid, error) { | ||
return cid.Undef, fmt.Errorf("could not publish locally: index provider disabled") | ||
} | ||
|
||
func (d DisabledIndexProvider) Publish(ctx context.Context, advertisement schema.Advertisement) (cid.Cid, error) { | ||
return cid.Undef, fmt.Errorf("could not publish: index provider disabled") | ||
} | ||
|
||
func (d DisabledIndexProvider) RegisterMultihashLister(lister provider.MultihashLister) { | ||
} | ||
|
||
func (d DisabledIndexProvider) NotifyPut(ctx context.Context, contextID []byte, md metadata.Metadata) (cid.Cid, error) { | ||
return cid.Undef, fmt.Errorf("could not notify put: index provider disabled") | ||
} | ||
|
||
func (d DisabledIndexProvider) NotifyRemove(ctx context.Context, contextID []byte) (cid.Cid, error) { | ||
return cid.Undef, fmt.Errorf("could not notify remove: index provider disabled") | ||
} | ||
|
||
func (d DisabledIndexProvider) GetAdv(ctx context.Context, cid cid.Cid) (*schema.Advertisement, error) { | ||
return nil, fmt.Errorf("could not get advertisement: index provider disabled") | ||
} | ||
|
||
func (d DisabledIndexProvider) GetLatestAdv(ctx context.Context) (cid.Cid, *schema.Advertisement, error) { | ||
return cid.Undef, nil, fmt.Errorf("could not get latest advertisement: index provider disabled") | ||
} | ||
|
||
func (d DisabledIndexProvider) Shutdown() error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package modules | ||
|
||
import ( | ||
"github.com/filecoin-project/boost/indexprovider" | ||
provider "github.com/filecoin-project/index-provider" | ||
"github.com/filecoin-project/lotus/node/config" | ||
lotus_modules "github.com/filecoin-project/lotus/node/modules" | ||
"github.com/filecoin-project/lotus/node/modules/dtypes" | ||
"github.com/libp2p/go-libp2p-core/host" | ||
pubsub "github.com/libp2p/go-libp2p-pubsub" | ||
) | ||
|
||
func IndexProvider(cfg config.IndexProviderConfig) func(params lotus_modules.IdxProv, marketHost host.Host, dt dtypes.ProviderDataTransfer, maddr dtypes.MinerAddress, ps *pubsub.PubSub, nn dtypes.NetworkName) (provider.Interface, error) { | ||
if !cfg.Enable { | ||
log.Warnf("Starting Boost with index provider disabled - no announcements will be made to the index provider") | ||
return func(params lotus_modules.IdxProv, marketHost host.Host, dt dtypes.ProviderDataTransfer, maddr dtypes.MinerAddress, ps *pubsub.PubSub, nn dtypes.NetworkName) (provider.Interface, error) { | ||
return indexprovider.NewDisabledIndexProvider(), nil | ||
} | ||
} | ||
return lotus_modules.IndexProvider(cfg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters