pstoremem

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 18 Imported by: 0

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

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