peerstore

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWakuPeerstore

func NewWakuPeerstore(p peerstore.Peerstore) peerstore.Peerstore

NewWakuPeerstore creates a new WakuPeerStore object

Types

type ConnectionFailures

type ConnectionFailures struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConnectionFailures contains connection failure information towards all peers

type Origin

type Origin int64

Origin is used to determine how the peer is identified, either it is statically added or discovered via one of the discovery protocols

const (
	Unknown Origin = iota
	Discv5
	Static
	PeerExchange
	DNSDiscovery
	Rendezvous
	PeerManager
)

type WakuPeerstore

type WakuPeerstore interface {
	SetOrigin(p peer.ID, origin Origin) error
	Origin(p peer.ID) (Origin, error)
	PeersByOrigin(origin Origin) peer.IDSlice
	SetENR(p peer.ID, enr *enode.Node) error
	ENR(p peer.ID) (*enode.Node, error)
	AddConnFailure(p peer.AddrInfo)
	ResetConnFailures(p peer.AddrInfo)
	ConnFailures(p peer.AddrInfo) int

	SetDirection(p peer.ID, direction network.Direction) error
	Direction(p peer.ID) (network.Direction, error)

	AddPubSubTopic(p peer.ID, topic string) error
	RemovePubSubTopic(p peer.ID, topic string) error
	PubSubTopics(p peer.ID) ([]string, error)
	SetPubSubTopics(p peer.ID, topics []string) error
	PeersByPubSubTopics(pubSubTopics []string, specificPeers ...peer.ID) peer.IDSlice
	PeersByPubSubTopic(pubSubTopic string, specificPeers ...peer.ID) peer.IDSlice
}

WakuPeerstore is an interface for implementing WakuPeerStore

type WakuPeerstoreImpl

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

WakuPeerstoreImpl is a implementation of WakuPeerStore

func (*WakuPeerstoreImpl) AddAddr

func (ps *WakuPeerstoreImpl) AddAddr(p peer.ID, addr ma.Multiaddr, ttl time.Duration)

func (*WakuPeerstoreImpl) AddAddrs

func (ps *WakuPeerstoreImpl) AddAddrs(p peer.ID, addrs []ma.Multiaddr, ttl time.Duration)

func (*WakuPeerstoreImpl) AddConnFailure

func (ps *WakuPeerstoreImpl) AddConnFailure(p peer.AddrInfo)

AddConnFailure increments connectionFailures for a peer

func (*WakuPeerstoreImpl) AddPrivKey

func (ps *WakuPeerstoreImpl) AddPrivKey(p peer.ID, privk ic.PrivKey) error

func (*WakuPeerstoreImpl) AddProtocols

func (ps *WakuPeerstoreImpl) AddProtocols(p peer.ID, proto ...protocol.ID) error

func (*WakuPeerstoreImpl) AddPubKey

func (ps *WakuPeerstoreImpl) AddPubKey(p peer.ID, pubk ic.PubKey) error

func (*WakuPeerstoreImpl) AddPubSubTopic

func (ps *WakuPeerstoreImpl) AddPubSubTopic(p peer.ID, topic string) error

AddPubSubTopic adds a new pubSubTopic for a peer

func (*WakuPeerstoreImpl) AddrStream

func (ps *WakuPeerstoreImpl) AddrStream(ctx context.Context, p peer.ID) <-chan ma.Multiaddr

func (*WakuPeerstoreImpl) Addrs

func (ps *WakuPeerstoreImpl) Addrs(p peer.ID) []ma.Multiaddr

func (*WakuPeerstoreImpl) ClearAddrs

func (ps *WakuPeerstoreImpl) ClearAddrs(p peer.ID)

func (*WakuPeerstoreImpl) Close

func (ps *WakuPeerstoreImpl) Close() error

func (*WakuPeerstoreImpl) ConnFailures

func (ps *WakuPeerstoreImpl) ConnFailures(p peer.AddrInfo) int

ConnFailures fetches connectionFailures for a peer

func (*WakuPeerstoreImpl) ConsumePeerRecord

func (ps *WakuPeerstoreImpl) ConsumePeerRecord(s *record.Envelope, ttl time.Duration) (accepted bool, err error)

func (*WakuPeerstoreImpl) Direction

func (ps *WakuPeerstoreImpl) Direction(p peer.ID) (network.Direction, error)

Direction fetches the connection direction (Inbound or outBound) for a specific peer

func (*WakuPeerstoreImpl) ENR

func (ps *WakuPeerstoreImpl) ENR(p peer.ID) (*enode.Node, error)

ENR fetches the ENR record for a peer

func (*WakuPeerstoreImpl) FirstSupportedProtocol

func (ps *WakuPeerstoreImpl) FirstSupportedProtocol(p peer.ID, proto ...protocol.ID) (protocol.ID, error)

func (*WakuPeerstoreImpl) Get

func (ps *WakuPeerstoreImpl) Get(p peer.ID, key string) (interface{}, error)

func (*WakuPeerstoreImpl) GetPeerRecord

func (ps *WakuPeerstoreImpl) GetPeerRecord(p peer.ID) *record.Envelope

GetPeerRecord returns a Envelope containing a PeerRecord for the given peer id, if one exists. Returns nil if no signed PeerRecord exists for the peer.

func (*WakuPeerstoreImpl) GetProtocols

func (ps *WakuPeerstoreImpl) GetProtocols(p peer.ID) ([]protocol.ID, error)

