package pstoremem
import "github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
Index ¶
- func NewAddrBook(opts ...AddrBookOption) *memoryAddrBook
- func NewKeyBook() *memoryKeyBook
- func NewPeerMetadata() *memoryPeerMetadata
- func NewPeerstore(opts ...Option) (ps *pstoremem, err error)
- func NewProtoBook(opts ...ProtoBookOption) (*memoryProtoBook, error)
- type AddrBookOption
- func WithClock(clock clock) AddrBookOption
- func WithMaxAddresses(n int) AddrBookOption
- func WithMaxSignedPeerRecords(n int) AddrBookOption
- type AddrSubManager
- func NewAddrSubManager() *AddrSubManager
- func (mgr *AddrSubManager) AddrStream(ctx context.Context, p peer.ID, initial []ma.Multiaddr) <-chan ma.Multiaddr
- func (mgr *AddrSubManager) BroadcastAddr(p peer.ID, addr ma.Multiaddr)
- type Option
- type ProtoBookOption
Functions ¶
func NewAddrBook ¶
func NewAddrBook(opts ...AddrBookOption) *memoryAddrBook
func NewKeyBook ¶
func NewKeyBook() *memoryKeyBook
func NewPeerMetadata ¶
func NewPeerMetadata() *memoryPeerMetadata
func NewPeerstore ¶
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 ¶
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 ¶
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
Source Files ¶
addr_book.go keybook.go metadata.go peerstore.go protobook.go sorting.go
- Version
- v0.41.1 (latest)
- Published
- Mar 24, 2025
- Platform
- linux/amd64
- Imports
- 19 packages
- Last checked
- 3 weeks ago –
Tools for package owners.