Documentation
¶
Index ¶
- Constants
- Variables
- func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, hashOnRead bool, writeThrough bool, ...) ...
- func Bitswap(serverEnabled, libp2pEnabled, httpEnabled bool) interface{}
- func BitswapOptions(cfg *config.Config) interface{}
- func BlockService(cfg *config.Config) ...
- func DNSResolver(cfg *config.Config) (*madns.Resolver, error)
- func Dag(bs blockservice.BlockService) format.DAGService
- func Datastore(repo repo.Repo) datastore.Datastore
- func Files(strategy string) ...
- func FilestoreBlockstoreCtor(repo repo.Repo, bb BaseBlocks, prov DHTProvider) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, ...)
- func GcBlockstoreCtor(bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, ...)
- func IPFS(ctx context.Context, bcfg *BuildCfg) fx.Option
- func Identity(cfg *config.Config) fx.Option
- func IpnsRepublisher(repubPeriod time.Duration, recordLifetime time.Duration) func(lcStartStop, namesys.NameSystem, repo.Repo, crypto.PrivKey) error
- func LegacyProviderOpt(reprovideInterval time.Duration, strategy string, acceleratedDHTClient bool, ...) fx.Option
- func LibP2P(bcfg *BuildCfg, cfg *config.Config, ...) fx.Option
- func Namesys(cacheSize int, cacheMaxTTL time.Duration) ...
- func Networked(bcfg *BuildCfg, cfg *config.Config, ...) fx.Option
- func Offline(cfg *config.Config) fx.Option
- func OfflineProviders() fx.Option
- func Online(bcfg *BuildCfg, cfg *config.Config, ...) fx.Option
- func OnlineExchange(isBitswapActive bool) interface{}
- func OnlineProviders(provide bool, cfg *config.Config) fx.Option
- func PeerID(id peer.ID) func() peer.ID
- func PeerWith(peers ...peer.AddrInfo) fx.Option
- func Peering(lc fx.Lifecycle, host host.Host) *peering.PeeringService
- func Pinning(strategy string) ...
- func PrivateKey(sk crypto.PrivKey) func(id peer.ID) (crypto.PrivKey, error)
- func RecordValidator(ps peerstore.Peerstore) record.Validator
- func RepoConfig(repo repo.Repo) (*config.Config, error)
- func Storage(bcfg *BuildCfg, cfg *config.Config) fx.Option
- func SweepingProviderOpt(cfg *config.Config) fx.Option
- type BaseBlocks
- type BuildCfg
- type DHTProvider
- type FetchersIn
- type FetchersOut
- type LegacyProvider
- type NoopProvider
- type PathResolversOut
Constants ¶
const ( DefaultEngineBlockstoreWorkerCount = 128 DefaultTaskWorkerCount = 8 DefaultEngineTaskWorkerCount = 8 DefaultMaxOutstandingBytesPerPeer = 1 << 20 DefaultProviderSearchDelay = 1000 * time.Millisecond DefaultMaxProviders = 10 // matching BitswapClientDefaultMaxProviders from https://github.com/ipfs/boxo/blob/v0.29.1/bitswap/internal/defaults/defaults.go#L15 DefaultWantHaveReplaceSize = 1024 )
Docs: https://github.com/ipfs/kubo/blob/master/docs/config.md#internalbitswap
const DefaultIpnsCacheSize = 128
Variables ¶
var BaseLibP2P = fx.Options( fx.Provide(libp2p.PNet), fx.Provide(libp2p.ConnectionManager), fx.Provide(libp2p.Host), fx.Provide(libp2p.MultiaddrResolver), fx.Provide(libp2p.DiscoveryHandler), fx.Invoke(libp2p.PNetChecker), )
var Core = fx.Options( fx.Provide(Dag), fx.Provide(FetcherConfig), fx.Provide(PathResolverConfig), )
Core groups basic IPFS services
var IPNS = fx.Options( fx.Provide(RecordValidator), )
IPNS groups namesys related units
Functions ¶
func BaseBlockstoreCtor ¶
func BaseBlockstoreCtor( cacheOpts blockstore.CacheOpts, hashOnRead bool, writeThrough bool, providingStrategy string, ) func(mctx helpers.MetricsCtx, repo repo.Repo, prov DHTProvider, lc fx.Lifecycle) (bs BaseBlocks, err error)
BaseBlockstoreCtor creates cached blockstore backed by the provided datastore
func Bitswap ¶ added in v0.33.0
func Bitswap(serverEnabled, libp2pEnabled, httpEnabled bool) interface{}
Bitswap creates the BitSwap server/client instance. If Bitswap.ServerEnabled is false, the node will act only as a client using an empty blockstore to prevent serving blocks to other peers.
func BitswapOptions ¶ added in v0.16.0
BitswapOptions creates configuration options for Bitswap from the config file and whether to provide data.
func BlockService ¶
func BlockService(cfg *config.Config) func(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interface) blockservice.BlockService
BlockService creates new blockservice which provides an interface to fetch content-addressable blocks
func Files ¶
func Files(strategy string) func(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService, bs blockstore.Blockstore, prov DHTProvider) (*mfs.Root, error)
Files loads persisted MFS root
func FilestoreBlockstoreCtor ¶
func FilestoreBlockstoreCtor(repo repo.Repo, bb BaseBlocks, prov DHTProvider) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore, fstore *filestore.Filestore)
FilestoreBlockstoreCtor wraps GcBlockstore and adds Filestore support
func GcBlockstoreCtor ¶
func GcBlockstoreCtor(bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore)
GcBlockstoreCtor wraps the base blockstore with GC and Filestore layers
func IpnsRepublisher ¶
func IpnsRepublisher(repubPeriod time.Duration, recordLifetime time.Duration) func(lcStartStop, namesys.NameSystem, repo.Repo, crypto.PrivKey) error
IpnsRepublisher runs new IPNS republisher service
func LegacyProviderOpt ¶ added in v0.38.0
func LegacyProviderOpt(reprovideInterval time.Duration, strategy string, acceleratedDHTClient bool, provideWorkerCount int) fx.Option
LegacyProviderOpt creates a LegacyProvider to be used as provider in the IpfsNode
func Namesys ¶
func Namesys(cacheSize int, cacheMaxTTL time.Duration) func(rt irouting.ProvideManyRouter, rslv *madns.Resolver, repo repo.Repo) (namesys.NameSystem, error)
Namesys creates new name system
func OfflineProviders ¶
OfflineProviders groups units managing provide routing records offline
func Online ¶
func Online(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.PartialLimitConfig) fx.Option
Online groups online-only units
func OnlineExchange ¶
func OnlineExchange(isBitswapActive bool) interface{}
OnlineExchange creates new LibP2P backed block exchange. Returns a no-op exchange if Bitswap is disabled.
func OnlineProviders ¶
OnlineProviders groups units managing provide routing records online
func Peering ¶
Peering constructs the peering service and hooks it into fx's lifetime management system.
func Pinning ¶
func Pinning(strategy string) func(bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo, prov DHTProvider) (pin.Pinner, error)
Pinning creates new pinner which tells GC which blocks should be kept
func PrivateKey ¶
PrivateKey loads the private key from config
func RecordValidator ¶
RecordValidator provides namesys compatible routing record validator
func RepoConfig ¶
RepoConfig loads configuration from the repo
Types ¶
type BaseBlocks ¶
type BaseBlocks blockstore.Blockstore
BaseBlocks is the lower level blockstore without GC or Filestore layers
type BuildCfg ¶
type BuildCfg struct {
// If online is set, the node will have networking enabled
Online bool
// ExtraOpts is a map of extra options used to configure the ipfs nodes creation
ExtraOpts map[string]bool
// If permanent then node should run more expensive processes
// that will improve performance in long run
Permanent bool
// DisableEncryptedConnections disables connection encryption *entirely*.
// DO NOT SET THIS UNLESS YOU'RE TESTING.
DisableEncryptedConnections bool
Routing libp2p.RoutingOption
Host libp2p.HostOption
Repo repo.Repo
}
type DHTProvider ¶ added in v0.38.0
type DHTProvider interface {
// StartProviding ensures keys are periodically advertised to the DHT swarm.
//
// If the `keys` aren't currently being reprovided, they are added to the
// queue to be provided to the DHT swarm as soon as possible, and scheduled
// to be reprovided periodically. If `force` is set to true, all keys are
// provided to the DHT swarm, regardless of whether they were already being
// reprovided in the past. `keys` keep being reprovided until `StopProviding`
// is called.
//
// This operation is asynchronous, it returns as soon as the `keys` are added
// to the provide queue, and provides happens asynchronously.
//
// Returns an error if the keys couldn't be added to the provide queue. This
// can happen if the provider is closed or if the node is currently Offline
// (either never bootstrapped, or disconnected since more than `OfflineDelay`).
// The schedule and provide queue depend on the network size, hence recent
// network connectivity is essential.
StartProviding(force bool, keys ...mh.Multihash) error
// ProvideOnce sends provider records for the specified keys to the DHT swarm
// only once. It does not automatically reprovide those keys afterward.
//
// Add the supplied multihashes to the provide queue, and return immediately.
// The provide operation happens asynchronously.
//
// Returns an error if the keys couldn't be added to the provide queue. This
// can happen if the provider is closed or if the node is currently Offline
// (either never bootstrapped, or disconnected since more than `OfflineDelay`).
// The schedule and provide queue depend on the network size, hence recent
// network connectivity is essential.
ProvideOnce(keys ...mh.Multihash) error
// Clear clears the all the keys from the provide queue and returns the number
// of keys that were cleared.
//
// The keys are not deleted from the keystore, so they will continue to be
// reprovided as scheduled.
Clear() int
// RefreshSchedule scans the Keystore for any keys that are not currently
// scheduled for reproviding. If such keys are found, it schedules their
// associated keyspace region to be reprovided.
//
// This function doesn't remove prefixes that have no keys from the schedule.
// This is done automatically during the reprovide operation if a region has no
// keys.
//
// Returns an error if the provider is closed or if the node is currently
// Offline (either never bootstrapped, or disconnected since more than
// `OfflineDelay`). The schedule depends on the network size, hence recent
// network connectivity is essential.
RefreshSchedule() error
Close() error
}
DHTProvider is an interface for providing keys to a DHT swarm. It holds a state of keys to be advertised, and is responsible for periodically publishing provider records for these keys to the DHT swarm before the records expire.
type FetchersIn ¶ added in v0.20.0
type FetchersIn struct {
fx.In
IPLDFetcher fetcher.Factory `name:"ipldFetcher"`
UnixfsFetcher fetcher.Factory `name:"unixfsFetcher"`
OfflineIPLDFetcher fetcher.Factory `name:"offlineIpldFetcher"`
OfflineUnixfsFetcher fetcher.Factory `name:"offlineUnixfsFetcher"`
}
FetchersIn allows using fetchers for other dependencies.
type FetchersOut ¶ added in v0.20.0
type FetchersOut struct {
fx.Out
IPLDFetcher fetcher.Factory `name:"ipldFetcher"`
UnixfsFetcher fetcher.Factory `name:"unixfsFetcher"`
OfflineIPLDFetcher fetcher.Factory `name:"offlineIpldFetcher"`
OfflineUnixfsFetcher fetcher.Factory `name:"offlineUnixfsFetcher"`
}
FetchersOut allows injection of fetchers.
func FetcherConfig ¶
func FetcherConfig(bs blockservice.BlockService) FetchersOut
FetcherConfig returns a fetcher config that can build new fetcher instances
type LegacyProvider ¶ added in v0.38.0
LegacyProvider is a wrapper around the boxo/provider.System that implements the DHTProvider interface. This provider manages reprovides using a burst strategy where it sequentially reprovides all keys at once during each reprovide interval, rather than spreading the load over time.
This is the legacy provider implementation that can cause resource spikes during reprovide operations. For more efficient providing, consider using the SweepingProvider which spreads the load over the reprovide interval.
func (*LegacyProvider) Clear ¶ added in v0.38.0
func (r *LegacyProvider) Clear() int
func (*LegacyProvider) ProvideOnce ¶ added in v0.38.0
func (r *LegacyProvider) ProvideOnce(keys ...mh.Multihash) error
func (*LegacyProvider) RefreshSchedule ¶ added in v0.38.0
func (r *LegacyProvider) RefreshSchedule() error
func (*LegacyProvider) StartProviding ¶ added in v0.38.0
func (r *LegacyProvider) StartProviding(force bool, keys ...mh.Multihash) error
type NoopProvider ¶ added in v0.38.0
type NoopProvider struct{}
NoopProvider is a no-operation provider implementation that does nothing. It is used when providing is disabled or when no DHT is available. All methods return successfully without performing any actual operations.
func (*NoopProvider) Clear ¶ added in v0.38.0
func (r *NoopProvider) Clear() int
func (*NoopProvider) Close ¶ added in v0.39.0
func (r *NoopProvider) Close() error
func (*NoopProvider) ProvideOnce ¶ added in v0.38.0
func (r *NoopProvider) ProvideOnce(...mh.Multihash) error
func (*NoopProvider) RefreshSchedule ¶ added in v0.38.0
func (r *NoopProvider) RefreshSchedule() error
func (*NoopProvider) StartProviding ¶ added in v0.38.0
func (r *NoopProvider) StartProviding(bool, ...mh.Multihash) error
type PathResolversOut ¶ added in v0.20.0
type PathResolversOut struct {
fx.Out
IPLDPathResolver pathresolver.Resolver `name:"ipldPathResolver"`
UnixFSPathResolver pathresolver.Resolver `name:"unixFSPathResolver"`
OfflineIPLDPathResolver pathresolver.Resolver `name:"offlineIpldPathResolver"`
OfflineUnixFSPathResolver pathresolver.Resolver `name:"offlineUnixFSPathResolver"`
}
PathResolversOut allows injection of path resolvers
func PathResolverConfig ¶ added in v0.20.0
func PathResolverConfig(fetchers FetchersIn) PathResolversOut
PathResolverConfig creates path resolvers with the given fetchers.