Documentation ¶
Index ¶
- Variables
- func NewAddrBook(ctx context.Context, store ds.TxnDatastore, opts Options) (*dsAddrBook, error)
- func NewKeyBook(_ context.Context, store ds.TxnDatastore, _ Options) (pstore.KeyBook, error)
- func NewPeerMetadata(_ context.Context, store ds.Datastore, _ Options) (pstore.PeerMetadata, error)
- func NewPeerstore(ctx context.Context, store ds.TxnDatastore, opts Options) (pstore.Peerstore, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
var (
ErrTTLDatastore = errors.New("datastore must provide TTL support")
)
Functions ¶
func NewAddrBook ¶
NewAddrBook initializes a new address book given a Datastore instance, a context for managing the TTL manager, and the interval at which the TTL manager should sweep the Datastore.
func NewKeyBook ¶
func NewPeerMetadata ¶
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.
func NewPeerstore ¶
func NewPeerstore(ctx context.Context, store ds.TxnDatastore, opts Options) (pstore.Peerstore, error)
NewPeerstore creates a peerstore backed by the provided persistent datastore.
Types ¶
type Options ¶
type Options struct { // The size of the in-memory cache. A value of 0 or lower disables the cache. CacheSize uint // Sweep interval to expire entries, only used when TTL is *not* natively managed // by the underlying datastore. TTLInterval time.Duration // Number of times to retry transactional writes. WriteRetries uint }
Configuration object for the peerstore.
func DefaultOpts ¶
func DefaultOpts() Options
DefaultOpts returns the default options for a persistent peerstore: * Cache size: 1024 * TTL sweep interval: 1 second * WriteRetries: 5