pstoreds

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 4 Imported by: 32

Documentation

Overview

Deprecated: This package has moved into go-libp2p as a sub-package: github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddrBook deprecated

func NewAddrBook(ctx context.Context, store ds.Batching, opts Options) (pstore.AddrBook, error)

NewAddrBook initializes a new datastore-backed address book. It serves as a drop-in replacement for pstoremem (memory-backed peerstore), and works with any datastore implementing the ds.Batching interface.

Addresses and peer records are serialized into protobuf, storing one datastore entry per peer, along with metadata to control address expiration. To alleviate disk access and serde overhead, we internally use a read/write-through ARC cache, the size of which is adjustable via Options.CacheSize.

The user has a choice of two GC algorithms:

  • lookahead GC: minimises the amount of full store traversals by maintaining a time-indexed list of entries that need to be visited within the period specified in Options.GCLookaheadInterval. This is useful in scenarios with considerable TTL variance, coupled with datastores whose native iterators return entries in lexicographical key order. Enable this mode by passing a value Options.GCLookaheadInterval > 0. Lookahead windows are jumpy, not sliding. Purges operate exclusively over the lookahead window with periodicity Options.GCPurgeInterval.

  • full-purge GC (default): performs a full visit of the store with periodicity Options.GCPurgeInterval. Useful when the range of possible TTL values is small and the values themselves are also extreme, e.g. 10 minutes or permanent, popular values used in other libp2p modules. In this cited case, optimizing with lookahead windows makes little sense.

Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.NewAddrBook instead

func NewKeyBook deprecated

func NewKeyBook(ctx context.Context, store ds.Datastore, opts Options) (pstore.KeyBook, error)

Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.NewKeyBook instead

func NewPeerMetadata

func NewPeerMetadata(ctx context.Context, store ds.Datastore, opts Options) (pstore.PeerMetadata, error)

NewPeerMetadata creates a metadata store backed by a persistent db. It uses gob for serialisation.

See `init()` to learn which types are registered by default. Modules wishing to store values of other types will need to `gob.Register()` them explicitly, or else callers will receive runtime errors. Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.NewPeerMetadata instead

func NewPeerstore

func NewPeerstore(ctx context.Context, store ds.Batching, opts Options) (peerstore.Peerstore, error)

NewPeerstore creates a peerstore backed by the provided persistent datastore. It's the caller's responsibility to call RemovePeer to ensure that memory consumption of the peerstore doesn't grow unboundedly. Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.NewPeerstore instead

func NewProtoBook deprecated added in v0.0.6

func NewProtoBook(meta pstore.PeerMetadata, opts ...ProtoBookOption) (peerstore.ProtoBook, error)

Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.NewProtoBook instead

Types

type Options

type Options = pstoreds.Options

Configuration object for the peerstore. Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.Options instead

func DefaultOpts

func DefaultOpts() Options

DefaultOpts returns the default options for a persistent peerstore, with the full-purge GC algorithm:

* Cache size: 1024. * MaxProtocols: 1024. * GC purge interval: 2 hours. * GC lookahead interval: disabled. * GC initial delay: 60 seconds. Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.DefaultOpts instead

type ProtoBookOption deprecated added in v0.4.0

type ProtoBookOption = pstoreds.ProtoBookOption

Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.ProtoBookOption instead

func WithMaxProtocols deprecated added in v0.4.0

func WithMaxProtocols(num int) ProtoBookOption

Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds.WithMaxProtocols instead

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL