pstoremem

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 19 Imported by: 84

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddrBook

func NewAddrBook() *memoryAddrBook

func NewKeyBook

func NewKeyBook() *memoryKeyBook

func NewPeerMetadata

func NewPeerMetadata() *memoryPeerMetadata

func NewPeerstore

func NewPeerstore(opts ...Option) (ps *pstoremem, err error)

NewPeerstore creates an in-memory thread-safe collection of peers. It's the caller's responsibility to call RemovePeer to ensure that memory consumption of the peerstore doesn't grow unboundedly.

func NewProtoBook

func NewProtoBook(opts ...ProtoBookOption) (*memoryProtoBook, error)

Types

type AddrBookOption

type AddrBookOption func(book *memoryAddrBook) error

func WithClock

func WithClock(clock clock) AddrBookOption

func WithMaxAddresses added in v0.37.0

func WithMaxAddresses(n int) AddrBookOption

WithMaxAddresses sets the maximum number of unconnected addresses to store. The maximum number of connected addresses is bounded by the connection limits in the Connection Manager and Resource Manager.

func WithMaxSignedPeerRecords added in v0.37.0

func WithMaxSignedPeerRecords(n int) AddrBookOption

type AddrSubManager

type AddrSubManager struct {
	// contains filtered or unexported fields
}

An abstracted, pub-sub manager for address streams. Extracted from memoryAddrBook in order to support additional implementations.

func NewAddrSubManager

func NewAddrSubManager() *AddrSubManager

NewAddrSubManager initializes an AddrSubManager.

func (*AddrSubManager) AddrStream

func (mgr *AddrSubManager) AddrStream(ctx context.Context, p peer.ID, initial []ma.Multiaddr) <-chan ma.Multiaddr

AddrStream creates a new subscription for a given peer ID, pre-populating the channel with any addresses we might already have on file.

func (*AddrSubManager) BroadcastAddr

func (mgr *AddrSubManager) BroadcastAddr(p peer.ID, addr ma.Multiaddr)

BroadcastAddr broadcasts a new address to all subscribed streams.

type Option

type Option interface{}

type ProtoBookOption

type ProtoBookOption func(book *memoryProtoBook) error

func WithMaxProtocols

func WithMaxProtocols(num int) ProtoBookOption

Jump to

Keyboard shortcuts

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