func (*WakuPeerstoreImpl) LatencyEWMA

func (ps *WakuPeerstoreImpl) LatencyEWMA(p peer.ID) time.Duration

func (*WakuPeerstoreImpl) Origin

func (ps *WakuPeerstoreImpl) Origin(p peer.ID) (Origin, error)

Origin fetches the origin for a specific peer.

func (*WakuPeerstoreImpl) PeerInfo

func (ps *WakuPeerstoreImpl) PeerInfo(peerID peer.ID) peer.AddrInfo

func (*WakuPeerstoreImpl) Peers

func (ps *WakuPeerstoreImpl) Peers() peer.IDSlice

func (*WakuPeerstoreImpl) PeersByOrigin

func (ps *WakuPeerstoreImpl) PeersByOrigin(expectedOrigin Origin) peer.IDSlice

PeersByOrigin returns the list of peers for a specific origin

func (*WakuPeerstoreImpl) PeersByPubSubTopic

func (ps *WakuPeerstoreImpl) PeersByPubSubTopic(pubSubTopic string, specificPeers ...peer.ID) peer.IDSlice

PeersByPubSubTopic Returns list of peers that support a single pubSubTopic If specifiPeers are listed, filtering is done from them otherwise from all peers in peerstore

func (*WakuPeerstoreImpl) PeersByPubSubTopics added in v0.9.0

func (ps *WakuPeerstoreImpl) PeersByPubSubTopics(pubSubTopics []string, specificPeers ...peer.ID) peer.IDSlice

PeersByPubSubTopic Returns list of peers that support list of pubSubTopics If specifiPeers are listed, filtering is done from them otherwise from all peers in peerstore

func (*WakuPeerstoreImpl) PeersWithAddrs

func (ps *WakuPeerstoreImpl) PeersWithAddrs() peer.IDSlice

func (*WakuPeerstoreImpl) PeersWithKeys

func (ps *WakuPeerstoreImpl) PeersWithKeys() peer.IDSlice

func (*WakuPeerstoreImpl) PrivKey

func (ps *WakuPeerstoreImpl) PrivKey(p peer.ID) ic.PrivKey

func (*WakuPeerstoreImpl) PubKey

func (ps *WakuPeerstoreImpl) PubKey(p peer.ID) ic.PubKey

func (*WakuPeerstoreImpl) PubSubTopics

func (ps *WakuPeerstoreImpl) PubSubTopics(p peer.ID) ([]string, error)

PubSubTopics fetches list of pubSubTopics for a peer

func (*WakuPeerstoreImpl) Put

func (ps *WakuPeerstoreImpl) Put(p peer.ID, key string, val interface{}) error

func (*WakuPeerstoreImpl) RecordLatency

func (ps *WakuPeerstoreImpl) RecordLatency(p peer.ID, t time.Duration)

func (*WakuPeerstoreImpl) RemovePeer

func (ps *WakuPeerstoreImpl) RemovePeer(p peer.ID)

func (*WakuPeerstoreImpl) RemoveProtocols

func (ps *WakuPeerstoreImpl) RemoveProtocols(p peer.ID, proto ...protocol.ID) error

func (*WakuPeerstoreImpl) RemovePubSubTopic added in v0.8.1

func (ps *WakuPeerstoreImpl) RemovePubSubTopic(p peer.ID, topic string) error

RemovePubSubTopic removes a pubSubTopic from the peer

func (*WakuPeerstoreImpl) ResetConnFailures

func (ps *WakuPeerstoreImpl) ResetConnFailures(p peer.AddrInfo)

ResetConnFailures resets connectionFailures for a peer to 0

func (*WakuPeerstoreImpl) SetAddr

func (ps *WakuPeerstoreImpl) SetAddr(p peer.ID, addr ma.Multiaddr, ttl time.Duration)

func (*WakuPeerstoreImpl) SetAddrs

func (ps *WakuPeerstoreImpl) SetAddrs(p peer.ID, addrs []ma.Multiaddr, ttl time.Duration)

func (*WakuPeerstoreImpl) SetDirection

func (ps *WakuPeerstoreImpl) SetDirection(p peer.ID, direction network.Direction) error

SetDirection sets connection direction for a specific peer.

func (*WakuPeerstoreImpl) SetENR

func (ps *WakuPeerstoreImpl) SetENR(p peer.ID, enr *enode.Node) error

SetENR sets the ENR record a peer

func (*WakuPeerstoreImpl) SetOrigin

func (ps *WakuPeerstoreImpl) SetOrigin(p peer.ID, origin Origin) error

SetOrigin sets origin for a specific peer.

func (*WakuPeerstoreImpl) SetProtocols

func (ps *WakuPeerstoreImpl) SetProtocols(p peer.ID, proto ...protocol.ID) error

func (*WakuPeerstoreImpl) SetPubSubTopics

func (ps *WakuPeerstoreImpl) SetPubSubTopics(p peer.ID, topics []string) error

SetPubSubTopics sets pubSubTopics for a peer, it also overrides existing ones that were set previously..

func (*WakuPeerstoreImpl) SupportsProtocols

func (ps *WakuPeerstoreImpl) SupportsProtocols(p peer.ID, proto ...protocol.ID) ([]protocol.ID, error)

func (*WakuPeerstoreImpl) UpdateAddrs

func (ps *WakuPeerstoreImpl) UpdateAddrs(p peer.ID, oldTTL time.Duration, newTTL time.Duration)

Jump to

Keyboard shortcuts

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